THotPDF.ExtractLoadedPageText Method

 

THotPDF.ExtractLoadedPageText

THotPDF

 

Top

Extracts text from a loaded page as a Unicode string without layout clustering and returns True if successful

 

Delphi syntax:

function ExtractLoadedPageText(PageIndex: Integer; out AText: UnicodeString): boolean;

 

Description

An available /ToUnicode CMap remains authoritative; missing entries fall through to /Encoding /Differences glyph names resolved through the Adobe Glyph List, code-to-CID mappings and Adobe CID collections, then binary /CIDToGIDMap data combined with the embedded TrueType or OpenType cmap

Embedded cmap recovery supports BMP and supplementary-plane mappings, and the same fallback chain is reversed when loaded text replacement must encode a Unicode scalar back into the original font

Text is returned in content-stream order. A new line starts where the text moves across its own direction by more than half the text height, so raised superscripts stay on their line and rotated text keeps its characters together. A space is added where a document separates words by moving the text position instead of showing a space character, that is, where the gap after a glyph's own width exceeds 0.15 of the text height; no space is added between two Chinese, Japanese or Korean characters

Only the text the page shows is returned: glyphs whose box lies outside the visible area given by GetLoadedPageVisibleBox, such as the printer's marks of a page trimmed by its crop box, are left out. A character painted again over itself at the same size, as in overprinted logos and bold faked by drawing the text twice with a small offset, is read once. ExtractLoadedPageGlyphs still returns every glyph with its position

Text that the page paints through Form XObjects, such as page headers, watermarks and stamps, is part of the page text. It appears where the form is painted in the content stream and is placed through the form's matrix, in the form's own fonts; forms nested in forms are followed too. The same holds for ExtractLoadedPageTextLayout, ExtractLoadedPageTextColumns and the semantic text methods

Scanned pages can gain searchable ToUnicode content through Searchable OCR Text Layers