pub struct PdfPageGroupObject<'a> { /* private fields */ }
Expand description

A group of PdfPageObject objects contained in the same PdfPageObjects collection. The page objects contained in the group can be manipulated and transformed together as if they were a single object.

Groups are bound to specific pages in the document. To create an empty group, use either the PdfPageObjects::create_new_group() function or the PdfPageGroupObject::empty() function. To create a populated group, use one of the PdfPageGroupObject::new(), PdfPageGroupObject::from_vec(), or PdfPageGroupObject::from_slice() functions.

Implementations§

source§

impl<'a> PdfPageGroupObject<'a>

source

pub fn empty(page: &'a PdfPage<'_>) -> Self

Creates a new, empty PdfPageGroupObject that can be used to hold any page objects on the given PdfPage.

source

pub fn new<F>(page: &'a PdfPage<'_>, predicate: F) -> Result<Self, PdfiumError>where
    F: FnMut(&PdfPageObject<'_>) -> bool,

Creates a new PdfPageGroupObject that includes any page objects on the given PdfPage matching the given predicate function.

source

pub fn from_vec(
    page: &PdfPage<'a>,
    objects: Vec<PdfPageObject<'a>>
) -> Result<Self, PdfiumError>

Creates a new PdfPageGroupObject that includes the given page objects on the given PdfPage.

source

pub fn from_slice(
    page: &PdfPage<'a>,
    objects: &mut [PdfPageObject<'a>]
) -> Result<Self, PdfiumError>

Creates a new PdfPageGroupObject that includes the given page objects on the given PdfPage.

source

pub fn len(&self) -> usize

Returns the number of page objects in this group.

source

pub fn is_empty(&self) -> bool

Returns true if this group contains no page objects.

source

pub fn contains(&self, object: &PdfPageObject<'_>) -> bool

Returns true if this group already contains the given page object.

source

pub fn push(&mut self, object: &mut PdfPageObject<'a>) -> Result<(), PdfiumError>

Adds a single PdfPageObject to this group.

source

pub fn append(
    &mut self,
    objects: &mut [PdfPageObject<'a>]
) -> Result<(), PdfiumError>

Adds all the given PdfPageObject objects to this group.

source

pub fn remove_objects_from_page(self) -> Result<(), PdfiumError>

Removes every PdfPageObject in this group from the group’s containing PdfPage and from this group, consuming the group.

Each object’s memory ownership will be removed from the PdfPageObjects collection for this group’s containing PdfPage. The objects will also be removed from this group, and the memory owned by each object will be freed.

If the containing PdfPage has a content regeneration strategy of PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration will be triggered on the page.

source

pub fn get(
    &self,
    index: PdfPageObjectIndex
) -> Result<PdfPageObject<'_>, PdfiumError>

Returns a single PdfPageObject from this group.

source

pub fn retain<F>(&mut self, f: F)where
    F: Fn(&PdfPageObject<'_>) -> bool,

Retains only the PdfPageObject objects in this group specified by the given predicate function.

Unretained objects are only removed from this group. They remain on the source PdfPage that currently contains them.

source

pub fn retain_if_copyable(&mut self)

Retains only the PdfPageObject objects in this group that can be copied.

Objects that cannot be copied are only removed from this group. They remain on the source PdfPage that currently contains them.

source

pub fn is_copyable(&self) -> bool

Returns true if all the PdfPageObject objects in this group can be copied.

source

pub fn try_copy_onto_existing_page<'b>(
    &self,
    destination: &mut PdfPage<'b>
) -> Result<PdfPageGroupObject<'b>, PdfiumError>

Attempts to copy all the PdfPageObject objects in this group, placing the copied objects onto the given existing destination PdfPage.

This function can only copy page objects supported by the PdfPageObjectCommon::try_copy() method. For a different approach that supports more page object types but is more limited in where the copied objects can be placed, see the PdfPageGroupObject::copy_onto_new_page_at_start(), PdfPageGroupObject::copy_onto_new_page_at_end(), and PdfPageGroupObject::copy_onto_new_page_at_index() functions.

If all objects were copied successfully, then a new PdfPageGroupObject containing the clones is returned, allowing the new objects to be manipulated as a group.

source

pub fn copy_onto_new_page_at_start(
    &self,
    destination: &PdfDocument<'_>
) -> Result<(), PdfiumError>

Copies all the PdfPageObject objects in this group by copying the page containing the objects in this group into a new page at the start of the given destination PdfDocument then removing all objects from the new page not in this group.

This function differs internally from PdfPageGroupObject::try_copy_onto_existing_page() in that it uses Pdfium to copy page objects instead of the PdfPageObjectCommon::try_copy() method provided by pdfium-render. As a result, this function can copy some objects that PdfPageGroupObject::try_copy_onto_existing_page() cannot; for example, it can copy path objects containing Bézier curves. However, it can only copy objects onto a new page, not an existing page, and it cannot return a new PdfPageGroupObject containing the newly created objects.

The new page will have the same size and bounding box configuration as the page containing the objects in this group.

source

pub fn copy_onto_new_page_at_end(
    &self,
    destination: &PdfDocument<'_>
) -> Result<(), PdfiumError>

Copies all the PdfPageObject objects in this group by copying the page containing the objects in this group into a new page at the end of the given destination PdfDocument then removing all objects from the new page not in this group.

This function differs internally from PdfPageGroupObject::try_copy_onto_existing_page() in that it uses Pdfium to copy page objects instead of the PdfPageObjectCommon::try_copy() method provided by pdfium-render. As a result, this function can copy some objects that PdfPageGroupObject::try_copy_onto_existing_page() cannot; for example, it can copy path objects containing Bézier curves. However, it can only copy objects onto a new page, not an existing page, and it cannot return a new PdfPageGroupObject containing the newly created objects.

The new page will have the same size and bounding box configuration as the page containing the objects in this group.

source

pub fn copy_onto_new_page_at_index(
    &self,
    index: PdfPageIndex,
    destination: &PdfDocument<'_>
) -> Result<(), PdfiumError>

Copies all the PdfPageObject objects in this group by copying the page containing the objects in this group into a new page in the given destination PdfDocument at the given page index, then removing all objects from the new page not in this group.

This function differs internally from PdfPageGroupObject::try_copy_onto_existing_page() in that it uses Pdfium to copy page objects instead of the PdfPageObjectCommon::try_copy() method provided by pdfium-render. As a result, this function can copy some objects that PdfPageGroupObject::try_copy_onto_existing_page() cannot; for example, it can copy path objects containing Bézier curves. However, it can only copy objects onto a new page, not an existing page, and it cannot return a new PdfPageGroupObject containing the newly created objects.

The new page will have the same size and bounding box configuration as the page containing the objects in this group.

source

pub fn iter(&'a self) -> PdfPageGroupObjectIterator<'a>

Returns an iterator over all the PdfPageObject objects in this group.

source

pub fn text(&self) -> String

Returns the text contained within all PdfPageTextObject objects in this group.

source

pub fn text_separated(&self, separator: &str) -> String

Returns the text contained within all PdfPageTextObject objects in this group, separating each text fragment with the given separator.

source

pub fn has_transparency(&self) -> bool

Returns true if any PdfPageObject in this group contains transparency.

source

pub fn bounds(&self) -> Result<PdfRect, PdfiumError>

Returns the bounding box of this group of objects. Since the bounds of every object in the group must be considered, this function has runtime complexity of O(n).

source

pub fn transform(
    &mut self,
    a: f64,
    b: f64,
    c: f64,
    d: f64,
    e: f64,
    f: f64
) -> Result<(), PdfiumError>

Applies the given transformation, expressed as six values representing the six configurable elements of a nine-element 3x3 PDF transformation matrix, to every PdfPageObject in this group.

To move, scale, rotate, or skew the page objects in this group, consider using one or more of the following functions. Internally they all use PdfPageGroupObject::transform(), but are probably easier to use (and certainly clearer in their intent) in most situations.

The order in which transformations are applied to a page object is significant. For example, the result of rotating then translating a page object may be vastly different from translating then rotating the same page object.

An overview of PDF transformation matrices can be found in the PDF Reference Manual version 1.7 on page 204; a detailed description can be founded in section 4.2.3 on page 207.

source

pub fn translate(
    &mut self,
    delta_x: PdfPoints,
    delta_y: PdfPoints
) -> Result<(), PdfiumError>

Moves the origin of every PdfPageObject in this group by the given horizontal and vertical delta distances.

source

pub fn scale(
    &mut self,
    horizontal_scale_factor: f64,
    vertical_scale_factor: f64
) -> Result<(), PdfiumError>

Changes the size of every PdfPageObject in this group, scaling them by the given horizontal and vertical scale factors.

source

pub fn rotate_counter_clockwise_degrees(
    &mut self,
    degrees: f32
) -> Result<(), PdfiumError>

Rotates every PdfPageObject in this group counter-clockwise by the given number of degrees.

source

pub fn rotate_clockwise_degrees(
    &mut self,
    degrees: f32
) -> Result<(), PdfiumError>

Rotates every PdfPageObject in this group clockwise by the given number of degrees.

source

pub fn rotate_counter_clockwise_radians(
    &mut self,
    radians: f32
) -> Result<(), PdfiumError>

Rotates every PdfPageObject in this group counter-clockwise by the given number of radians.

source

pub fn rotate_clockwise_radians(
    &mut self,
    radians: f32
) -> Result<(), PdfiumError>

Rotates every PdfPageObject in this group clockwise by the given number of radians.

source

pub fn skew_degrees(
    &mut self,
    x_axis_skew: f32,
    y_axis_skew: f32
) -> Result<(), PdfiumError>

Skews the axes of every PdfPageObject in this group by the given angles in degrees.

source

pub fn skew_radians(
    &mut self,
    x_axis_skew: f32,
    y_axis_skew: f32
) -> Result<(), PdfiumError>

Skews the axes of every PdfPageObject in this group by the given angles in radians.

source

pub fn set_blend_mode(
    &mut self,
    blend_mode: PdfPageObjectBlendMode
) -> Result<(), PdfiumError>

Sets the blend mode that will be applied when painting every PdfPageObject in this group.

source

pub fn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>

Sets the color of any filled paths in every PdfPageObject in this group.

source

pub fn set_stroke_color(
    &mut self,
    stroke_color: PdfColor
) -> Result<(), PdfiumError>

Sets the color of any stroked lines in every PdfPageObject in this group.

Even if an object’s path is set with a visible color and a non-zero stroke width, the object’s stroke mode must be set in order for strokes to actually be visible.

source

pub fn set_stroke_width(
    &mut self,
    stroke_width: PdfPoints
) -> Result<(), PdfiumError>

Sets the width of any stroked lines in every PdfPageObject in this group.

A line width of 0 denotes the thinnest line that can be rendered at device resolution: 1 device pixel wide. However, some devices cannot reproduce 1-pixel lines, and on high-resolution devices, they are nearly invisible. Since the results of rendering such zero-width lines are device-dependent, their use is not recommended.

Even if an object’s path is set with a visible color and a non-zero stroke width, the object’s stroke mode must be set in order for strokes to actually be visible.

source

pub fn set_line_join(
    &mut self,
    line_join: PdfPageObjectLineJoin
) -> Result<(), PdfiumError>

Sets the line join style that will be used when painting stroked path segments in every PdfPageObject in this group.

source

pub fn set_line_cap(
    &mut self,
    line_cap: PdfPageObjectLineCap
) -> Result<(), PdfiumError>

Sets the line cap style that will be used when painting stroked path segments in every PdfPageObject in this group.

source

pub fn set_fill_and_stroke_mode(
    &mut self,
    fill_mode: PdfPathFillMode,
    do_stroke: bool
) -> Result<(), PdfiumError>

Sets the method used to determine which sub-paths of any path in a PdfPageObject should be filled, and whether or not any path in a PdfPageObject should be stroked, for every PdfPageObject in this group.

Even if an object’s path is set to be stroked, the stroke must be configured with a visible color and a non-zero width in order to actually be visible.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PdfPageGroupObject<'a>

§

impl<'a> !Send for PdfPageGroupObject<'a>

§

impl<'a> !Sync for PdfPageGroupObject<'a>

§

impl<'a> Unpin for PdfPageGroupObject<'a>

§

impl<'a> !UnwindSafe for PdfPageGroupObject<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.