Struct pdfium_render::paragraph::PdfParagraph
source · [−]pub struct PdfParagraph<'a> { /* private fields */ }Expand description
A group of PdfPageTextObject objects contained in the same PdfPageObjects collection
that should be laid out together as a single paragraph.
Text layout in PDF files is handled entirely by text objects. Each text object contains a single span of text that is styled consistently and can be at most a single line long. Paragraphs containing multiple lines, with different internal text styles, are formed from multiple text objects stitched together visually at the time the page is generated. There is no native functionality for retrieving a single paragraph from its constituent text objects. This makes it difficult to work with long spans of text.
The PdfParagraph is an attempt to improve multi-line text handling. Paragraphs can be created from existing groups of page objects, or created by scratch; once created, text in a paragraph can be edited and re-formatted, and then used to generate a group of text objects that can be placed on a page.
Implementations
sourceimpl<'a> PdfParagraph<'a>
impl<'a> PdfParagraph<'a>
sourcepub fn from_objects(objects: &'a [PdfPageObject<'a>]) -> Vec<Self>
pub fn from_objects(objects: &'a [PdfPageObject<'a>]) -> Vec<Self>
Creates a set of one or more PdfParagraph objects from the given list of page objects.
sourcepub fn empty(
maximum_width: PdfPoints,
overflow: PdfParagraphOverflowBehaviour,
alignment: PdfParagraphAlignment
) -> Self
pub fn empty(
maximum_width: PdfPoints,
overflow: PdfParagraphOverflowBehaviour,
alignment: PdfParagraphAlignment
) -> Self
Creates a new, empty [PdfPageParagraphObject] with the given maximum line width, overflow, and alignment settings.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this PdfParagraph contains no fragments.
sourcepub fn push(&mut self, string: PdfStyledString<'a>)
pub fn push(&mut self, string: PdfStyledString<'a>)
Adds a new fragment containing the given styled string to this paragraph.
sourcepub fn maximum_width(&self) -> PdfPoints
pub fn maximum_width(&self) -> PdfPoints
Returns the maximum line width of this paragraph.
sourcepub fn set_maximum_width(&mut self, width: PdfPoints)
pub fn set_maximum_width(&mut self, width: PdfPoints)
Sets the maximum line width of this paragraph to the given value.
sourcepub fn set_maximum_height(&mut self, height: PdfPoints)
pub fn set_maximum_height(&mut self, height: PdfPoints)
Sets the maximum height of this paragraph to the given value.
sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Returns the text contained within all text fragments in this paragraph.
sourcepub fn text_separated(&self, separator: &str) -> String
pub fn text_separated(&self, separator: &str) -> String
Returns the text contained within all text fragments in this paragraph, separating each text fragment with the given separator.
sourcepub fn as_group(&self) -> PdfPageGroupObject<'_>
pub fn as_group(&self) -> PdfPageGroupObject<'_>
Assembles the fragments in this paragraph into lines, taking into account the paragraph’s current sizing, overflow, indent, and alignment settings, and generates new page objects for each line, adding all generated page objects to a new PdfPageGroupObject.
pub fn d(&self)
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PdfParagraph<'a>
impl<'a> !Send for PdfParagraph<'a>
impl<'a> !Sync for PdfParagraph<'a>
impl<'a> Unpin for PdfParagraph<'a>
impl<'a> !UnwindSafe for PdfParagraph<'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