Struct pdfium_render::page_object_text::PdfPageTextObject
source · [−]pub struct PdfPageTextObject<'a> { /* private fields */ }Expand description
A single PdfPageObject of type PdfPageObjectType::Text.
Page objects can be created either attached to a PdfPage (in which case the page object’s
memory is owned by the containing page) or detached from any page (in which case the page
object’s memory is owned by the object). Page objects are not rendered until they are
attached to a page; page objects that are never attached to a page will be lost when they
fall out of scope.
The simplest way to create a page text object that is immediately attached to a page
is to call the PdfPageObjects::create_text_object() function.
Creating a detached page text object offers more scope for customization, but you must
add the object to a containing PdfPage manually. To create a detached page text object,
use the PdfPageTextObject::new() function. The detached page text object can later
be attached to a page by using the PdfPageObjects::add_object() function.
Implementations
sourceimpl<'a> PdfPageTextObject<'a>
impl<'a> PdfPageTextObject<'a>
sourcepub fn new(
document: &PdfDocument<'a>,
text: impl ToString,
font: &PdfFont<'_>,
font_size: PdfPoints
) -> Result<Self, PdfiumError>
pub fn new(
document: &PdfDocument<'a>,
text: impl ToString,
font: &PdfFont<'_>,
font_size: PdfPoints
) -> Result<Self, PdfiumError>
Creates a new PdfPageTextObject from the given arguments. The returned page object
will not be rendered until it is added to a PdfPage using the
PdfPageObjects::add_text_object() function.
A single space will be used if the given text is empty, in order to avoid unexpected behaviour from Pdfium when dealing with empty strings.
sourcepub fn render_mode(&self) -> PdfPageTextRenderMode
pub fn render_mode(&self) -> PdfPageTextRenderMode
Returns the text rendering mode for the text contained within this PdfPageTextObject.
sourcepub fn scaled_font_size(&self) -> PdfPoints
pub fn scaled_font_size(&self) -> PdfPoints
Returns the effective size of the text when rendered, taking into account both the font size specified in this text object as well as any vertical scale factor applied to the text object’s transformation matrix.
To retrieve only the specified font size, ignoring any vertical scaling, use the PdfPageTextObject::unscaled_font_size() function.
sourcepub fn unscaled_font_size(&self) -> PdfPoints
pub fn unscaled_font_size(&self) -> PdfPoints
Returns the font size of the text specified in this PdfPageTextObject.
Note that the effective size of the text when rendered may differ from the font size if a scaling factor has been applied to this text object’s transformation matrix. To retrieve the effective font size, taking vertical scaling into account, use the PdfPageTextObject::scaled_font_size() function.
sourcepub fn font(&self) -> PdfFont<'_>
pub fn font(&self) -> PdfFont<'_>
Returns the PdfFont used to render the text contained within this PdfPageTextObject.
sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Returns the text contained within this PdfPageTextObject.
Text retrieval in Pdfium is handled by the PdfPageText object owned by the PdfPage
containing this PdfPageTextObject. If this text object has not been attached to a page
then text retrieval will be unavailable and an empty string will be returned.
When retrieving the text from many PdfPageTextObject objects (for instance, as part of a loop or an iterator), it may be faster to open the PdfPageText object once and keep it open while processing the text objects, like so:
let text_page = page.text()?; // Opens the text page once.
for object in <some object iterator> {
let object_text = text_page.for_object(object)?;
}The PdfPageText object will be closed when the binding to it (text_page in the example above)
falls out of scope.
sourcepub fn set_text(&mut self, text: impl ToString) -> Result<(), PdfiumError>
pub fn set_text(&mut self, text: impl ToString) -> Result<(), PdfiumError>
Sets the text contained within this PdfPageTextObject, replacing any existing text.
A single space will be used if the given text is empty, in order to avoid unexpected behaviour from Pdfium when dealing with an empty string.
sourcepub fn set_render_mode(
&mut self,
render_mode: PdfPageTextRenderMode
) -> Result<(), PdfiumError>
pub fn set_render_mode(
&mut self,
render_mode: PdfPageTextRenderMode
) -> Result<(), PdfiumError>
Sets the text rendering mode for the text contained within this PdfPageTextObject.
sourcepub fn chars(
&self,
text: &'a PdfPageText<'a>
) -> Result<PdfPageTextChars<'a>, PdfiumError>
pub fn chars(
&self,
text: &'a PdfPageText<'a>
) -> Result<PdfPageTextChars<'a>, PdfiumError>
Returns a collection of the characters contained within this PdfPageTextObject, using character retrieval functionality provided by the given PdfPageText object.
sourcepub fn has_descenders(
&self,
text: &PdfPageText<'_>
) -> Result<bool, PdfiumError>
pub fn has_descenders(
&self,
text: &PdfPageText<'_>
) -> Result<bool, PdfiumError>
Returns true if any of the characters contained within this PdfPageTextObject have a
glyph shape that descends below the font baseline.
Character retrieval functionality is provided by the given PdfPageText object.
sourcepub fn descent(&self, text: &PdfPageText<'_>) -> Result<PdfPoints, PdfiumError>
pub fn descent(&self, text: &PdfPageText<'_>) -> Result<PdfPoints, PdfiumError>
Returns the descent of this PdfPageTextObject. The descent is the maximum distance below the baseline reached by any glyph in any of the characters contained in this text object, expressed as a negative points value.
Character retrieval and bounds measurement is provided by the given PdfPageText object.
Trait Implementations
sourceimpl<'a> From<PdfPageTextObject<'a>> for PdfPageObject<'a>
impl<'a> From<PdfPageTextObject<'a>> for PdfPageObject<'a>
sourcefn from(object: PdfPageTextObject<'a>) -> Self
fn from(object: PdfPageTextObject<'a>) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PdfPageTextObject<'a>
impl<'a> !Send for PdfPageTextObject<'a>
impl<'a> !Sync for PdfPageTextObject<'a>
impl<'a> Unpin for PdfPageTextObject<'a>
impl<'a> !UnwindSafe for PdfPageTextObject<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> PdfPageObjectCommon<'a> for T where
T: PdfPageObjectPrivate<'a>,
impl<'a, T> PdfPageObjectCommon<'a> for T where
T: PdfPageObjectPrivate<'a>,
sourcefn has_transparency(&self) -> bool
fn has_transparency(&self) -> bool
Returns true if this PdfPageObject contains transparency.
sourcefn bounds(&self) -> Result<PdfRect, PdfiumError>
fn bounds(&self) -> Result<PdfRect, PdfiumError>
Returns the bounding box of this PdfPageObject. Read more
sourcefn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> Result<(), PdfiumError>
fn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> 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. Read more
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. Read more
sourcefn get_horizontal_translation(&self) -> PdfPoints
fn get_horizontal_translation(&self) -> PdfPoints
Returns the current horizontal translation of the origin of this PdfPageObject.
sourcefn get_vertical_translation(&self) -> PdfPoints
fn get_vertical_translation(&self) -> PdfPoints
Returns the current vertical translation of the origin of this PdfPageObject.
sourcefn get_horizontal_scale(&self) -> f64
fn get_horizontal_scale(&self) -> f64
Returns the current horizontal scale factor applied to this PdfPageObject.
sourcefn get_vertical_scale(&self) -> f64
fn get_vertical_scale(&self) -> f64
Returns the current vertical scale factor applied to this PdfPageObject.
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
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. Read more
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 lines 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 lines in this PdfPageObject. Read more
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. Read more
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. Read more
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. Read more
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. Read more
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. Read more
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. Read more
sourcefn translate(
&mut self,
delta_x: PdfPoints,
delta_y: PdfPoints
) -> Result<(), PdfiumError>
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.
sourcefn get_translation(&self) -> (PdfPoints, PdfPoints)
fn get_translation(&self) -> (PdfPoints, PdfPoints)
Returns the current horizontal and vertical translation of the origin of this PdfPageObject.
sourcefn scale(
&mut self,
horizontal_scale_factor: f64,
vertical_scale_factor: f64
) -> Result<(), PdfiumError>
fn scale(
&mut self,
horizontal_scale_factor: f64,
vertical_scale_factor: f64
) -> Result<(), PdfiumError>
Changes the size of this PdfPageObject, scaling it by the given horizontal and vertical scale factors. Read more
sourcefn 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.
sourcefn 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.
sourcefn reflect(&mut self) -> Result<(), PdfiumError>
fn reflect(&mut self) -> Result<(), PdfiumError>
Reflects this PdfPageObject by flipping it both horizontally and vertically around its origin.
sourcefn get_scale(&self) -> (f64, f64)
fn get_scale(&self) -> (f64, f64)
Returns the current horizontal and vertical scale factors applied to this PdfPageObject.
sourcefn 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.
sourcefn 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. Read more
sourcefn 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.
sourcefn get_rotation_clockwise_degrees(&self) -> f32
fn get_rotation_clockwise_degrees(&self) -> f32
Returns the clockwise rotation applied to this PdfPageObject, in degrees. Read more
sourcefn 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.
sourcefn 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.
sourcefn get_rotation_clockwise_radians(&self) -> f32
fn get_rotation_clockwise_radians(&self) -> f32
Returns the clockwise rotation applied to this PdfPageObject, in radians. Read more
sourcefn 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.
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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.
sourcefn 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. Read more