The content processor that extracts positioned text: every glyph a run shows, with its Unicode text, its box and origin in page space, its font, size and rendering mode. Runs alone through ExtractText(), or beside other processors in one run through CompositeContentProcessor.
public sealed class TextExtractor : ContentProcessor
ISO 32000-2 §9.4.4 (glyph positions), §9.10 (Unicode), §9.3.6 (rendering modes), §8.11.3.1 (optional content) and §14.9.4
(replacement text). Glyphs shown by form XObjects are extracted where the form paints them. A Type 3 glyph is one glyph, mapped
to Unicode like any other; its glyph description is not run, so text inside it is part of its appearance, not of the page's text.
Glyphs in Artifact marked-content sequences (§14.8.2.2) are left out unless IncludeArtifacts
asks for them.
The extractor gives page content order. ExtractText(TextExtractionOptions) puts a tagged page in logical content order from the structure tree (§14.8.2.5.1, TextReadingOrder); the extractor records, for that, the content item each glyph is shown in. Words, Lines and PlainText group the glyphs in content order (§14.8.2.6.2; see TextWord and TextLine), assembled when first read after a run.
Glyphs accumulate over runs until Clear(); the buffers are kept, so an extractor reused for page after page allocates nothing per glyph once its buffers have grown. Not thread-safe: use one extractor per thread.
kind:method, kind:property, kind:ctor. Press Esc to clear.TextExtractor()Creates an extractor with the default options.TextExtractor(TextExtractionOptions)Creates an extractor.GlyphsGets the glyphs extracted since the last Clear(), in content order. Valid until the extractor next runs or is cleared.LinesGets the lines of the extracted glyphs, assembled when first read after a run. Valid until the extractor next runs or is cleared.PlainTextGets the plain text of the extracted glyphs in content order, as PlainText. Valid until the extractor next runs or is cleared.TextGets the text of the extracted glyphs, in content order. Valid until the extractor next runs or is cleared.WordsGets the words of the extracted glyphs, assembled when first read after a run. Valid until the extractor next runs or is cleared.BeginForm(in FormEvent, ContentContext)Called when a form XObject's content is about to run (Forms).BeginMarkedContent(in MarkedContentEvent, ContentContext)Called at BMC and BDC (MarkedContent).BeginRun(ContentContext)Called when a run starts, before the first operator.Clear()Forgets the extracted glyphs and text, keeping the buffers.EndForm(in FormEvent, ContentContext)Called when a form XObject's content has run, for a form whose BeginForm(in FormEvent, ContentContext) returned Enter.EndMarkedContent(in MarkedContentEvent, ContentContext)Called at EMC, and implicitly for sequences still open at the end of a stream (MarkedContent).GetGlyphText(in TextGlyph)Gets the text of one extracted glyph. Valid until the extractor next runs or is cleared.GetLineText(in TextLine)Gets the text of one line: its words separated by single spaces. Valid until the extractor next runs or is cleared.GetWordText(in TextWord)Gets the text of one word: the texts of its glyphs. Valid until the extractor next runs or is cleared.ShowGlyph(in GlyphEvent, ContentContext)Called for every glyph shown (Glyphs).ToTextPage()Copies what was extracted into a TextPage.