Trait pdfium_render::page_object::PdfPageObjectCommon
source · [−]pub trait PdfPageObjectCommon<'a> {
Show 46 methods
fn has_transparency(&self) -> bool;
fn bounds(&self) -> Result<PdfRect, PdfiumError>;
fn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> Result<(), PdfiumError>;
fn transform_from(
&mut self,
other: &PdfPageObject<'_>
) -> Result<(), PdfiumError>;
fn get_horizontal_translation(&self) -> PdfPoints;
fn get_vertical_translation(&self) -> PdfPoints;
fn get_horizontal_scale(&self) -> f64;
fn get_vertical_scale(&self) -> f64;
fn get_rotation_counter_clockwise_radians(&self) -> f32;
fn get_x_axis_skew_radians(&self) -> f32;
fn get_y_axis_skew_radians(&self) -> f32;
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 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 { ... }
fn translate(
&mut self,
delta_x: PdfPoints,
delta_y: PdfPoints
) -> Result<(), PdfiumError> { ... }
fn get_translation(&self) -> (PdfPoints, PdfPoints) { ... }
fn scale(
&mut self,
horizontal_scale_factor: f64,
vertical_scale_factor: f64
) -> Result<(), PdfiumError> { ... }
fn flip_horizontally(&mut self) -> Result<(), PdfiumError> { ... }
fn flip_vertically(&mut self) -> Result<(), PdfiumError> { ... }
fn reflect(&mut self) -> Result<(), PdfiumError> { ... }
fn get_scale(&self) -> (f64, f64) { ... }
fn rotate_counter_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError> { ... }
fn get_rotation_counter_clockwise_degrees(&self) -> f32 { ... }
fn rotate_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError> { ... }
fn get_rotation_clockwise_degrees(&self) -> f32 { ... }
fn rotate_counter_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError> { ... }
fn rotate_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError> { ... }
fn get_rotation_clockwise_radians(&self) -> f32 { ... }
fn skew_degrees(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError> { ... }
fn get_skew_degrees(&self) -> (f32, f32) { ... }
fn get_x_axis_skew_degrees(&self) -> f32 { ... }
fn get_y_axis_skew_degrees(&self) -> f32 { ... }
fn skew_radians(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError> { ... }
fn get_skew_radians(&self) -> (f32, f32) { ... }
}Expand description
Functionality common to all PdfPageObject objects, regardless of their PdfPageObjectType.
Required Methods
fn has_transparency(&self) -> bool
fn has_transparency(&self) -> bool
Returns true if this PdfPageObject contains transparency.
fn bounds(&self) -> Result<PdfRect, PdfiumError>
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.
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 a PdfPageObject, consider using one or more of the following functions. Internally they all use PdfPageObjectCommon::transform(), but are probably easier to use (and certainly clearer in their intent) in most situations.
- PdfPageObjectCommon::translate(): changes the position of a PdfPageObject.
- PdfPageObjectCommon::scale(): changes the size of a PdfPageObject.
- PdfPageObjectCommon::rotate_clockwise_degrees(), PdfPageObjectCommon::rotate_counter_clockwise_degrees(), PdfPageObjectCommon::rotate_clockwise_radians(), PdfPageObjectCommon::rotate_counter_clockwise_radians(): rotates a PdfPageObject around its origin.
- PdfPageObjectCommon::skew_degrees(), PdfPageObjectCommon::skew_radians(): skews a PdfPageObject relative to its axes.
The order in which transformations are applied to a page object is significant. For example, the result of rotating then translating a page object may be vastly different from translating then rotating the same page object. In general, to obtain the expected results, transformations should be done in the following order:
- Translate
- Rotate
- Scale and/or skew
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 founded in section 4.2.3 on page 207.
fn 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.
fn get_horizontal_translation(&self) -> PdfPoints
fn get_horizontal_translation(&self) -> PdfPoints
Returns the current horizontal translation of the origin of this PdfPageObject.
fn get_vertical_translation(&self) -> PdfPoints
fn get_vertical_translation(&self) -> PdfPoints
Returns the current vertical translation of the origin of this PdfPageObject.
fn get_horizontal_scale(&self) -> f64
fn get_horizontal_scale(&self) -> f64
Returns the current horizontal scale factor applied to this PdfPageObject.
fn get_vertical_scale(&self) -> f64
fn get_vertical_scale(&self) -> f64
Returns the current vertical scale factor applied to this PdfPageObject.
fn get_rotation_counter_clockwise_radians(&self) -> f32
fn get_rotation_counter_clockwise_radians(&self) -> f32
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.
fn get_x_axis_skew_radians(&self) -> f32
fn get_x_axis_skew_radians(&self) -> f32
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.
fn get_y_axis_skew_radians(&self) -> f32
fn get_y_axis_skew_radians(&self) -> f32
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.
fn 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.
fn fill_color(&self) -> Result<PdfColor, PdfiumError>
fn fill_color(&self) -> Result<PdfColor, PdfiumError>
Returns the color of any filled paths in this PdfPageObject.
fn 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.
fn stroke_color(&self) -> Result<PdfColor, PdfiumError>
fn stroke_color(&self) -> Result<PdfColor, PdfiumError>
Returns the color of any stroked lines in this PdfPageObject.
fn 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 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.
fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
Returns the width of any stroked lines in this PdfPageObject.
fn 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.
fn 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.
fn 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.
fn 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.
fn 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.
Provided Methods
fn width(&self) -> Result<PdfPoints, PdfiumError>
fn width(&self) -> Result<PdfPoints, PdfiumError>
Returns the width of this PdfPageObject.
fn height(&self) -> Result<PdfPoints, PdfiumError>
fn height(&self) -> Result<PdfPoints, PdfiumError>
Returns the height of this PdfPageObject.
fn 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.
fn 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.
Moves the origin of this PdfPageObject by the given horizontal and vertical delta distances.
fn get_translation(&self) -> (PdfPoints, PdfPoints)
fn get_translation(&self) -> (PdfPoints, PdfPoints)
Returns the current horizontal and vertical translation of the origin of this PdfPageObject.
Changes the size of this PdfPageObject, scaling it by the given horizontal and vertical scale factors.
fn flip_horizontally(&mut self) -> Result<(), PdfiumError>
fn flip_horizontally(&mut self) -> Result<(), PdfiumError>
Flips this PdfPageObject horizontally around its origin by applying a horizontal scale factor of -1.
fn flip_vertically(&mut self) -> Result<(), PdfiumError>
fn flip_vertically(&mut self) -> Result<(), PdfiumError>
Flips this PdfPageObject vertically around its origin by applying a vertical scale factor of -1.
fn reflect(&mut self) -> Result<(), PdfiumError>
fn reflect(&mut self) -> Result<(), PdfiumError>
Reflects this PdfPageObject by flipping it both horizontally and vertically around its origin.
Returns the current horizontal and vertical scale factors applied to this PdfPageObject.
fn rotate_counter_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError>
fn rotate_counter_clockwise_degrees(
&mut self,
degrees: f32
) -> Result<(), PdfiumError>
Rotates this PdfPageObject counter-clockwise by the given number of degrees.
fn get_rotation_counter_clockwise_degrees(&self) -> f32
fn get_rotation_counter_clockwise_degrees(&self) -> f32
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.
fn rotate_clockwise_degrees(&mut self, degrees: f32) -> Result<(), PdfiumError>
fn rotate_clockwise_degrees(&mut self, degrees: f32) -> Result<(), PdfiumError>
Rotates this PdfPageObject clockwise by the given number of degrees.
fn get_rotation_clockwise_degrees(&self) -> f32
fn get_rotation_clockwise_degrees(&self) -> f32
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.
fn rotate_counter_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError>
fn rotate_counter_clockwise_radians(
&mut self,
radians: f32
) -> Result<(), PdfiumError>
Rotates this PdfPageObject counter-clockwise by the given number of radians.
fn rotate_clockwise_radians(&mut self, radians: f32) -> Result<(), PdfiumError>
fn rotate_clockwise_radians(&mut self, radians: f32) -> Result<(), PdfiumError>
Rotates this PdfPageObject clockwise by the given number of radians.
fn get_rotation_clockwise_radians(&self) -> f32
fn get_rotation_clockwise_radians(&self) -> f32
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.
fn skew_degrees(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
fn skew_degrees(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
Skews the axes of this PdfPageObject by the given angles in degrees.
fn get_skew_degrees(&self) -> (f32, f32)
fn get_skew_degrees(&self) -> (f32, f32)
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.
fn get_x_axis_skew_degrees(&self) -> f32
fn get_x_axis_skew_degrees(&self) -> f32
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.
fn get_y_axis_skew_degrees(&self) -> f32
fn get_y_axis_skew_degrees(&self) -> f32
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.
fn skew_radians(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
fn skew_radians(
&mut self,
x_axis_skew: f32,
y_axis_skew: f32
) -> Result<(), PdfiumError>
Skews the axes of this PdfPageObject by the given angles in radians.
fn get_skew_radians(&self) -> (f32, f32)
fn get_skew_radians(&self) -> (f32, f32)
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.