Skip to main content

TextExtractor

Struct TextExtractor 

Source
pub struct TextExtractor { /* private fields */ }
Expand description

Text extractor for PDF pages with CMap support

Implementations§

Source§

impl TextExtractor

Source

pub fn new() -> Self

Create a new text extractor with default options

Source

pub fn with_options(options: ExtractionOptions) -> Self

Create a text extractor with custom options

Source

pub fn with_reading_order(self, enable: bool) -> Self

Enable (or disable) flat-path reading-order reordering (issue #448).

Off by default. When on, the flat .text path permutes its line groups into reading order (left column before right, top block before bottom) using the scale-relative XY-cut primitive; the text inside each group is untouched, and the result is byte-identical whenever the stream order is already the reading order. Only affects the flat path (ExtractionOptions::preserve_layout = false, no reorder_columns).

Consuming builder, so it chains after the constructors: TextExtractor::with_options(opts).with_reading_order(true).

Known ceiling (issue #448 design §5.1): only reorders groups the newline heuristic already separated — two columns drawn row-interleaved fall into one group. /Rotate ≠ 0 pages are ordered in unrotated page space.

Source

pub fn with_carriage_return_handling( self, handling: CarriageReturnHandling, ) -> Self

Select how standalone carriage returns decoded from PDF text strings are represented. CRLF is always normalized to one line feed.

The default is CarriageReturnHandling::Remove.

Source

pub fn merge_fragments_for_partition( &self, fragments: &[TextFragment], ) -> Vec<TextFragment>

Run the full fragment-merge chain used by the partition pipeline: kerning fix → line reconstruction → paragraph reconstruction.

Honors ExtractionOptions::reconstruct_paragraphs: when false, only merge_close_fragments (the kerning fix) runs and the input is returned at fragment granularity.

This method is pub so the integration test in tests/paragraph_reconstruction_test.rs can exercise it without going through a PDF file. Production callers should prefer PdfDocument::partition() and friends, which use this internally.

Source

pub fn extract_from_document<R: Read + Seek>( &mut self, document: &PdfDocument<R>, ) -> ParseResult<Vec<ExtractedText>>

Extract text from a PDF document

Source

pub fn extract_from_page<R: Read + Seek>( &mut self, document: &PdfDocument<R>, page_index: u32, ) -> ParseResult<ExtractedText>

Extract text from a specific page

Trait Implementations§

Source§

impl Default for TextExtractor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more