PdfContentParser class

Converts the bytes of a content stream into a list of operators.

The design follows the same principle as MuPDF's pdf_processor: a single loop pushes operands and, on reaching a keyword, hands out the operator with the accumulated stack. The difference is that here the result is a list of data — not a set of callbacks — because the immediate goal is to reserialize and analyze, not to render.

The parser never throws on malformed content: leftover operands are discarded at the end, unknown operators are preserved as they are, and unexpected bytes become keywords. A content stream is often generated by tools with small defects, and aborting the whole read would be worse than carrying on.

Constructors

PdfContentParser(Uint8List data, {bool keepComments = false, int maxOperands = 512})
Creates a parser over data.

Properties

data → Uint8List
Content stream bytes, already decompressed.
final
hashCode → int
The hash code for this object.
no setterinherited
keepComments → bool
When true, comments become PdfContentComment in the output.
final
maxOperands → int
Limit of operands accumulated before an operator; keeps memory use bounded on corrupted streams.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse() → List<PdfContentOperator>
Tokenizes the whole stream.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

parseBytes(Uint8List data, {bool keepComments = false}) → List<PdfContentOperator>
Shortcut: tokenizes data and returns the operators.