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.
Reads both cross-reference forms: the classic table, and the PDF 1.5+ stream
with its objects compressed into object streams. The index is built by scanning
for N G obj and then expanding every object stream — never from the
cross-reference table, which an incremental update leaves pointing at the
objects the update replaced.
Unlike Facturx.Embed, this module does not require its input to be PDF/A, and
does not check: reading an attachment cannot damage the document, so refusing a
file it can in fact read would only be in the caller's way. The library will
therefore read from PDFs it would decline to write to.
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
Functions
Extract the embedded CII XML and metadata from pdf.
Types
@type result() :: %{ xml: binary(), profile: Facturx.profile() | nil, filename: String.t() }
Result of a successful extraction.