View Source Pdf.Reader.Parser (ExPDF v1.0.1)

PDF recursive-descent parser.

Converts a PDF binary into the tagged-tuple internal value representation defined in the design:

  • integers → integer()
  • reals → float()
  • booleans → true | false

  • null → :null
  • names → {:name, binary()}
  • literal strings → {:string, binary()}
  • hex strings → {:hex_string, binary()}
  • arrays → Elixir list()
  • dictionaries → %{binary() => value()} (keys without leading /)
  • indirect refs → {:ref, n, g}
  • streams → {:stream, dict_map, raw_bytes}

References are NEVER resolved here — they come out as {:ref, n, g} tuples for lazy resolution by Pdf.Reader.ObjectResolver.

Summary

Functions

Parses a full indirect object N G obj <value> endobj from binary.

Parses a single PDF value from binary. Returns {value, rest}.

Functions

@spec parse_object(binary()) ::
  {:ok, {pos_integer(), non_neg_integer()}, term(), binary()} | {:error, term()}

Parses a full indirect object N G obj <value> endobj from binary.

Returns {:ok, {n, g}, value, rest} on success, or {:error, reason} on failure.

For stream objects the value is {:stream, dict_map, raw_bytes} where raw_bytes is the UNFILTERED payload.

@spec parse_value(binary()) :: {term(), binary()}

Parses a single PDF value from binary. Returns {value, rest}.

The rest binary is the unconsumed input after the value ends.