pub struct PdfPageText<'a> { /* private fields */ }Expand description
The collection of Unicode characters visible on a single PdfPage.
Use the PdfPageText::all() function to easily return all characters in the containing PdfPage in the order in which they are defined in the PDF file.
Use the PdfPageText::search() function to initialise a new PdfPageTextSearch object, yielding the results of searching for a target string within the character collection.
In complex custom layouts, the order in which characters are defined in the document and the order in which they appear visually during rendering (and thus the order in which they are read by a user) may not necessarily match.
PdfPageText implements both the ToString and the Display traits.
Implementations§
Source§impl<'a> PdfPageText<'a>
impl<'a> PdfPageText<'a>
Sourcepub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfPageText.
Sourcepub fn len(&self) -> i32
pub fn len(&self) -> i32
Returns the total number of characters in all text segments in the containing PdfPage.
The character count includes whitespace and newlines, and so may differ slightly
from the result of calling PdfPageText::all().len().
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no characters in any text box collection in the containing PdfPage.
Sourcepub fn segments(&self) -> PdfPageTextSegments<'_>
pub fn segments(&self) -> PdfPageTextSegments<'_>
Returns a collection of all the PdfPageTextSegment text segments in the containing PdfPage.
Sourcepub fn segments_subset(
&self,
start: PdfPageTextCharIndex,
count: PdfPageTextCharIndex,
) -> PdfPageTextSegments<'_>
pub fn segments_subset( &self, start: PdfPageTextCharIndex, count: PdfPageTextCharIndex, ) -> PdfPageTextSegments<'_>
Returns a subset of the PdfPageTextSegment text segments in the containing PdfPage.
Only text segments containing characters in the given index range will be included.
Sourcepub fn chars(&self) -> PdfPageTextChars<'_>
pub fn chars(&self) -> PdfPageTextChars<'_>
Returns a collection of all the PdfPageTextChar characters in the containing PdfPage.
Sourcepub fn chars_for_object(
&self,
object: &PdfPageTextObject<'_>,
) -> Result<PdfPageTextChars<'_>, PdfiumError>
pub fn chars_for_object( &self, object: &PdfPageTextObject<'_>, ) -> Result<PdfPageTextChars<'_>, PdfiumError>
Returns a collection of all the PdfPageTextChar characters in the given PdfPageTextObject.
The return result will be empty if the given PdfPageTextObject is not attached to the containing PdfPage.
Sourcepub fn chars_for_annotation(
&self,
annotation: &PdfPageAnnotation<'_>,
) -> Result<PdfPageTextChars<'_>, PdfiumError>
pub fn chars_for_annotation( &self, annotation: &PdfPageAnnotation<'_>, ) -> Result<PdfPageTextChars<'_>, PdfiumError>
Returns a collection of all the PdfPageTextChar characters in the given PdfPageAnnotation.
The return result will be empty if the given PdfPageAnnotation is not attached to the containing PdfPage.
Sourcepub fn chars_inside_rect(
&self,
rect: PdfRect,
) -> Result<PdfPageTextChars<'_>, PdfiumError>
pub fn chars_inside_rect( &self, rect: PdfRect, ) -> Result<PdfPageTextChars<'_>, PdfiumError>
Sourcepub fn all(&self) -> String
pub fn all(&self) -> String
Returns all characters that lie within the containing PdfPage, in the order in which they are defined in the document, concatenated into a single string.
In complex custom layouts, the order in which characters are defined in the document and the order in which they appear visually during rendering (and thus the order in which they are read by a user) may not necessarily match.
Sourcepub fn inside_rect(&self, rect: PdfRect) -> String
pub fn inside_rect(&self, rect: PdfRect) -> String
Returns all characters that lie within the bounds of the given PdfRect in the containing PdfPage, in the order in which they are defined in the document, concatenated into a single string.
In complex custom layouts, the order in which characters are defined in the document and the order in which they appear visually during rendering (and thus the order in which they are read by a user) may not necessarily match.
Sourcepub fn for_object(&self, object: &PdfPageTextObject<'_>) -> String
pub fn for_object(&self, object: &PdfPageTextObject<'_>) -> String
Returns all characters assigned to the given PdfPageTextObject in this PdfPageText object, concatenated into a single string.
Sourcepub fn for_annotation(
&self,
annotation: &PdfPageAnnotation<'_>,
) -> Result<String, PdfiumError>
pub fn for_annotation( &self, annotation: &PdfPageAnnotation<'_>, ) -> Result<String, PdfiumError>
Returns all characters that lie within the bounds of the given PdfPageAnnotation in the containing PdfPage, in the order in which they are defined in the document, concatenated into a single string.
In complex custom layouts, the order in which characters are defined in the document and the order in which they appear visually during rendering (and thus the order in which they are read by a user) may not necessarily match.
Sourcepub fn search(
&self,
text: &str,
options: &PdfSearchOptions,
) -> Result<PdfPageTextSearch<'_>, PdfiumError>
pub fn search( &self, text: &str, options: &PdfSearchOptions, ) -> Result<PdfPageTextSearch<'_>, PdfiumError>
Starts a search for the given text string, returning a new PdfPageTextSearch object that can be used to step through the search results.
Sourcepub fn search_from(
&self,
text: &str,
options: &PdfSearchOptions,
index: PdfPageTextCharIndex,
) -> Result<PdfPageTextSearch<'_>, PdfiumError>
pub fn search_from( &self, text: &str, options: &PdfSearchOptions, index: PdfPageTextCharIndex, ) -> Result<PdfPageTextSearch<'_>, PdfiumError>
Starts a search for the given test string from the given character position, returning a new PdfPageTextSearch object that can be used to step through the search results.
Trait Implementations§
Source§impl<'a> Display for PdfPageText<'a>
impl<'a> Display for PdfPageText<'a>
Source§impl<'a> Drop for PdfPageText<'a>
impl<'a> Drop for PdfPageText<'a>
Source§fn drop(&mut self)
fn drop(&mut self)
Closes the PdfPageText collection, releasing held memory.
Auto Trait Implementations§
impl<'a> Freeze for PdfPageText<'a>
impl<'a> !RefUnwindSafe for PdfPageText<'a>
impl<'a> !Send for PdfPageText<'a>
impl<'a> !Sync for PdfPageText<'a>
impl<'a> Unpin for PdfPageText<'a>
impl<'a> !UnwindSafe for PdfPageText<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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