Struct pdfium_render::page_objects::PdfPageObjects
source · [−]pub struct PdfPageObjects<'a> { /* private fields */ }Expand description
The page objects contained within a single PdfPage.
Content on a page is structured as a stream of PdfPageObject objects of different types: text objects, image objects, path objects, and so on.
Note that Pdfium does not support or recognize all PDF page object types. For instance,
Pdfium does not currently support or recognize the External Object (“XObject”) page object type
supported by Adobe Acrobat and Foxit’s commercial PDF SDK. In these cases, Pdfium will return
PdfPageObjectType::Unsupported.
Implementations
sourceimpl<'a> PdfPageObjects<'a>
impl<'a> PdfPageObjects<'a>
sourcepub fn len(&self) -> PdfPageObjectIndex
pub fn len(&self) -> PdfPageObjectIndex
Returns the total number of page objects within the containing PdfPage.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this PdfPageObjects collection is empty.
sourcepub fn as_range(&self) -> Range<PdfPageObjectIndex>
pub fn as_range(&self) -> Range<PdfPageObjectIndex>
Returns a Range from 0..(number of objects) for this PdfPageObjects collection.
sourcepub fn as_range_inclusive(&self) -> RangeInclusive<PdfPageObjectIndex>
pub fn as_range_inclusive(&self) -> RangeInclusive<PdfPageObjectIndex>
Returns an inclusive Range from 0..=(number of objects - 1) for this PdfPageObjects collection.
sourcepub fn get(
&self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn get(
&self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'a>, PdfiumError>
Returns a single PdfPageObject from this PdfPageObjects collection.
sourcepub fn iter(&self) -> PdfPageObjectsIterator<'_>ⓘNotable traits for PdfPageObjectsIterator<'a>impl<'a> Iterator for PdfPageObjectsIterator<'a> type Item = PdfPageObject<'a>;
pub fn iter(&self) -> PdfPageObjectsIterator<'_>ⓘNotable traits for PdfPageObjectsIterator<'a>impl<'a> Iterator for PdfPageObjectsIterator<'a> type Item = PdfPageObject<'a>;
Returns an iterator over all the PdfPageObject objects in this PdfPageObjects collection.
sourcepub fn add_object(
&mut self,
object: PdfPageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn add_object(
&mut self,
object: PdfPageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
Adds the given PdfPageObject to this PdfPageObjects collection. The object’s memory ownership will be transferred to the PdfPage containing this PdfPageObjects collection, and the updated page object will be returned.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn add_text_object(
&mut self,
object: PdfPageTextObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn add_text_object(
&mut self,
object: PdfPageTextObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
Adds the given PdfPageTextObject to this PdfPageObjects collection, returning the text object wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_text_object(
&mut self,
x: PdfPoints,
y: PdfPoints,
text: impl ToString,
font: &PdfFont<'_>,
font_size: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_text_object(
&mut self,
x: PdfPoints,
y: PdfPoints,
text: impl ToString,
font: &PdfFont<'_>,
font_size: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPageTextObject at the given x and y page co-ordinates from the given arguments and adds it to this PdfPageObjects collection, returning the text object wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn add_path_object(
&mut self,
object: PdfPagePathObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn add_path_object(
&mut self,
object: PdfPagePathObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
Adds the given PdfPagePathObject to this PdfPageObjects collection, returning the path object wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_path_object_line(
&mut self,
x1: PdfPoints,
y1: PdfPoints,
x2: PdfPoints,
y2: PdfPoints,
stroke_color: PdfColor,
stroke_width: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_line(
&mut self,
x1: PdfPoints,
y1: PdfPoints,
x2: PdfPoints,
y2: PdfPoints,
stroke_color: PdfColor,
stroke_width: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject for the given line, with the given stroke settings applied. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_path_object_bezier(
&mut self,
x1: PdfPoints,
y1: PdfPoints,
x2: PdfPoints,
y2: PdfPoints,
control1_x: PdfPoints,
control1_y: PdfPoints,
control2_x: PdfPoints,
control2_y: PdfPoints,
stroke_color: PdfColor,
stroke_width: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_bezier(
&mut self,
x1: PdfPoints,
y1: PdfPoints,
x2: PdfPoints,
y2: PdfPoints,
control1_x: PdfPoints,
control1_y: PdfPoints,
control2_x: PdfPoints,
control2_y: PdfPoints,
stroke_color: PdfColor,
stroke_width: PdfPoints
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject for the given cubic Bézier curve, with the given stroke settings applied. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_path_object_rect(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_rect(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject for the given rectangle, with the given fill and stroke settings applied. Both the stroke color and the stroke width must be provided for the rectangle to be stroked. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_path_object_circle(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_circle(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject. The new path will be created with a circle that fills the given rectangle, with the given fill and stroke settings applied. Both the stroke color and the stroke width must be provided for the circle to be stroked. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_path_object_circle_at(
&mut self,
center_x: PdfPoints,
center_y: PdfPoints,
radius: PdfPoints,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_circle_at(
&mut self,
center_x: PdfPoints,
center_y: PdfPoints,
radius: PdfPoints,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject. The new path will be created with a circle centered at the given coordinates, with the given radius, and with the given fill and stroke settings applied. Both the stroke color and the stroke width must be provided for the circle to be stroked. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then the content regeneration
will be triggered on the page.
sourcepub fn create_path_object_ellipse(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_ellipse(
&mut self,
rect: PdfRect,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject. The new path will be created with an ellipse that fills the given rectangle, with the given fill and stroke settings applied. Both the stroke color and the stroke width must be provided for the ellipse to be stroked. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then the content regeneration
will be triggered on the page.
sourcepub fn create_path_object_ellipse_at(
&mut self,
center_x: PdfPoints,
center_y: PdfPoints,
x_radius: PdfPoints,
y_radius: PdfPoints,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_path_object_ellipse_at(
&mut self,
center_x: PdfPoints,
center_y: PdfPoints,
x_radius: PdfPoints,
y_radius: PdfPoints,
stroke_color: Option<PdfColor>,
stroke_width: Option<PdfPoints>,
fill_color: Option<PdfColor>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPagePathObject. The new path will be created with an ellipse centered at the given coordinates, with the given radii, and with the given fill and stroke settings applied. Both the stroke color and the stroke width must be provided for the ellipse to be stroked. The new path object will be added to this PdfPageObjects collection and then returned, wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then the content regeneration
will be triggered on the page.
sourcepub fn add_image_object(
&mut self,
object: PdfPageImageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn add_image_object(
&mut self,
object: PdfPageImageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
Adds the given PdfPageImageObject to this PdfPageObjects collection, returning the image object wrapped inside a generic PdfPageObject wrapper.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
sourcepub fn create_image_object(
&mut self,
x: PdfPoints,
y: PdfPoints,
image: DynamicImage,
width: Option<PdfPoints>,
height: Option<PdfPoints>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn create_image_object(
&mut self,
x: PdfPoints,
y: PdfPoints,
image: DynamicImage,
width: Option<PdfPoints>,
height: Option<PdfPoints>
) -> Result<PdfPageObject<'a>, PdfiumError>
Creates a new PdfPageImageObject at the given x and y page co-ordinates from the given arguments and adds it to this PdfPageObjects collection, returning the image object wrapped inside a generic PdfPageObject wrapper.
By default, new image objects have their width and height both set to 1.0 points. If provided, the given width and/or height will be applied to the newly created object to scale its size.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then the content regeneration
will be triggered on the page.
sourcepub fn create_group<F>(
&'a self,
predicate: F
) -> Result<PdfPageGroupObject<'a>, PdfiumError>where
F: Fn(&PdfPageObject<'_>) -> bool,
pub fn create_group<F>(
&'a self,
predicate: F
) -> Result<PdfPageGroupObject<'a>, PdfiumError>where
F: Fn(&PdfPageObject<'_>) -> bool,
Creates a new PdfPageGroupObject object group that includes any page objects in this PdfPageObjects collection matching the given predicate function.
sourcepub fn create_empty_group(&self) -> PdfPageGroupObject<'a>
pub fn create_empty_group(&self) -> PdfPageGroupObject<'a>
Creates a new PdfPageGroupObject object group that can accept any PdfPageObject in this PdfPageObjects collection. The newly created group will be empty; you will need to manually add to it the objects you want to manipulate.
sourcepub fn remove_object(
&mut self,
object: PdfPageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
pub fn remove_object(
&mut self,
object: PdfPageObject<'a>
) -> Result<PdfPageObject<'a>, PdfiumError>
Removes the given PdfPageObject from this PdfPageObjects collection. The object’s memory ownership will be removed from the PdfPage containing this PdfPageObjects collection, and the updated page object will be returned. It can be added back to a page objects collection or dropped, at which point the memory owned by the 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.
sourcepub fn remove_object_at_index(
&mut self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'_>, PdfiumError>
pub fn remove_object_at_index(
&mut self,
index: PdfPageObjectIndex
) -> Result<PdfPageObject<'_>, PdfiumError>
Removes the PdfPageObject at the given index from this PdfPageObjects collection. The object’s memory ownership will be removed from the PdfPage containing this PdfPageObjects collection, and the updated page object will be returned. It can be added back into a page objects collection or discarded, at which point the memory owned by the 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.
sourcepub fn take_object_from_page(
&mut self,
source: &mut PdfPage<'_>,
source_page_object_index: PdfPageObjectIndex
) -> Result<(), PdfiumError>
pub fn take_object_from_page(
&mut self,
source: &mut PdfPage<'_>,
source_page_object_index: PdfPageObjectIndex
) -> Result<(), PdfiumError>
Removes a single page object with the given source page object index from the given source PdfPage, adding the object to the end of this PdfPageObjects collection.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
Likewise, if the given source PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the source page.
sourcepub fn take_object_range_from_page(
&mut self,
source: &mut PdfPage<'_>,
source_page_object_range: RangeInclusive<PdfPageObjectIndex>
) -> Result<(), PdfiumError>
pub fn take_object_range_from_page(
&mut self,
source: &mut PdfPage<'_>,
source_page_object_range: RangeInclusive<PdfPageObjectIndex>
) -> Result<(), PdfiumError>
Removes one or more page objects with the given range of indices from the given source PdfPage, adding the objects sequentially to the end of this PdfPageObjects collection.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
Likewise, if the given source PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the source page.
sourcepub fn take_all(&mut self, source: &mut PdfPage<'_>) -> Result<(), PdfiumError>
pub fn take_all(&mut self, source: &mut PdfPage<'_>) -> Result<(), PdfiumError>
Removes all page objects in the given PdfPage into this PdfPageObjects collection, appending them to the end of this PdfPageObjects collection. The given PdfPage will be drained of all page objects once this operation is completed.
If the containing PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the page.
Likewise, if the given source PdfPage has a content regeneration strategy of
PdfPageContentRegenerationStrategy::AutomaticOnEveryChange then content regeneration
will be triggered on the source page.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PdfPageObjects<'a>
impl<'a> !Send for PdfPageObjects<'a>
impl<'a> !Sync for PdfPageObjects<'a>
impl<'a> Unpin for PdfPageObjects<'a>
impl<'a> !UnwindSafe for PdfPageObjects<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more