pub struct TextExtractor { /* private fields */ }Expand description
Text extractor for PDF pages with CMap support
Implementations§
Source§impl TextExtractor
impl TextExtractor
Sourcepub fn with_options(options: ExtractionOptions) -> Self
pub fn with_options(options: ExtractionOptions) -> Self
Create a text extractor with custom options
Sourcepub fn with_reading_order(self, enable: bool) -> Self
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.
Sourcepub fn with_carriage_return_handling(
self,
handling: CarriageReturnHandling,
) -> Self
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.
Sourcepub fn merge_fragments_for_partition(
&self,
fragments: &[TextFragment],
) -> Vec<TextFragment>
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.
Sourcepub fn extract_from_document<R: Read + Seek>(
&mut self,
document: &PdfDocument<R>,
) -> ParseResult<Vec<ExtractedText>>
pub fn extract_from_document<R: Read + Seek>( &mut self, document: &PdfDocument<R>, ) -> ParseResult<Vec<ExtractedText>>
Extract text from a PDF document
Sourcepub fn extract_from_page<R: Read + Seek>(
&mut self,
document: &PdfDocument<R>,
page_index: u32,
) -> ParseResult<ExtractedText>
pub fn extract_from_page<R: Read + Seek>( &mut self, document: &PdfDocument<R>, page_index: u32, ) -> ParseResult<ExtractedText>
Extract text from a specific page