Expand description
Factur-X, ZUGFeRD and Order-X PDF files (feature pdf, on by default): the invoice
XML a PDF/A-3 file embeds, extracted with einvoice_pdf, to be validated as any
other document.
extract returns the embedded file named as the specifications require
(INVOICE_FILE_NAMES), byte for byte, with its file specification
(/AFRelationship, …) and the XMP metadata of the document (the PDF/A
identification, the Factur-X / ZUGFeRD properties). Syntax::detect then tells
which built-in rule set the XML is for:
fn validate(file: &[u8]) -> Result<einvoice_validator::Report, einvoice_validator::Error> {
use einvoice_validator::{Syntax, Validator, pdf};
let xml = if pdf::is_pdf(file) {
let embedded = pdf::extract(file)?;
println!("{} ({:?})", embedded.xml.file_name, embedded.xml.relationship);
embedded.xml.data
} else {
file.to_vec()
};
let rule_set = Syntax::detect(&xml).map_or("cen-ubl", Syntax::builtin_rule_set);
Validator::builtin(rule_set)?.validate_owned(xml)
}Only the part of PDF on the path to the embedded files is read (see einvoice_pdf);
anything else met there is refused rather than read approximately. The errors are
Error::Pdf.
Structs§
- Attachment
- An embedded file: its file specification and its decoded content.
- Embedded
- What
extractreturns. - Invoice
Metadata - The Factur-X /
ZUGFeRD/ Order-X extension schema properties of the XMP metadata. - Limits
- Bounds on the work done for one file, against hostile input. Every bound that is
reached is an
Error::LimitExceedednaming the field. - Metadata
- The XMP metadata of the document catalog (
/Metadata).
Enums§
- AfRelationship
- The relationship of an associated file to the document (
/AFRelationship, ISO 32000-2, 14.13.2, Table 43).
Constants§
- INVOICE_
FILE_ NAMES - The names under which the specifications embed the invoice XML: Factur-X (and
ZUGFeRD2.1 and later),ZUGFeRD2.0,ZUGFeRD1.0,XRechnunginZUGFeRD, Order-X.