Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › EN 16931

Factur-X / ZUGFeRD from HTML: Embed EN 16931 XML in PDF/A-3 and Validate with veraPDF and Mustang

By Freedom251 Team · · 6 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make a Factur-X or ZUGFeRD invoice from HTML, render the visible invoice, create a conforming PDF/A-3 file, then embed and associate the matching invoice XML with the right filename, metadata, relationship, and profile. Validate the PDF/A container and the XML/business rules separately, then check that both representations describe the same transaction. An XML attachment alone does not make a valid hybrid invoice.

What you are building

A Factur-X or ZUGFeRD invoice is a hybrid document: a human-readable PDF accompanies machine-readable invoice XML. PDF/A-3 can contain associated files, but its conformance checks address the PDF container, not whether the invoice XML is correct or whether the two versions agree.

As an Amazon Associate I earn from qualifying purchases.

That means “pass” is not one result. You need evidence for the PDF/A-3 container, the XML structure and applicable invoice rules, and the correspondence between the visible and structured invoice. veraPDF and Mustang help with different parts of that job; neither replaces the last check in your own application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What is the safe order of operations?

  1. Render the final HTML invoice. Use your HTML-to-PDF renderer, such as Chromium driven by Playwright in the implementation path reported by a PDFik-authored tutorial dated September 8, 2026. Make sure all page content, overlays, and fonts are present before archival normalization. Later stamping or other edits can introduce fonts after the PDF/A check.
  2. Create or normalize the PDF/A-3 container. Ensure the document has the applicable PDF/A metadata, output intent and color profile, embedded fonts, and other required characteristics. The cited tutorial uses PDF/A-3b as its example, but the required conformance level depends on your project and the applicable specification. Its example uses pikepdf at this stage; that is one reported toolchain, not a compliance requirement.
  3. Embed the invoice XML as an associated file. Add it at document level and align its filename and association with the selected format, edition, and profile. A technical overview identifies factur-x.xml for Factur-X, but confirm the required name for the precise release you implement. The file should be represented as an associated file, not merely appear as a generic attachment.
  4. Write the format-specific XMP metadata. The implementation tutorial names the properties DocumentType, DocumentFileName, Version, and ConformanceLevel. Factur-X custom XMP also needs its namespace described through the PDF/A extension mechanism. Verify property spelling, values, and serialization against the specification package for your selected edition.
  5. Set the associated-file relationship deliberately. Do not assume a library default is right for every profile or release. The tutorial reports using Alternative for its EN 16931 case and notes that defaults vary. A historical PDFlib overview describes a special Source condition for ZUGFeRD 2.1. These are version- and context-dependent details, not interchangeable universal settings.
  6. Run independent validation gates. Validate the container with veraPDF, and validate the XML for well-formedness, schema, and applicable EN 16931 or national business rules. The tutorial uses Mustang for invoice checks and warns that its overall status may not fail solely because the PDF/A result failed. Inspect detailed reports and require an independent PDF/A pass rather than relying on one summary or exit code.
  7. Compare the two invoice representations. In your application, compare the rendered PDF and XML for parties, dates, line items, quantities, totals, tax, currency, and payment details. Validators can establish structural or rule compliance; they cannot prove that independently generated representations describe the same transaction.

Which details must agree?

  • Filename: Use the name required by the exact Factur-X/ZUGFeRD edition and profile, and make the XMP filename declaration match it.
  • Association: Include the document-level associated-file declaration as well as the attachment entry. A listed attachment by itself does not establish the required association.
  • Metadata: Supply the custom Factur-X XMP properties and declare the custom schema using the PDF/A extension mechanism. Profile labels in serialized metadata may differ from internal API keys; the tutorial specifically cautions that labels such as BASIC WL and EN 16931 can include spaces.
  • Version and profile: Keep the XML syntax, profile, metadata values, filename, and association consistent with one exact format release. Do not infer serialized values by copying an internal enum or an older example.
  • Relationship: Choose the relationship value required for that version and transaction context instead of copying a setting from a different profile.

The implementation article reports that the Factur-X release it read was version 1.07.2 / ZUGFeRD 2.3.2, dated November 15, 2024, and that it had not read the newer release it referenced. Its implementation observations are useful examples, but not a substitute for the current official release artifacts. PDFlib’s technical overview is also useful background, though some details it gives are historical, including ZUGFeRD 2.1.

What do veraPDF and Mustang actually check?

veraPDF: the PDF/A container

Use veraPDF to test whether the PDF meets the selected PDF/A conformance requirements. A PDF/A result does not certify that the invoice XML is schema-valid, complies with business rules, or matches what a reader sees on the page.

Mustang: invoice XML and related checks

Use Mustang to check the invoice data and inspect its detailed report. The cited tutorial describes a version-specific behavior in which an overall validity value derives from XML validity while the PDF/A result is reported separately. Check the behavior of the version you deploy; do not treat a successful summary as proof that the PDF/A gate passed.

Rank #2
Sale
Adobe Acrobat 6 PDF For Dummies
  • Used Book in Good Condition

Your application: correspondence and business truth

Even valid XML can contain the wrong invoice, and a valid PDF/A can display different values. Compare both outputs against the same transaction data in your system. As the vendor-authored tutorial puts it, “Schema-valid is not tax-compliant; the content stays the sender’s responsibility either way.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which implementation route fits?

The sources document several approaches, but do not establish one as universally best. Choose based on whether the tool creates PDF/A-3 or only preserves an existing file, supports the profile and release you need, produces useful diagnostics, fits your language and deployment environment, and suits your licensing constraints.

Route What the cited source establishes What to verify for your deployment
Mustangproject tooling The Mustangserver manual, version 1.7.0, describes combining CII XML with an input PDF/A document to produce a Factur-X/ZUGFeRD PDF/A-3. Current supported versions and profiles, CLI or API integration, report semantics, and runtime requirements.
FPDF extension Its documentation describes an XML-embedding method and supported profile labels. It explicitly says, “No validation is performed on the XML file.” Separate PDF/A and XML/business-rule validation, and meet the PDF/A font requirements noted by the extension documentation.
PDFlib Its documentation covers PDF/A-3 creation, XML embedding and association, and Factur-X examples. Current profile/version support, licensing, and operational requirements.
Python-oriented pipeline The PDFik-authored tutorial reports a sequence using Playwright, pikepdf, the Python factur-x library, veraPDF, and Mustang. Library defaults, relationship behavior, current compatibility, and the limits of the tutorial’s version-specific observations.

The tutorial’s author discloses being the founder of PDFik, a hosted HTML-to-PDF service. Treat its workflow and validator observations as vendor-authored implementation guidance rather than a neutral certification of the tools.

Quick Recap

SaleBestseller No. 2
Adobe Acrobat 6 PDF For Dummies
Adobe Acrobat 6 PDF For Dummies
Used Book in Good Condition
$13.00

Why does a PDF/A or XML check fail?

  • PDF/A fails after a later edit: Re-run validation after stamping or any post-processing. A later operation can introduce fonts or other content not present during the earlier check.
  • The PDF passes but the hybrid invoice is incomplete: Check that the XML is attached at document level, associated correctly, and identified by matching filename and XMP metadata.
  • Metadata or profile validation fails: Check the exact edition’s required values and serialization. Confirm the custom XMP extension-schema declaration and do not assume a human-readable label and internal library key are identical.
  • Mustang reports success but veraPDF fails: Treat the results as separate gates. Read Mustang’s detailed report and require the PDF/A validator to pass independently.
  • XML parses but invoice validation fails: Parsing establishes only that the file can be read. Check schema and applicable business rules, then compare the XML data with the rendered invoice.

Production checklist

  • Choose the exact current Factur-X/ZUGFeRD release, profile, and required PDF/A conformance level.
  • Render the complete invoice before PDF/A normalization, and avoid unvalidated post-processing.
  • Align XML filename, associated-file declaration, relationship, XMP values, and profile.
  • Run a PDF/A validation gate and separate XML schema/business-rule checks; retain detailed reports.
  • Compare parties, dates, lines, totals, tax, currency, and payment data across the PDF and XML.
  • Recheck the normative values against the exact official format package used by your implementation rather than relying on historical examples.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

EN 16931Factur-XHTML to PDFMustangPDF/A-3veraPDFZUGFeRD

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.