PdfPageObjectsCommon

Trait PdfPageObjectsCommon 

Source
pub trait PdfPageObjectsCommon<'a> {
Show 25 methods // Required methods fn len(&self) -> PdfPageObjectIndex; fn get( &self, index: PdfPageObjectIndex, ) -> Result<PdfPageObject<'a>, PdfiumError>; fn iter(&'a self) -> PdfPageObjectsIterator<'a> ; fn add_object( &mut self, object: PdfPageObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError>; fn create_text_object( &mut self, x: PdfPoints, y: PdfPoints, text: impl ToString, font: impl ToPdfFontToken, font_size: PdfPoints, ) -> Result<PdfPageObject<'a>, PdfiumError>; 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>; 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>; 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>; 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>; 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>; 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>; 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>; fn create_image_object( &mut self, x: PdfPoints, y: PdfPoints, image: &DynamicImage, width: Option<PdfPoints>, height: Option<PdfPoints>, ) -> Result<PdfPageObject<'a>, PdfiumError>; fn remove_object( &mut self, object: PdfPageObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError>; fn remove_object_at_index( &mut self, index: PdfPageObjectIndex, ) -> Result<PdfPageObject<'a>, PdfiumError>; // Provided methods fn is_empty(&self) -> bool { ... } fn as_range(&self) -> Range<PdfPageObjectIndex> { ... } fn as_range_inclusive(&self) -> RangeInclusive<PdfPageObjectIndex> { ... } fn first(&self) -> Result<PdfPageObject<'a>, PdfiumError> { ... } fn last(&self) -> Result<PdfPageObject<'a>, PdfiumError> { ... } fn bounds(&'a self) -> PdfRect { ... } fn add_text_object( &mut self, object: PdfPageTextObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError> { ... } fn add_path_object( &mut self, object: PdfPagePathObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError> { ... } fn add_x_object_form_object( &mut self, object: PdfPageXObjectFormObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError> { ... } fn add_image_object( &mut self, object: PdfPageImageObject<'a>, ) -> Result<PdfPageObject<'a>, PdfiumError> { ... }
}
Expand description

Functionality common to all containers of multiple PdfPageObject objects. Both pages and annotations can contain page objects.

Required Methods§

Source

fn len(&self) -> PdfPageObjectIndex

Returns the total number of page objects in the collection.

Source

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

Returns a single PdfPageObject from this page objects collection.

Source

fn iter(&'a self) -> PdfPageObjectsIterator<'a>

Returns an iterator over all the PdfPageObject objects in this page objects collection.

Source

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

Adds the given PdfPageObject to this page objects collection. The object’s memory ownership will be transferred to the PdfPage containing this page objects 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.

Source

fn create_text_object( &mut self, x: PdfPoints, y: PdfPoints, text: impl ToString, font: impl ToPdfFontToken, 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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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.

Source

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 page objects 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 content regeneration will be triggered on the page.

This function is only available when this crate’s image feature is enabled.

Source

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

Removes the given PdfPageObject from this page objects collection. The object’s memory ownership will be removed from the PdfPage containing this page objects 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.

Source

fn remove_object_at_index( &mut self, index: PdfPageObjectIndex, ) -> Result<PdfPageObject<'a>, PdfiumError>

Removes the PdfPageObject at the given index from this page objects collection. The object’s memory ownership will be removed from the PdfPage containing this page objects 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.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if this page objects collection is empty.

Source

fn as_range(&self) -> Range<PdfPageObjectIndex>

Returns a Range from 0..(number of objects) for this page objects collection.

Source

fn as_range_inclusive(&self) -> RangeInclusive<PdfPageObjectIndex>

Returns an inclusive Range from 0..=(number of objects - 1) for this page objects collection.

Source

fn first(&self) -> Result<PdfPageObject<'a>, PdfiumError>

Returns the first PdfPageObject in this page objects collection.

Source

fn last(&self) -> Result<PdfPageObject<'a>, PdfiumError>

Returns the last PdfPageObject in this page objects collection.

Source

fn bounds(&'a self) -> PdfRect

Returns the smallest bounding box that contains all the PdfPageObject objects in this page objects collection.

Source

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

Adds the given PdfPageTextObject to this page objects 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.

Source

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

Adds the given PdfPagePathObject to this page objects 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.

Source

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

Adds the given PdfPageXObjectFormObject to this page objects collection, returning the XObject form 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.

Source

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

Adds the given PdfPageImageObject to this page objects 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T> PdfPageObjectsCommon<'a> for T
where T: PdfPageObjectsPrivate<'a>,