pub trait PdfPageObjectCommon<'a> {
Show 20 methods // Required methods fn has_transparency(&self) -> bool; fn bounds(&self) -> Result<PdfRect, PdfiumError>; fn transform_from( &mut self, other: &PdfPageObject<'_> ) -> Result<(), PdfiumError>; fn set_blend_mode( &mut self, blend_mode: PdfPageObjectBlendMode ) -> Result<(), PdfiumError>; fn fill_color(&self) -> Result<PdfColor, PdfiumError>; fn set_fill_color( &mut self, fill_color: PdfColor ) -> Result<(), PdfiumError>; fn stroke_color(&self) -> Result<PdfColor, PdfiumError>; fn set_stroke_color( &mut self, stroke_color: PdfColor ) -> Result<(), PdfiumError>; fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>; fn set_stroke_width( &mut self, stroke_width: PdfPoints ) -> Result<(), PdfiumError>; fn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>; fn set_line_join( &mut self, line_join: PdfPageObjectLineJoin ) -> Result<(), PdfiumError>; fn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>; fn set_line_cap( &mut self, line_cap: PdfPageObjectLineCap ) -> Result<(), PdfiumError>; fn is_copyable(&self) -> bool; fn try_copy<'b>( &self, document: &'b PdfDocument<'b> ) -> Result<PdfPageObject<'b>, PdfiumError>; // Provided methods fn width(&self) -> Result<PdfPoints, PdfiumError> { ... } fn height(&self) -> Result<PdfPoints, PdfiumError> { ... } fn is_inside_rect(&self, rect: &PdfRect) -> bool { ... } fn does_overlap_rect(&self, rect: &PdfRect) -> bool { ... }
}
Expand description

Functionality common to all PdfPageObject objects, regardless of their PdfPageObjectType.

Required Methods§

source

fn has_transparency(&self) -> bool

Returns true if this PdfPageObject contains transparency.

source

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

Returns the bounding box of this PdfPageObject.

For text objects, the bottom of the bounding box is set to the font baseline. Any characters in the text object that have glyph shapes that descends below the font baseline will extend beneath the bottom of this bounding box. To measure the distance of the maximum descent of any glyphs, use the PdfPageTextObject::descent() function.

source

fn transform_from( &mut self, other: &PdfPageObject<'_> ) -> Result<(), PdfiumError>

Transforms this PdfPageObject by applying the transformation matrix read from the given PdfPageObject.

Any translation, rotation, scaling, or skewing transformations currently applied to the given PdfPageObject will be immediately applied to this PdfPageObject.

source

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

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

Note that Pdfium does not currently expose a function to read the currently set blend mode.

source

fn fill_color(&self) -> Result<PdfColor, PdfiumError>

Returns the color of any filled paths in this PdfPageObject.

source

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

Sets the color of any filled paths in this PdfPageObject.

source

fn stroke_color(&self) -> Result<PdfColor, PdfiumError>

Returns the color of any stroked lines in this PdfPageObject.

source

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

Sets the color of any stroked lines in this PdfPageObject.

Even if this 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

fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>

Returns the width of any stroked lines in this PdfPageObject.

source

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

Sets the width of any stroked lines in this PdfPageObject.

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 this 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

fn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>

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

source

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 this PdfPageObject.

source

fn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>

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

source

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 this PdfPageObject.

source

fn is_copyable(&self) -> bool

Returns true if this PdfPageObject can be successfully copied by calling its try_copy() function.

Not all page objects can be successfully copied. The following restrictions apply:

  • For path objects, it is not possible to copy a path object that contains a Bézier path segment, because Pdfium does not currently provide any way to retrieve the control points of a Bézier curve of an existing path object.
  • For text objects, the font used by the object must be present in the destination document, or text rendering behaviour will be unpredictable. While text objects refer to fonts, font data is embedded into documents separately from text objects.
  • For image objects, Pdfium allows iterating over the list of image filters applied to an image object, but currently provides no way to set a new object’s image filters. As a result, it is not possible to copy an image object that has any image filters applied.

Pdfium currently allows setting the blend mode for a page object, but provides no way to retrieve an object’s current blend mode. As a result, the blend mode setting of the original object will not be transferred to the copy.

source

fn try_copy<'b>( &self, document: &'b PdfDocument<'b> ) -> Result<PdfPageObject<'b>, PdfiumError>

Attempts to copy this PdfPageObject by creating a new page object and copying across all the properties of this PdfPageObject to the new page object.

Not all page objects can be successfully copied. The following restrictions apply:

  • For path objects, it is not possible to copy a path object that contains a Bézier path segment, because Pdfium does not currently provide any way to retrieve the control points of a Bézier curve of an existing path object.
  • For text objects, the font used by the object must be present in the destination document, or text rendering behaviour will be unpredictable. While text objects refer to fonts, font data is embedded into documents separately from text objects.
  • For image objects, Pdfium allows iterating over the list of image filters applied to an image object, but currently provides no way to set a new object’s image filters. As a result, it is not possible to copy an image object that has any image filters applied.

Pdfium currently allows setting the blend mode for a page object, but provides no way to retrieve an object’s current blend mode. As a result, the blend mode setting of the original object will not be transferred to the copy.

The returned page object will be detached from any existing PdfPage. Its lifetime will be bound to the lifetime of the given destination PdfDocument.

Provided Methods§

source

fn width(&self) -> Result<PdfPoints, PdfiumError>

Returns the width of this PdfPageObject.

source

fn height(&self) -> Result<PdfPoints, PdfiumError>

Returns the height of this PdfPageObject.

source

fn is_inside_rect(&self, rect: &PdfRect) -> bool

Returns true if the bounds of this PdfPageObject lie entirely within the given rectangle.

source

fn does_overlap_rect(&self, rect: &PdfRect) -> bool

Returns true if the bounds of this PdfPageObject lie at least partially within the given rectangle.

Implementors§

source§

impl<'a, T> PdfPageObjectCommon<'a> for Twhere T: PdfPageObjectPrivate<'a>,