Content Stream Semantic Comparison

HPDFContentStream can normalise decoded PDF content into bounded canonical events and compare those events without treating harmless serialisation choices as changes

Declarations

function HPDFNormalizeContentStreamGraphicsState(
  const Bytes: TBytes; out Canonical: TBytes;
  out Statistics: THPDFContentSemanticStatistics;
  NumberTolerance: Double = 1E-9;
  MaxOperations: Integer = 1000000;
  MaxCanonicalBytes: Int64 = 67108864
): boolean;

function HPDFCompareContentStreamsSemantic(
  const Left, Right: TBytes;
  out Info: THPDFContentSemanticCompareInfo;
  NumberTolerance: Double = 1E-9;
  MaxOperations: Integer = 1000000;
  MaxCanonicalBytes: Int64 = 67108864
): boolean;

Normalisation

Diagnostics and bounds

THPDFContentSemanticStatistics reports token, operation, state-operation, redundant-state, normalised-event, maximum-stack-depth, canonical-byte, error-offset, validity and limit information. Comparison also reports the first differing normalised event

Malformed nested dictionary operands, invalid state-operator arity, unmatched or unclosed graphics-state scopes, trailing operands, operation overflow and canonical-byte overflow fail closed and never report equivalence

Pass decoded content bytes. Stream filter decoding and resource-name reconciliation across different resource dictionaries remain the caller's responsibility