NAME

PDF::FacturX::Embed - Embed Factur-X XML into a PDF/A-3 envelope

SYNOPSIS

use PDF::FacturX::Embed qw(embed_xml_pdfa3);

my ($ok, $msg) = embed_xml_pdfa3(
    pdf_in   => 'invoice.pdf',
    xml      => $factur_x_xml,
    pdf_out  => 'invoice-fx.pdf',
    profile  => 'en16931',
    title    => 'Invoice FA-2026-0042',
    author   => 'Acme SARL',
);
die $msg unless $ok;

DESCRIPTION

Wraps an existing PDF into a PDF/A-3 envelope with the Factur-X XML attached as an associated file (AFRelationship = /Data) and the required XMP metadata stream. Drives Ghostscript (>= 10.x) for the heavy lifting, then PDF::Builder for the final XMP write that Ghostscript cannot perform correctly per PDF/A-3 §6.6.2.1.

REQUIREMENTS

  • Ghostscript 10.x or later, as the gs binary in PATH (override with the gs option).

  • An sRGB ICC profile (auto-detected from common Ghostscript install paths; bundled fallback at share/icc/sRGB.icc).

FUNCTIONS

embed_xml_pdfa3(%opts)

Returns (1, $message) on success or (0, $error) on failure. Required: pdf_in, xml, pdf_out. Optional: profile, title, author, creator, tmp_dir, gs, icc_path, on_warning.

find_icc_profile()

Returns a path to an sRGB ICC profile or undef.

LICENSE

Same terms as Perl itself (Artistic License 2.0).