pub trait PdfPageObjectCommon<'a> {
Show 27 methods
// Required methods
fn has_transparency(&self) -> bool;
fn bounds(&self) -> Result<PdfQuadPoints, 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 dash_phase(&self) -> Result<PdfPoints, PdfiumError>;
fn set_dash_phase(
&mut self,
dash_phase: PdfPoints,
) -> Result<(), PdfiumError>;
fn dash_array(&self) -> Result<Vec<PdfPoints>, PdfiumError>;
fn set_dash_array(
&mut self,
array: &[PdfPoints],
phase: PdfPoints,
) -> Result<(), PdfiumError>;
fn is_copyable(&self) -> bool;
fn try_copy<'b>(
&self,
document: &'b PdfDocument<'b>,
) -> Result<PdfPageObject<'b>, PdfiumError>;
fn copy_to_page<'b>(
&mut self,
page: &mut PdfPage<'b>,
) -> Result<PdfPageObject<'b>, PdfiumError>;
fn move_to_page(
&mut self,
page: &mut PdfPage<'_>,
) -> Result<(), PdfiumError>;
fn move_to_annotation(
&mut self,
annotation: &mut PdfPageAnnotation<'_>,
) -> Result<(), 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§
Sourcefn has_transparency(&self) -> bool
fn has_transparency(&self) -> bool
Returns true if this PdfPageObject contains transparency.
Sourcefn bounds(&self) -> Result<PdfQuadPoints, PdfiumError>
fn bounds(&self) -> Result<PdfQuadPoints, PdfiumError>
Returns the bounding box of this PdfPageObject as a quadrilateral.
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.
Sourcefn transform_from(
&mut self,
other: &PdfPageObject<'_>,
) -> Result<(), PdfiumError>
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.
Sourcefn set_blend_mode(
&mut self,
blend_mode: PdfPageObjectBlendMode,
) -> Result<(), PdfiumError>
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.
Sourcefn fill_color(&self) -> Result<PdfColor, PdfiumError>
fn fill_color(&self) -> Result<PdfColor, PdfiumError>
Returns the color of any filled paths in this PdfPageObject.
Sourcefn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>
fn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>
Sets the color of any filled paths in this PdfPageObject.
Sourcefn stroke_color(&self) -> Result<PdfColor, PdfiumError>
fn stroke_color(&self) -> Result<PdfColor, PdfiumError>
Returns the color of any stroked paths in this PdfPageObject.
Sourcefn set_stroke_color(
&mut self,
stroke_color: PdfColor,
) -> Result<(), PdfiumError>
fn set_stroke_color( &mut self, stroke_color: PdfColor, ) -> Result<(), PdfiumError>
Sets the color of any stroked paths 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.
Sourcefn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
Returns the width of any stroked lines in this PdfPageObject.
Sourcefn set_stroke_width(
&mut self,
stroke_width: PdfPoints,
) -> Result<(), PdfiumError>
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.
Sourcefn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>
fn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>
Returns the line join style that will be used when painting stroked path segments in this PdfPageObject.
Sourcefn set_line_join(
&mut self,
line_join: PdfPageObjectLineJoin,
) -> Result<(), PdfiumError>
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.
Sourcefn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>
fn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>
Returns the line cap style that will be used when painting stroked path segments in this PdfPageObject.
Sourcefn set_line_cap(
&mut self,
line_cap: PdfPageObjectLineCap,
) -> Result<(), PdfiumError>
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.
Sourcefn dash_phase(&self) -> Result<PdfPoints, PdfiumError>
fn dash_phase(&self) -> Result<PdfPoints, PdfiumError>
Returns the line dash phase that will be used when painting stroked path segments in this PdfPageObject.
A page object’s line dash pattern controls the pattern of dashes and gaps used to stroke paths, as specified by a dash array and a dash phase. The dash array’s elements are PdfPoints values that specify the lengths of alternating dashes and gaps; all values must be non-zero and non-negative. The dash phase specifies the distance into the dash pattern at which to start the dash.
For more information on stroked dash patterns, refer to the PDF Reference Manual, version 1.7, pages 217 - 218.
Note that dash pattern save support in Pdfium was not fully stabilized until release
chromium/5772 (May 2023). Versions of Pdfium older than this can load and render
dash patterns, but will not save dash patterns to PDF files.
Sourcefn set_dash_phase(&mut self, dash_phase: PdfPoints) -> Result<(), PdfiumError>
fn set_dash_phase(&mut self, dash_phase: PdfPoints) -> Result<(), PdfiumError>
Sets the line dash phase that will be used when painting stroked path segments in this PdfPageObject.
A page object’s line dash pattern controls the pattern of dashes and gaps used to stroke paths, as specified by a dash array and a dash phase. The dash array’s elements are PdfPoints values that specify the lengths of alternating dashes and gaps; all values must be non-zero and non-negative. The dash phase specifies the distance into the dash pattern at which to start the dash.
For more information on stroked dash patterns, refer to the PDF Reference Manual, version 1.7, pages 217 - 218.
Note that dash pattern save support in Pdfium was not fully stabilized until release
chromium/5772 (May 2023). Versions of Pdfium older than this can load and render
dash patterns, but will not save dash patterns to PDF files.
Sourcefn dash_array(&self) -> Result<Vec<PdfPoints>, PdfiumError>
fn dash_array(&self) -> Result<Vec<PdfPoints>, PdfiumError>
Returns the line dash array that will be used when painting stroked path segments in this PdfPageObject.
A page object’s line dash pattern controls the pattern of dashes and gaps used to stroke paths, as specified by a dash array and a dash phase. The dash array’s elements are PdfPoints values that specify the lengths of alternating dashes and gaps; all values must be non-zero and non-negative. The dash phase specifies the distance into the dash pattern at which to start the dash.
For more information on stroked dash patterns, refer to the PDF Reference Manual, version 1.7, pages 217 - 218.
Note that dash pattern save support in Pdfium was not fully stabilized until release
chromium/5772 (May 2023). Versions of Pdfium older than this can load and render
dash patterns, but will not save dash patterns to PDF files.
Sourcefn set_dash_array(
&mut self,
array: &[PdfPoints],
phase: PdfPoints,
) -> Result<(), PdfiumError>
fn set_dash_array( &mut self, array: &[PdfPoints], phase: PdfPoints, ) -> Result<(), PdfiumError>
Sets the line dash array that will be used when painting stroked path segments in this PdfPageObject.
A page object’s line dash pattern controls the pattern of dashes and gaps used to stroke paths, as specified by a dash array and a dash phase. The dash array’s elements are PdfPoints values that specify the lengths of alternating dashes and gaps; all values must be non-zero and non-negative. The dash phase specifies the distance into the dash pattern at which to start the dash.
For more information on stroked dash patterns, refer to the PDF Reference Manual, version 1.7, pages 217 - 218.
Note that dash pattern save support in Pdfium was not fully stabilized until release
chromium/5772 (May 2023). Versions of Pdfium older than this can load and render
dash patterns, but will not save dash patterns to PDF files.
Sourcefn is_copyable(&self) -> bool
👎Deprecated since 0.8.32: This function has been retired in favour of the PdfPageObject::copy_to_page() function.
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.
Sourcefn try_copy<'b>(
&self,
document: &'b PdfDocument<'b>,
) -> Result<PdfPageObject<'b>, PdfiumError>
👎Deprecated since 0.8.32: This function has been retired in favour of the PdfPageObject::copy_to_page() function.
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.
Sourcefn copy_to_page<'b>(
&mut self,
page: &mut PdfPage<'b>,
) -> Result<PdfPageObject<'b>, PdfiumError>
fn copy_to_page<'b>( &mut self, page: &mut PdfPage<'b>, ) -> Result<PdfPageObject<'b>, PdfiumError>
Copies this PdfPageObject object into a new PdfPageXObjectFormObject, then adds the new form object to the page objects collection of the given PdfPage, returning the new form object.
Sourcefn move_to_page(&mut self, page: &mut PdfPage<'_>) -> Result<(), PdfiumError>
fn move_to_page(&mut self, page: &mut PdfPage<'_>) -> Result<(), PdfiumError>
Moves the ownership of this PdfPageObject to the given PdfPage, regenerating page content as necessary.
An error will be returned if the destination page is in a different PdfDocument than this object. Pdfium only supports safely moving objects within the same document, not across documents.
Sourcefn move_to_annotation(
&mut self,
annotation: &mut PdfPageAnnotation<'_>,
) -> Result<(), PdfiumError>
fn move_to_annotation( &mut self, annotation: &mut PdfPageAnnotation<'_>, ) -> Result<(), PdfiumError>
Moves the ownership of this PdfPageObject to the given PdfPageAnnotation, regenerating page content as necessary.
An error will be returned if the destination annotation is in a different PdfDocument than this object. Pdfium only supports safely moving objects within the same document, not across documents.
Provided Methods§
Sourcefn width(&self) -> Result<PdfPoints, PdfiumError>
fn width(&self) -> Result<PdfPoints, PdfiumError>
Returns the width of this PdfPageObject.
Sourcefn height(&self) -> Result<PdfPoints, PdfiumError>
fn height(&self) -> Result<PdfPoints, PdfiumError>
Returns the height of this PdfPageObject.
Sourcefn is_inside_rect(&self, rect: &PdfRect) -> bool
fn is_inside_rect(&self, rect: &PdfRect) -> bool
Returns true if the bounds of this PdfPageObject lie entirely within the given rectangle.
Sourcefn does_overlap_rect(&self, rect: &PdfRect) -> bool
fn does_overlap_rect(&self, rect: &PdfRect) -> bool
Returns true if the bounds of this PdfPageObject lie at least partially within
the given rectangle.