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
sourceimpl<'a> PdfPageGroupObject<'a>
impl<'a> PdfPageGroupObject<'a>
sourcepub fn empty(page: &PdfPage<'a>) -> Self
pub fn empty(page: &PdfPage<'a>) -> Self
Creates a new, empty PdfPageGroupObject that can be used to hold any page objects on the given PdfPage.
sourcepub fn new<F>(page: &'a PdfPage<'a>, predicate: F) -> Result<Self, PdfiumError>where
F: FnMut(&PdfPageObject<'_>) -> bool,
pub fn new<F>(page: &'a PdfPage<'a>, 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.
sourcepub fn from_vec(
page: &PdfPage<'a>,
objects: Vec<PdfPageObject<'a>>
) -> Result<Self, PdfiumError>
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.
sourcepub fn from_slice(
page: &PdfPage<'a>,
objects: &mut [PdfPageObject<'a>]
) -> Result<Self, PdfiumError>
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.
sourcepub fn contains(&self, object: &PdfPageObject<'_>) -> bool
pub fn contains(&self, object: &PdfPageObject<'_>) -> bool
Returns true if this group already contains the given page object.
sourcepub fn push(&mut self, object: &mut PdfPageObject<'a>) -> Result<(), PdfiumError>
pub fn push(&mut self, object: &mut PdfPageObject<'a>) -> Result<(), PdfiumError>
Adds a single PdfPageObject to this group.
sourcepub fn append(
&mut self,
objects: &mut [PdfPageObject<'a>]
) -> Result<(), PdfiumError>
pub fn append(
&mut self,
objects: &mut [PdfPageObject<'a>]
) -> Result<(), PdfiumError>
Adds all the given PdfPageObject objects to this group.
sourcepub fn remove_objects_from_page(&mut self) -> Result<(), PdfiumError>
pub fn remove_objects_from_page(&mut self) -> Result<(), PdfiumError>
Removes every PdfPageObject in this group from the group’s containing PdfPage.
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. The group will be empty at the end of
this operation.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn get(
&self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'_>, PdfiumError>
pub fn get(
&self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'_>, PdfiumError>
Returns a single PdfPageObject from this group.
sourcepub fn iter(&self) -> PdfPageGroupObjectIterator<'_>ⓘNotable traits for PdfPageGroupObjectIterator<'a>impl<'a> Iterator for PdfPageGroupObjectIterator<'a> type Item = PdfPageObject<'a>;
pub fn iter(&self) -> PdfPageGroupObjectIterator<'_>ⓘNotable traits for PdfPageGroupObjectIterator<'a>impl<'a> Iterator for PdfPageGroupObjectIterator<'a> type Item = PdfPageObject<'a>;
Returns an iterator over all the PdfPageObject objects in this group.
sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Returns the text contained within all PdfPageTextObject objects in this group.
sourcepub fn text_separated(&self, separator: &str) -> String
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.
sourcepub fn has_transparency(&self) -> bool
pub fn has_transparency(&self) -> bool
Returns true if any PdfPageObject in this group contains transparency.
sourcepub fn bounds(&self) -> Result<PdfRect, PdfiumError>
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).
sourcepub fn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> Result<(), PdfiumError>
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.
- PdfPageGroupObject::translate(): changes the position of every PdfPageObject in this group.
- PdfPageGroupObject::scale(): changes the size of every PdfPageObject in this group.
- PdfPageGroupObject::rotate_clockwise_degrees(), PdfPageGroupObject::rotate_counter_clockwise_degrees(), PdfPageGroupObject::rotate_clockwise_radians(), PdfPageGroupObject::rotate_counter_clockwise_radians(): rotates every PdfPageObject in this group around its origin.
- PdfPageGroupObject::skew_degrees(), PdfPageGroupObject::skew_radians(): skews every PdfPageObject in this group relative to its axes.
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.
sourcepub fn translate(
&mut self,
delta_x: PdfPoints,
delta_y: PdfPoints
) -> Result<(), PdfiumError>
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.
sourcepub fn scale(
&mut self,
horizontal_scale_factor: f64,
vertical_scale_factor: f64
) -> Result<(), PdfiumError>
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.
sourcepub fn rotate_counter_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError>
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.
sourcepub fn rotate_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError>
pub fn rotate_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError>
Rotates every PdfPageObject in this group clockwise by the given number of degrees.
sourcepub fn rotate_counter_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError>
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.
sourcepub fn rotate_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError>
pub fn rotate_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError>
Rotates every PdfPageObject in this group clockwise by the given number of radians.
sourcepub fn skew_degrees(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
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.
sourcepub fn skew_radians(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
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.
sourcepub fn set_blend_mode(
&mut self,
blend_mode: PdfPageObjectBlendMode
) -> Result<(), PdfiumError>
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.
sourcepub fn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>
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.
sourcepub fn set_stroke_color(
&mut self,
stroke_color: PdfColor
) -> Result<(), PdfiumError>
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.
sourcepub fn set_stroke_width(
&mut self,
stroke_width: PdfPoints
) -> Result<(), PdfiumError>
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.
sourcepub fn set_line_join(
&mut self,
line_join: PdfPageObjectLineJoin
) -> Result<(), PdfiumError>
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.
sourcepub fn set_line_cap(
&mut self,
line_cap: PdfPageObjectLineCap
) -> Result<(), PdfiumError>
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.
sourcepub fn set_fill_and_stroke_mode(
&mut self,
fill_mode: PdfPathFillMode,
do_stroke: bool
) -> Result<(), PdfiumError>
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.