pdf_graphics library
Content-stream parsing and interpretation for PDF pages: the interpreter walks page content and emits drawing callbacks into a PdfDevice implementation (Flutter Canvas, text extraction, test recorders).
Classes
- ContentOperation
- One content-stream instruction: operands followed by an operator.
- ContentStreamParser
- Parses a page content stream into a flat list of operations.
- IccProfile
- An ICC profile reduced to what rendering needs: a transform from device components to sRGB.
- PdfAnnotationContext
- One annotation summarized for an agent.
- PdfCalibratedColorSpace
- CIE-based calibrated color spaces used by PDF graphics operators.
- PdfClosePath
- PdfColor
- An RGB color with components in 0..1, the renderer's common currency. Device color spaces convert into it; ICC-based spaces approximate for now.
- PdfCubicTo
- PdfDevice
- Rendering target. The interpreter walks a content stream and emits these callbacks; implementations include the Flutter Canvas device, a text-extraction device, and test recorders.
- PdfDocumentActionSink
- The write half of the Document-AI seam: the editing actions an agent can drive, decoupled from any particular model or transport.
- PdfDocumentContext
- A clean, serializable snapshot of a document's text and interactive structure, shaped for handing to a language model.
- PdfExtractedRun
- One positioned run of text on a page, in page space.
- PdfFieldContext
- One interactive form field, flattened for an agent.
- PdfFontInfo
- Metrics, text decoding, and (for embedded TrueType fonts) real glyph outlines for one font dictionary. Fonts without usable embedded outlines fall back to device-side substitution scaled to these widths.
- PdfFunction
- A PDF function (§7.10), one input except where shadings need more.
- PdfGlyphPlacement
- One glyph within a PdfTextRun: its outline (when the font is embedded and parsed) and its pen offset, both in em units.
- PdfGradient
- A gradient ready for a device: stops pre-sampled from the shading's function, with geometry in the space mapped by transform.
- PdfImageRequest
- An image draw request. Decoding is left to the device, which may have platform codecs (and may need to be async — devices can pre-collect).
- PdfInterpreter
- Executes page content streams against a PdfDevice.
- PdfLineTo
- PdfMatrix
-
A 2D affine transform in PDF convention: row vectors, so a point maps as
x' = a·x + c·y + e,y' = b·x + d·y + f(ISO 32000-1 §8.3.3). - PdfMesh
- A triangle mesh with per-vertex colors — the decoded form of mesh shadings (types 4–7). Patch meshes arrive pre-subdivided; devices only ever see Gouraud triangles.
- PdfMeshParser
- Decodes the bit-packed vertex/patch data of mesh shadings.
- PdfMeshVertex
- One mesh vertex in page space.
- PdfMoveTo
- PdfPageContext
- One page's textual content and geometry, for PdfDocumentContext.
- PdfPageText
- The text content of one page, with geometry for search highlighting.
- PdfPath
- PdfPathSegment
- Path geometry emitted by the interpreter. Coordinates are already transformed into page space (PDF default user space, y-up), because PDF applies the CTM at path-construction time.
- PdfReflowBlock
- One paragraph-like block in reading order.
- PdfReflowDocument
- Document-level convenience wrapper for reflowed text.
- PdfReflowLine
- A line of text inferred from positioned page text.
- PdfReflowPage
- A page's text reduced to paragraph blocks in inferred reading order.
- PdfShading
- A parsed shading dictionary (§8.7.4.5).
- PdfStroke
- Stroke parameters, with width already scaled into page space.
- PdfTextDiff
- A word-level diff of two pages' extracted text, computed as a longest common subsequence over their token streams (a standard sequence diff), with each changed token mapped back to its page-space bounds for highlight overlays.
- PdfTextDiffHunk
- A contiguous change — one or more adjacent non-PdfTextDiffKind.equal segments, the unit a diff navigator steps through. A pure replace is a delete next to an insert, so a hunk carries both before and after tokens.
- PdfTextDiffSegment
- One run of the alignment between two pages' token streams.
- PdfTextExtractor
- Extracts positioned text by running the interpreter with a collecting device — the same code path rendering uses, so what you search is what you see.
- PdfTextMatch
- One search hit, with page-space geometry for highlighting.
- PdfTextQuad
- Four page-space corners of a text span's highlight box, in perimeter order: lower-left, lower-right, upper-right, upper-left of the run's own baseline frame.
- PdfTextReflower
- Paragraph and reading-order inference over PdfPageText.
- PdfTextRun
- One run of text from a single show-text operator.
- PdfTextToken
- A whitespace-delimited token of page text, with the page-space box it covers — the unit a PdfTextDiff aligns and the bounds a viewer highlights when it flags the token as changed.
Enums
- PdfBlendMode
- PDF blend modes (§11.3.5). Devices map these to their compositor.
- PdfFillRule
- PdfTextDiffKind
- What a PdfTextDiffSegment represents.
Functions
-
colorFromComponents(
List< double> values, [int? count]) → PdfColor - Interprets raw color components by count: 1 = gray, 3 = RGB, 4 = CMYK. Used for sc/scn operands and shading function outputs.
-
tokenizePageText(
PdfPageText page) → List< PdfTextToken> - Splits a page's extracted text into word tokens (maximal runs of non-whitespace) with their page-space bounds.