Enum PdfPageObject

Source
pub enum PdfPageObject<'a> {
    Text(PdfPageTextObject<'a>),
    Path(PdfPagePathObject<'a>),
    Image(PdfPageImageObject<'a>),
    Shading(PdfPageShadingObject<'a>),
    XObjectForm(PdfPageXObjectFormObject<'a>),
    Unsupported(PdfPageUnsupportedObject<'a>),
}
Expand description

A single renderable object on a PdfPage.

Variants§

§

Text(PdfPageTextObject<'a>)

A page object containing renderable text.

§

Path(PdfPagePathObject<'a>)

A page object containing a renderable vector path.

§

Image(PdfPageImageObject<'a>)

A page object containing a renderable bitmapped image.

§

Shading(PdfPageShadingObject<'a>)

A page object containing a renderable geometric shape whose color is an arbitrary function of position within the shape.

§

XObjectForm(PdfPageXObjectFormObject<'a>)

A page object containing a content stream that itself may consist of multiple other page objects. When this page object is rendered, it renders all its constituent page objects, effectively serving as a template or stamping object.

Despite the page object name including “form”, this page object type bears no relation to an interactive form containing form fields.

§

Unsupported(PdfPageUnsupportedObject<'a>)

Any External Object (“XObject”) page object type not directly supported by Pdfium.

Common properties shared by all PdfPageObject types can still be accessed for page objects not recognized by Pdfium, but object-specific functionality will be unavailable.

Implementations§

Source§

impl<'a> PdfPageObject<'a>

Source

pub fn object_type(&self) -> PdfPageObjectType

The object type of this PdfPageObject.

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.

Source

pub fn is_supported(&self) -> bool

Returns true if this PdfPageObject has an object type other than PdfPageObjectType::Unsupported.

The PdfPageObject::as_text_object(), PdfPageObject::as_path_object(), PdfPageObject::as_image_object(), PdfPageObject::as_shading_object(), and PdfPageObject::as_x_object_form_object() functions can be used to access properties and functions pertaining to a specific page object type.

Source

pub fn is_unsupported(&self) -> bool

Returns true if this PdfPageObject has an object type of PdfPageObjectType::Unsupported.

Common properties shared by all PdfPageObject types can still be accessed for page objects not recognized by Pdfium, but object-specific functionality will be unavailable.

Source

pub fn as_text_object(&self) -> Option<&PdfPageTextObject<'_>>

Returns an immutable reference to the underlying PdfPageTextObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Text.

Source

pub fn as_text_object_mut(&mut self) -> Option<&mut PdfPageTextObject<'a>>

Returns a mutable reference to the underlying PdfPageTextObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Text.

Source

pub fn as_path_object(&self) -> Option<&PdfPagePathObject<'_>>

Returns an immutable reference to the underlying PdfPagePathObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Path.

Source

pub fn as_path_object_mut(&mut self) -> Option<&mut PdfPagePathObject<'a>>

Returns a mutable reference to the underlying PdfPagePathObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Path.

Source

pub fn as_image_object(&self) -> Option<&PdfPageImageObject<'_>>

Returns an immutable reference to the underlying PdfPageImageObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Image.

Source

pub fn as_image_object_mut(&mut self) -> Option<&mut PdfPageImageObject<'a>>

Returns a mutable reference to the underlying PdfPageImageObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Image.

Source

pub fn as_shading_object(&self) -> Option<&PdfPageShadingObject<'_>>

Returns an immutable reference to the underlying PdfPageShadingObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Shading.

Source

pub fn as_shading_object_mut(&mut self) -> Option<&mut PdfPageShadingObject<'a>>

Returns a mutable reference to the underlying PdfPageShadingObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::Shading.

Source

pub fn as_x_object_form_object(&self) -> Option<&PdfPageXObjectFormObject<'_>>

Returns an immutable reference to the underlying PdfPageXObjectFormObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::XObjectForm.

Source

pub fn as_x_object_form_object_mut( &mut self, ) -> Option<&mut PdfPageXObjectFormObject<'a>>

Returns a mutable reference to the underlying PdfPageXObjectFormObject for this PdfPageObject, if this page object has an object type of PdfPageObjectType::XObjectForm.

Source

pub fn transform( &mut self, a: PdfMatrixValue, b: PdfMatrixValue, c: PdfMatrixValue, d: PdfMatrixValue, e: PdfMatrixValue, f: PdfMatrixValue, ) -> Result<(), PdfiumError>

Applies the given transformation, expressed as six values representing the six configurable elements of a nine-element 3x3 PDF transformation matrix, to this PdfPageObject.

To move, scale, rotate, or skew this PdfPageObject, consider using one or more of the following functions. Internally they all use Self::transform(), but are probably easier to use (and certainly clearer in their intent) in most situations.

The order in which transformations are applied is significant. For example, the result of rotating then translating an object may be vastly different from translating then rotating the same 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 found in section 4.2.3 on page 207.

Source

pub fn apply_matrix(&mut self, matrix: PdfMatrix) -> Result<(), PdfiumError>

Applies the given transformation, expressed as a PdfMatrix, to this PdfPageObject.

Source

pub fn reset_matrix(&mut self, matrix: PdfMatrix) -> Result<(), PdfiumError>

Resets the transform matrix for this PdfPageObject to the the given PdfMatrix, overriding any previously applied transformations.

Source

pub fn reset_matrix_to_identity(&mut self) -> Result<(), PdfiumError>

Resets the transformation matrix for this PdfPageObject to the identity matrix, undoing any previously applied transformations.

Source

pub fn translate( &mut self, delta_x: PdfPoints, delta_y: PdfPoints, ) -> Result<(), PdfiumError>

Moves the origin of this PdfPageObject by the given horizontal and vertical delta distances.

Source

pub fn scale( &mut self, horizontal_scale_factor: PdfMatrixValue, vertical_scale_factor: PdfMatrixValue, ) -> Result<(), PdfiumError>

Changes the size of this PdfPageObject, scaling it by the given horizontal and vertical scale factors.

Source

pub fn flip_horizontally(&mut self) -> Result<(), PdfiumError>

Flips this PdfPageObject horizontally around its origin by applying a horizontal scale factor of -1.

Source

pub fn flip_vertically(&mut self) -> Result<(), PdfiumError>

Flips this PdfPageObject vertically around its origin by applying a vertical scale factor of -1.

Source

pub fn reflect(&mut self) -> Result<(), PdfiumError>

Reflects this PdfPageObject by flipping it both horizontally and vertically around its origin.

Source

pub fn rotate_counter_clockwise_degrees( &mut self, degrees: PdfMatrixValue, ) -> Result<(), PdfiumError>

Rotates this PdfPageObject counter-clockwise by the given number of degrees.

Source

pub fn rotate_clockwise_degrees( &mut self, degrees: PdfMatrixValue, ) -> Result<(), PdfiumError>

Rotates this PdfPageObject clockwise by the given number of degrees.

Source

pub fn rotate_counter_clockwise_radians( &mut self, radians: PdfMatrixValue, ) -> Result<(), PdfiumError>

Rotates this PdfPageObject counter-clockwise by the given number of radians.

Source

pub fn rotate_clockwise_radians( &mut self, radians: PdfMatrixValue, ) -> Result<(), PdfiumError>

Rotates this PdfPageObject clockwise by the given number of radians.

Source

pub fn skew_degrees( &mut self, x_axis_skew: PdfMatrixValue, y_axis_skew: PdfMatrixValue, ) -> Result<(), PdfiumError>

Skews the axes of this PdfPageObject by the given angles in degrees.

Source

pub fn skew_radians( &mut self, x_axis_skew: PdfMatrixValue, y_axis_skew: PdfMatrixValue, ) -> Result<(), PdfiumError>

Skews the axes of this PdfPageObject by the given angles in radians.

Source

pub fn matrix(&self) -> Result<PdfMatrix, PdfiumError>

Returns the transformation matrix currently applied to this PdfPageObject.

Source

pub fn get_translation(&self) -> (PdfPoints, PdfPoints)

Returns the current horizontal and vertical translation of the origin of this PdfPageObject.

Source

pub fn get_horizontal_translation(&self) -> PdfPoints

Returns the current horizontal translation of the origin of this PdfPageObject.

Source

pub fn get_vertical_translation(&self) -> PdfPoints

Returns the current vertical translation of the origin of this PdfPageObject.

Source

pub fn get_scale(&self) -> (PdfMatrixValue, PdfMatrixValue)

Returns the current horizontal and vertical scale factors applied to this PdfPageObject.

Source

pub fn get_horizontal_scale(&self) -> PdfMatrixValue

Returns the current horizontal scale factor applied to this PdfPageObject.

Source

pub fn get_vertical_scale(&self) -> PdfMatrixValue

Returns the current vertical scale factor applied to this PdfPageObject.

Source

pub fn get_rotation_counter_clockwise_degrees(&self) -> PdfMatrixValue

Returns the counter-clockwise rotation applied to this PdfPageObject, in degrees.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_rotation_clockwise_degrees(&self) -> PdfMatrixValue

Returns the clockwise rotation applied to this PdfPageObject, in degrees.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_rotation_counter_clockwise_radians(&self) -> PdfMatrixValue

Returns the counter-clockwise rotation applied to this PdfPageObject, in radians.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_rotation_clockwise_radians(&self) -> PdfMatrixValue

Returns the clockwise rotation applied to this PdfPageObject, in radians.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_skew_degrees(&self) -> (PdfMatrixValue, PdfMatrixValue)

Returns the current x axis and y axis skew angles applied to this PdfPageObject, in degrees.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_x_axis_skew_degrees(&self) -> PdfMatrixValue

Returns the current x axis skew angle applied to this PdfPageObject, in degrees.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_y_axis_skew_degrees(&self) -> PdfMatrixValue

Returns the current y axis skew applied to this PdfPageObject, in degrees.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_skew_radians(&self) -> (PdfMatrixValue, PdfMatrixValue)

Returns the current x axis and y axis skew angles applied to this PdfPageObject, in radians.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_x_axis_skew_radians(&self) -> PdfMatrixValue

Returns the current x axis skew applied to this PdfPageObject, in radians.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Source

pub fn get_y_axis_skew_radians(&self) -> PdfMatrixValue

Returns the current y axis skew applied to this PdfPageObject, in radians.

If the object is both rotated and skewed, the return value of this function will reflect the combined operation.

Trait Implementations§

Source§

impl<'a> Drop for PdfPageObject<'a>

Source§

fn drop(&mut self)

Closes this PdfPageObject, releasing held memory.

Source§

impl<'a> From<PdfPageImageObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPageImageObject<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<PdfPagePathObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPagePathObject<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<PdfPageShadingObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPageShadingObject<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<PdfPageTextObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPageTextObject<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<PdfPageUnsupportedObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPageUnsupportedObject<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<PdfPageXObjectFormObject<'a>> for PdfPageObject<'a>

Source§

fn from(object: PdfPageXObjectFormObject<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for PdfPageObject<'a>

§

impl<'a> !RefUnwindSafe for PdfPageObject<'a>

§

impl<'a> !Send for PdfPageObject<'a>

§

impl<'a> !Sync for PdfPageObject<'a>

§

impl<'a> Unpin for PdfPageObject<'a>

§

impl<'a> !UnwindSafe for PdfPageObject<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn has_transparency(&self) -> bool

Returns true if this PdfPageObject contains transparency.
Source§

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

Returns the bounding box of this PdfPageObject as a quadrilateral. Read more
Source§

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

Transforms this PdfPageObject by applying the transformation matrix read from the given PdfPageObject. Read more
Source§

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

Sets the blend mode that will be applied when painting this PdfPageObject. Read more
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 paths in this PdfPageObject.
Source§

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

Sets the color of any stroked paths in this PdfPageObject. Read more
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. Read more
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 dash_phase(&self) -> Result<PdfPoints, PdfiumError>

Returns the line dash phase that will be used when painting stroked path segments in this PdfPageObject. Read more
Source§

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. Read more
Source§

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. Read more
Source§

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. Read more
Source§

fn is_copyable(&self) -> bool

👎Deprecated since 0.8.32: This function has been retired in favour of the PdfPageObject::copy_to_page() function.
Returns true if this PdfPageObject can be successfully copied by calling its try_copy() function. Read more
Source§

fn 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.
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. Read more
Source§

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.
Source§

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. Read more
Source§

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. Read more
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.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.