Skip to main content
Version: 10.0

ZUGFeRD

webPDF supports the embedding of XML data according to the ZUGFeRD 1.0 and ZUGFeRD 2.x specification or the ZUGFeRD 2.x compatible Factur-X for PDF/A conversion.

After a successful check for validity of the XML (invoice) data, it is embedded in the PDF and output as a ZUGFeRD-compliant PDF/A-3.

Data embedding​

You can use the parameters to specify the XML data for the ZUGFeRD file when calling the pdfa web service.

{
"pdfa": {
"convert": {
"autoTagging": false,
"errorCorrection": {
"enabled": false
},
"errorReport": "none",
"imageQuality": 75,
"level": "3b",
"successReport": "none",
"zugferd": {
"xmlFile": {
"value": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCg0KPHBy...<BASE64>",
"version": "v10Comfort"
}
}
}
}
}

If the zugferd element is defined in the pdfa object, the web service will embed the xmlFile file (Base64-encoded in zugferd.xmlFile.value) during the PDF/A conversion. Before being embedded, the XML data is validated against webPDF's XML schema (XSD) for the ZUGFeRD version and profile selected with the zugferd.xmlFile.version attribute, and is only embedded if it is valid against that schema. This schema validation checks the structure of the invoice XML only — it does not check the business rules of EN 16931 or XRechnung (for example calculation rules, the mandatory fields of a profile, or code lists). To check those as well, use the optional invoice rule validation.

Security: DOCTYPE declarations are rejected by default​

Since webPDF 10.0.7, an embedded ZUGFeRD/Factur-X XML file that contains a DOCTYPE declaration is rejected with error code PDFA_ZUGFERD_INVALID_XML_FILE = -411. Previously, such a file was accepted.

The reason is that the XML parser used to resolve external entities and an external DTD referenced by a DOCTYPE declaration. The resolved content could be returned to the caller through the error response, which allowed reading server-accessible files and issuing requests against internal network endpoints. External entity and external DTD resolution are now disabled unconditionally, and the DOCTYPE declaration itself is rejected by default as well.

Practically no valid documents are affected

The ZUGFeRD/Factur-X standard is defined by XML Schema (XSD) and does not use a DTD. All sample documents of all 16 official ZUGFeRD information packages, from version 1.0 through 2.5.2 — 384 documents in total — were checked, and none of them contains a DOCTYPE declaration. Only a generator that relies on internal XML entities (for example <!ENTITY auml "ä"> used as &auml; instead of encoding the character directly in UTF-8) would be affected.

Opt-out​

If a legitimate generator does rely on a DOCTYPE declaration, the check can be relaxed with the following setting:

FormValue
Environment variableWEBPDF_PDFA_ZUGFERD_ALLOW_DOCTYPE=true
System property-Dwebpdf.pdfa.zugferd.allow.doctype=true
Defaultfalse (DOCTYPE declaration rejected)
Limited scope — not a full rollback

This setting only allows the DOCTYPE declaration itself. Resolution of external entities and of an external DTD stays disabled in every case, including with this setting enabled — a document that references an external file or URL is still rejected. This is therefore not a full rollback to the previous behavior, and it lowers a security hardening measure. Treat it as a transitional aid for a generator that cannot be changed quickly, not as a setting to enable by default.

Error message length​

Independent of the above, the error message of a schema validation failure is now truncated to 8 KiB, with a visible truncation marker, to prevent a document with deeply nested internal entities from producing a multi-megabyte error message.

Supported schemas​

Validation for the following ZUGFeRD schemas is supported:

  • Version 1.0 (Comfort)
  • Version 2.0 (Minimum profile, Basic WL profile, Basic profile, EN16931 (Comfort) profile, Extended profile
  • Version 2.1, Version 2.2, Version 2.3, Version 2.4, Version 2.5 (Minimum profile, Basic WL profile, Basic profile, EN16931 (Comfort) profile, Extended profile, X-Rechnung profile) 1

Since version 2.1.1 the profile XRechnung is also supported.

note

The ZUGFeRD 2.x standard supports the XRechnung and Factur-X 1.0 standard developed as part of the German-French Digital Agenda. This means that all requirements according to the complete EU standard of EN 16931 are also met. ZUGFeRD 2.x fulfills all requirements of the EU Directive 2014/55/EU for XRechnung and can be used for invoicing with authorities, nationally and internationally.

For more information on ZUGFeRD and the structure of the XML file and its use, please visit https://www.ferd-net.de.

note

ZUGFeRD 2.1.x and Factur-X 1.0 continue to be fully compatible and technically identical formats, which will already share the Factur-X identifier as of March 24, 2020.

Invoice rule validation​

Since webPDF 10.0.7, an invoice can additionally be checked against an official e-invoicing business rule package — KoSIT XRechnung or Landrix ZUGFeRD. This is independent of, and in addition to, webPDF's own XML schema validation described above (error code PDFA_ZUGFERD_SCHEMA_VALIDATION_ERROR = -410), which always runs first in PDF/A conversion and is unaffected by the rule validation: a document can be valid against webPDF's own schema and still be rejected by a rule package, because the official rule packages check business rules a schema alone cannot express — and vice versa.

The Pdfa web service covers the whole e-invoicing subject, and the invoice rule validation is available wherever it handles an invoice — in three places, with the same parameters, the same meaning and the same result. They differ only in where the invoice comes from and in what the operation returns:

WhereThe invoice isThe operation returns
pdfa > convert > zugferd > invoiceRuleValidationthe XML supplied with the request, checked before it is embedded (see Data embedding)the PDF/A document; a report only if errorReport/successReport request one
pdfa > analyze > invoiceRuleValidationalready embedded in the uploaded PDF/A document (see PDF/A validation)always the PDF/A analysis report
pdfa > invoicethe uploaded document itself — a plain invoice XML without a PDF (see Invoice validation without a PDF)always the invoice validation report

In convert and analyze the check is an opt-in and disabled by default — omitting invoiceRuleValidation, or leaving mode at its default disabled, reproduces the previous behavior byte-for-byte and does not load any rule package. The invoice operation exists only to perform this check, so there it always runs.

{
"pdfa": {
"convert": {
"level": "3b",
"zugferd": {
"xmlFile": {
"value": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4...<BASE64>",
"version": "v25XRechnung"
},
"invoiceRuleValidation": {
"mode": "report",
"notEvaluable": "reject",
"ruleSet": "xrechnung"
}
}
}
}
}
AttributeTypeDefaultDescription
modeenumdisabledFor invoiceRuleValidation in convert and analyze: disabled — no rule validation is performed. report — the invoice is checked and the outcome is added to the report, but never changes the result of the operation. enforce — in addition to report, a rule-violating invoice is rejected (see below for how each branch surfaces that). In the invoice operation, mode only knows report (its default) and enforce.
notEvaluableenumrejectOnly effective under mode: "enforce". Governs the enforcement decision for a document that could not be evaluated at all (see reasons below). reject (fail-closed) treats it the same as a genuine rule violation; accept lets it through instead.
ruleSetstring(none)Optional. Forces a specific configured rule package (for example xrechnung or zugferd) instead of the automatic, ordered selection.
originalReportenumnoneSince webPDF 10.0.7. Whether the rule package's own report — the "Validation Artefact Result List" (VARL) it produces while checking the document, and which webPDF otherwise discards — is delivered alongside webPDF's own result, and in which form. none (default): not delivered; the answer is exactly the answer of a request that omits this attribute. embedded: delivered base64-encoded, complete and unaltered including its own XML declaration, in the originalReport element described below. See Original rule-package report for the interaction with errorReport/successReport and for size considerations.
originalReportHtmlbooleanfalseSince webPDF 10.0.7. Whether the human-readable HTML view the rule package embeds in its own report is additionally delivered as a payload of its own, in the originalReportHtml element. Only effective when originalReport is not none — its own delivery form always follows originalReport; asking for it while originalReport is none has no effect and is not an error.

Invoice validation without a PDF​

Since webPDF 10.0.7, an invoice XML can also be checked on its own, without a PDF carrying it, with the invoice operation of the Pdfa web service. The source document of the request is the invoice XML (ZUGFeRD 2.x / Factur-X CII, or XRechnung as UN/CEFACT CII or UBL); upload it like any other document and call the web service with it:

HTTP REST-APIOpenAPI
POST /pdfa/{documentId}🔗
{
"pdfa": {
"invoice": {
"mode": "enforce",
"ruleSet": "xrechnung"
}
}
}

The operation accepts the parameters of the table above with the same meaning. mode defaults to report here and does not offer disabled: the invoice element itself is the request to check the invoice. An empty element, "invoice": {}, is therefore a complete request that checks the invoice with the automatic rule package selection.

The result document is always the invoice validation report — an XML document with the root element report in the http://schema.webpdf.de/1.0/report/invoice namespace. This holds for every outcome of the check: a compliant invoice, a rule-violating one, and one that could not be evaluated all answer successfully (no error code, no SOAP fault), and the verdict travels in the report's state. Under mode: "enforce" the decision is recorded as enforcement on the report — there is no dedicated error code, the same as in analyze.

<report xmlns="http://schema.webpdf.de/1.0/report/invoice" state="compliant" assessment="accept"
error="0" warning="1" information="0" enforcement="passed" timestamp="2026-09-23T10:00:00Z">
<ruleSet id="xrechnung" name="Validator Configuration XRechnung 3.0.2" release="2026-02-04"/>
<finding .../>
<validationStep id="val-xsd" valid="true"/>
<validationStep id="val-sch.1" valid="true"/>
<document reference="webPDF job 42" hash="Yj4pjuz..." hashAlgorithm="SHA-256"/>
</report>

Two cases are specific to this operation, because the uploaded document itself is the invoice:

ReasonMeaning
sourceDocumentUnreadableThe source document is not well-formed XML — for example a PDF, or an XML file that is truncated. As in PDF/A conversion, a DOCTYPE declaration is rejected by default.
documentTooLargeThe source document exceeds maxDocumentSize (see Server-wide settings); its size is checked before it is read.

An XML document that is well-formed but is not an invoice any rule package recognizes is reported as notEvaluable with the reason noScenario.

Availability

The invoice operation is part of the Pdfa web service. It needs neither a PDF nor the PDF/A converter to check an invoice, but it is available exactly when the Pdfa web service is available: if that web service is disabled in the administration or not covered by the license, the invoice validation is not available either — the same applies to invoiceRuleValidation in convert and analyze.

How a rejection surfaces, per branch​

  • In convert, a rejection under mode: "enforce" aborts the operation with error code PDFA_ZUGFERD_RULE_VALIDATION_ERROR = -416 instead of embedding the invoice. The message tells the two cases apart: <n> rule violation(s) found (rule set '<id>') for a genuine rule violation, and document could not be evaluated (reason: <reason>, rule set: <id>) for a document that could not be evaluated at all. With errorReport: "file", the conversion answers successfully with its report instead, which carries the error code in result/error.
  • In analyze, the operation always returns its XML report — there is no dedicated error code for this check. The enforcement decision is instead recorded as enforcement on the report's invoice element; see PDF/A validation for details.
  • In invoice, the operation always returns the invoice validation report — as in analyze, there is no dedicated error code, and the enforcement decision is recorded as enforcement on the report (see Invoice validation without a PDF).

Invoice validation report​

When a report is produced (convert: errorReport/successReport not none; analyze: always), the outcome is added to it as an invoice element. The invoice operation returns the same content as a document of its own, with the root element report instead of invoice. Both are described by the http://schema.webpdf.de/1.0/report/invoice.xsd schema:

<invoice state="nonCompliant" error="1" warning="0" information="0" enforcement="rejected"
timestamp="2026-08-30T10:00:00Z">
<ruleSet id="xrechnung" name="Validator Configuration XRechnung 3.0.2" release="2026-02-04"/>
<finding .../>
<validationStep id="val-xsd" valid="true"/>
<validationStep id="val-sch.1" valid="false"/>
<document reference="invoice.xml (webPDF job 42)" hash="Yj4pjuz..." hashAlgorithm="SHA-256"/>
</invoice>
  • state — compliant, nonCompliant, or notEvaluable.
  • ruleSet — child element identifying the rule package the invoice was actually checked against: its identifier (id), its name (name) and its release (release, the release date the rule package declares for itself, see Rule packages); present whenever a package could be loaded, even when no scenario of it matched.
  • error / warning / information — number of findings per severity.
  • enforcement — passed or rejected, present only when mode: "enforce" was requested. Its absence means enforcement was not requested; it does not imply passed. Set by analyze and by the invoice operation — in convert, the same decision is already observable as error code -416.
  • timestamp — since webPDF 10.0.7. When the rule package evaluation was performed, with a UTC offset — useful because a later rule package update can change the outcome for the very same document.
  • validationStep — since webPDF 10.0.7. One entry per validation step the rule package actually executed, with id (from the same vocabulary as finding/@step, for example val-xml well-formedness, val-xsd the rule package's own schema step, val-sch.<n> a Schematron step) and valid. A step that did not run — because an earlier step already rejected the document — is absent rather than reported as failed.
  • document — since webPDF 10.0.7. Identifies the checked invoice: reference (a human-readable reference — the embedded attachment's file name when known, followed by the processing job reference; the job reference alone when the invoice was supplied directly), hash and hashAlgorithm (the digest of the exact invoice bytes that were checked, currently SHA-256).

timestamp, validationStep and document are present only when a rule package evaluation actually produced a report — every state="notEvaluable" outcome, whatever its reason, omits them together; their absence carries no information about the verdict by itself.

If the document could not be evaluated at all, state="notEvaluable" is reported together with a reason, for example noScenario, timeBudgetExceeded, or ruleSetLoadError. PDF/A validation lists the additional reasons that are specific to checking an invoice already embedded in an uploaded document.

Original rule-package report​

Since webPDF 10.0.7, the rule package's own report (the VARL it produces while checking the invoice, and which webPDF otherwise discards after extracting the findings above) can be delivered alongside webPDF's result, using originalReport and originalReportHtml (see the parameter table above). Both work identically in convert, analyze and the invoice operation.

<invoice state="nonCompliant" ...>
...
<originalReport>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxyZXA6cmVwb3J0IC4uLj4=</originalReport>
<originalReportHtml>PGh0bWwgZGF0YS1yZXBvcnQtdHlwZT0icmVwb3J0Ij4uLi48L2h0bWw+</originalReportHtml>
</invoice>
  • originalReport — the rule package's own report, base64-encoded exactly as produced, including its own XML declaration. webPDF neither rewrites nor abridges it.
  • originalReportHtml — the human-readable HTML view the rule package embeds in its own report, base64-encoded, extracted from that report rather than re-rendered — the same document, not a webPDF reconstruction of it.

Both elements are present only when they were requested and a rule package evaluation actually produced a report; their absence never changes state, assessment, reason, or the finding counters. The payload travels wherever the invoice element itself travels — through successReport/errorReport in convert, as part of the always-returned analysis report in analyze, or as part of the always-returned invoice validation report of the invoice operation — including errorReport: "message" for a rejected invoice in convert.

Size and where a rejected invoice's report is delivered

The rule package's own report is typically several times the size of webPDF's own report and grows with the number of findings; base64 encoding adds about another third on top. In convert, prefer errorReport: "file" over errorReport: "message" for large reports: the latter delivers the full report — including invoice content such as the supplier, invoice number, invoice date and a table of element values — inside the REST error body or the SOAP fault, which callers, middleware and monitoring routinely log and forward.

A server administrator can cap the size of both payloads independently with maxOriginalReportSize (see Server-wide settings); a payload above that ceiling is simply omitted, the verdict and the operation's result stay exactly as they are.

Rule packages​

webPDF ships two business rule packages. They are the official validator configurations of their publishers, delivered unchanged, and they are what the ruleSet parameter and the ruleSet element of the report refer to:

ruleSetRule packageRelease (ruleSet/@release)Covers
xrechnungKoSIT "Validator Configuration XRechnung 3.0.2"2026-02-04XRechnung 3.0 as UBL invoice, UBL credit note and UN/CEFACT CII, including the XRechnung extension and CVD variants, plus the plain EN 16931 guideline (urn:cen.eu:en16931:2017) in all three syntaxes
zugferdLandrix "Validator Configuration ZUGFeRD 2.5"2026-06-11ZUGFeRD 2.5 / Factur-X 1.09 profiles MINIMUM, BASIC WL, BASIC, EN 16931 (Comfort) and EXTENDED (CII), plus other EN 16931-based CII invoices

Which package checks a document is decided by the document itself: each package declares, per scenario, which documents it applies to (by the syntax and the guideline identifier of the invoice). Without ruleSet, the packages are tried in the configured order — by default zugferd before xrechnung — and the first package with a matching scenario decides. Both packages accept a document with the plain EN 16931 guideline identifier urn:cen.eu:en16931:2017; for such a document the default order selects zugferd, and ruleSet: "xrechnung" selects the other one. A forced ruleSet never falls back to another package: if it has no matching scenario, the outcome is notEvaluable with the reason noScenario.

A package is loaded and compiled when it is first used, and then kept in memory until the server is stopped; a package that is never used costs nothing. Measured with the packages listed above, an activated package occupies about 50 MB of Java heap for xrechnung and about 75 MB for zugferd, and loading takes a few seconds on the first request that uses it. The memory does not grow with the number of requests. Take this into account when sizing the Java heap of a server that uses the invoice rule validation, and disable a package you do not need (see below).

Cluster and container operation

Every cluster member and every container loads the rule packages itself. Use the same rule packages and the same <invoiceValidation> configuration on all of them — a node with a different package or selection order produces a different result for the same request.

Server-wide settings​

The rule packages and the rule validation engine's limits are configured server-wide in the <invoiceValidation> block of application.xml. It is optional: without it, both built-in packages are available with the defaults below.

A <ruleSet> entry overrides the order, the activation or the location of a rule package. Entries not listed keep their built-in default (enabled, built-in location); when entries are present, they define the selection order, and a built-in package that is not listed is appended after them in its default order.

<invoiceValidation maxDocumentSize="8388608" timeout="60">
<ruleSet id="xrechnung"/>
<ruleSet id="zugferd" enabled="false"/>
</invoiceValidation>
ruleSet attributeDefaultDescription
id(required)The rule package identifier: xrechnung, zugferd, or the identifier of an additional package.
enabledtrueActivates or deactivates the rule package.
locationbuilt-in locationFolder containing the rule package's scenarios.xml, relative to the schemas folder in the server's resources directory. The built-in packages are located in invoice/xrechnung and invoice/zugferd. A location outside that folder, or one that does not contain a readable rule package, is not registered; the error is logged, and a request that uses it ends as notEvaluable.

Every attribute of <invoiceValidation> itself can also be set as an environment variable or JVM system property, which take precedence over the configuration file:

AttributeEnvironment variableSystem propertyDefaultDescription
maxDocumentSizeWEBPDF_INVOICE_VALIDATION_MAX_DOCUMENT_SIZEwebpdf.invoice.validation.max.document.size8388608 (8 MiB)Upper size, in bytes, of the invoice document (XML) checked against a rule package.
maxDocumentDepthWEBPDF_INVOICE_VALIDATION_MAX_DOCUMENT_DEPTHwebpdf.invoice.validation.max.document.depth100Upper nesting depth of the parsed invoice document.
timeoutWEBPDF_INVOICE_VALIDATION_TIMEOUTwebpdf.invoice.validation.timeout60 (seconds)Soft time budget for a single invoice rule validation.
maxActiveRuleSetsWEBPDF_INVOICE_VALIDATION_MAX_ACTIVE_RULE_SETSwebpdf.invoice.validation.max.active.rule.sets4Upper number of simultaneously active rule packages.
maxOriginalReportSizeWEBPDF_INVOICE_VALIDATION_MAX_ORIGINAL_REPORT_SIZEwebpdf.invoice.validation.max.original.report.size8388608 (8 MiB)Upper size, in bytes, of the rule package's own report handed out on request, measured against the raw, not-yet-encoded payload — originalReport and originalReportHtml are measured against this ceiling independently. Unlike the limits above, this one bounds the answer, not the input. 0 disables the delivery entirely, the same fail-closed reading as the other limits.
Since webPDF 10.0.7

Two additional attributes bound the extraction of an invoice from an uploaded PDF/A document in pdfa > analyze; see PDF/A validation for how they are used.

AttributeEnvironment variableSystem propertyDefaultDescription
maxAttachmentCompressedSizeWEBPDF_INVOICE_VALIDATION_MAX_ATTACHMENT_COMPRESSED_SIZEwebpdf.invoice.validation.max.attachment.compressed.size2097152 (2 MiB)Upper size, in bytes, of the RAW, still compressed attachment stream, checked before decompression.
maxAttachmentCandidatesWEBPDF_INVOICE_VALIDATION_MAX_ATTACHMENT_CANDIDATESwebpdf.invoice.validation.max.attachment.candidates64Upper number of embedded file entries considered while looking for the invoice attachment.

Footnotes​

  1. The XRechnung is the German CIUS (Core Invoice Usage Specification), which was developed in accordance with the European standard 16931, which originated from EU Directive 2014/55/EU. EN 16931 specifies two valid XML schemas: Universal Business Language (UBL) and UN/CEFACT Cross Industry Invoice (CII). This means that XRechnungs must be transmitted in one of the two formats. ↩