Facturx.Extract (Facturx v0.1.0)

Copy Markdown View Source

Extract the embedded CII XML from a Factur-X / ZUGFeRD PDF (pure Elixir).

Locates the embedded file referenced by the PDF's /Filespec (/AFRelationship /Data), decodes its FlateDecode stream, and reports the detected profile.

Supports classic cross-reference table PDFs (the shape emitted by the common Typst + factur-x toolchains). Object streams / cross-reference streams are not yet handled — see docs/adr/0001-perimetre-et-architecture.md.

Memory note (BEAM refc binaries)

A PDF is a large binary (> 64 bytes → refc binary). Slicing it yields sub-binaries that retain the whole PDF. Everything we return — the XML and the filename — is :binary.copy/1-ed so the multi-MB PDF can be collected.

Summary

Types

Result of a successful extraction.

Functions

Extract the embedded CII XML and metadata from pdf.

Types

result()

@type result() :: %{
  xml: binary(),
  profile: Facturx.profile() | nil,
  filename: String.t()
}

Result of a successful extraction.

Functions

extract(pdf)

@spec extract(binary()) :: {:ok, result()} | {:error, term()}

Extract the embedded CII XML and metadata from pdf.