Skip to main content

text_segments

Function text_segments 

Source
pub fn text_segments(text: &str) -> usize
Expand description

How many text segments page_text_from can actually address.

Deliberately not the same number as DocumentInfo::pages, and that is the entire point. pages comes from the PDF’s page tree; this comes from splitting the extracted text on form feeds, which is all pdf_extract gives us to locate a page boundary with. For many real documents — every PDF in the CMS section 1115 corpus, for instance — the extractor emits no form feeds at all, so a 227-page document has exactly one addressable segment.

Two numbers with the same name meaning different things is what made the old failure so confusing. Now both are computable, so an error can name them both.