ZuGFeRD / Facture-X Support

The ZuGFeRD is a German invoice format that consists of:

The PDF file represents the human readable version and the XML file the electronic version.

 

ZuGFeRD is also known as Factur-X in France.

 

The ZuGFeRD standard was created to simplify and standardize the exchange of invoices. For more information, please visit :  www.ferd-net.de

 

The creation ZuGFeRD invoices involves the combination of

 

The XMP metadata consists basically in:

<rdf:Description xmlns:zf=' urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#' rdf:about=' ' >
<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>
<zf:DocumentFileName>ZuGFeRD-invoice.xml</zf:DocumentFileName>
<zf:DocumentType>INVOICE</zf:DocumentType>
<zf:Version>1.0</zf:Version>
</rdf:Description>

Remarks

In the case of the evaluation version, the ZuGFerD validation could fail, because the trial watermark font is not embedded.

Example

Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"

    Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"

 

    ' Initialize library

    ' This should be done once

    acPDFCreatorLib.Initialize()

 

    ' set license key This is needed only with licensed version

    acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Open the PDF/A-3b file

    Dim fileName As String = "c:\temp\invoice_pdfa.pdf"

    Dim password As String = ""

 

    ' Create new stream object

    Dim fileRead As System.IO.Stream = System.IO.File.OpenRead(fileName)

 

    ' Create a new PDF document

    Dim doc As New Amyuni.PDFCreator.IacDocument()

 

    ' Open PDF file

    doc.Open(fileRead, password)

 

    ' Create page object

    Dim page As Amyuni.PDFCreator.IacPage

 

    ' Define first page of PDF document

    page = doc.GetPage(1)

 

    ' Attach the ZuGFeRD-invoice.xml to the current document

    With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeAttachment, "ZuGFeRD-invoice.xml")

        .Attribute("Description").Value = "(ZuGFeRD Rechnung)"

        .Attribute("Type").Value = "text/xml"

        .Attribute("Relationship").Value = "Alternative"

        .Attribute("FileName").Value = "ZUGFeRD-invoice.xml"

        .Attribute("ReadFromFile").Value = "c:\temp\ZuGFeRD-invoice.xml"

    End With

 

    ' Adding Meta Information

    doc.Attribute("Author").Value = "Amyuni"

    doc.Attribute("Subject").Value = "ZuGFeRD Invoice Sample"

    doc.Attribute("Keywords").Value = "add keywords"

    doc.Attribute("Creator").Value = "Amyuni Technologies"

    doc.Attribute("Title").Value = "ZuGFeRD INVOICE"

 

    ' Addition XMP metadata to conform with ZuGFeRD

    doc.Attribute("ExtraXMPMetadata").Value =            

            "<rdf:Description xmlns:zf=' urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#' rdf:about=' ' >" + Chr(13) + Chr(10) +

            "<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>" + Chr(13) + Chr(10) +

            "<zf:DocumentFileName>ZuGFeRD-invoice.xml</zf:DocumentFileName>" + Chr(13) + Chr(10) +

            "<zf:DocumentType>INVOICE</zf:DocumentType>" + Chr(13) + Chr(10) +

            "<zf:Version>1.0</zf:Version>" + Chr(13) + Chr(10) +

            "</rdf:Description>" + Chr(13) + Chr(10) +

            "<rdf:Description xmlns:pdfaExtension=' http:// www.aiim.org/pdfa/ns/extension/' xmlns:pdfaSchema=' http:// www.aiim.org/pdfa/ns/schema#' xmlns:pdfaProperty=' http:// www.aiim.org/pdfa/ns/property#' rdf:about=' ' >" + Chr(13) + Chr(10) +

            "<pdfaExtension:schemas>" + Chr(13) + Chr(10) +

            "<rdf:Bag>" + Chr(13) + Chr(10) +

            "<rdf:li rdf:parseType=' Resource' >" + Chr(13) + Chr(10) +

            "<pdfaSchema:schema>ZuGFeRD PDFA Extension Schema</pdfaSchema:schema>" + Chr(13) + Chr(10) +

            "<pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>" + Chr(13) + Chr(10) +

            "<pdfaSchema:prefix>zf</pdfaSchema:prefix>" + Chr(13) + Chr(10) +

            "<pdfaSchema:property>" + Chr(13) + Chr(10) +

            "<rdf:Seq>" + Chr(13) + Chr(10) +

            "<rdf:li rdf:parseType=' Resource' >" + Chr(13) + Chr(10) +

            "<pdfaProperty:name>DocumentFileName</pdfaProperty:name>" + Chr(13) + Chr(10) +

            "<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + Chr(13) + Chr(10) +

            "<pdfaProperty:category>external</pdfaProperty:category>" + Chr(13) + Chr(10) +

            "<pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>" + Chr(13) + Chr(10) +

            "</rdf:li>" + Chr(13) + Chr(10) +

            "<rdf:li rdf:parseType=' Resource' >" + Chr(13) + Chr(10) +

            "<pdfaProperty:name>DocumentType</pdfaProperty:name>" + Chr(13) + Chr(10) +

            "<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + Chr(13) + Chr(10) +

            "<pdfaProperty:category>external</pdfaProperty:category>" + Chr(13) + Chr(10) +

            "<pdfaProperty:description>INVOICE</pdfaProperty:description>" + Chr(13) + Chr(10) +

            "</rdf:li>" + Chr(13) + Chr(10) +

            "<rdf:li rdf:parseType=' Resource' >" + Chr(13) + Chr(10) +

            "<pdfaProperty:name>Version</pdfaProperty:name>" + Chr(13) + Chr(10) +

            "<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + Chr(13) + Chr(10) +

            "<pdfaProperty:category>external</pdfaProperty:category>" + Chr(13) + Chr(10) +

            "<pdfaProperty:description>The actual version of the ZuGFeRD XML schema</pdfaProperty:description>" + Chr(13) + Chr(10) +

            "</rdf:li>" + Chr(13) + Chr(10) +

            "<rdf:li rdf:parseType=' Resource' >" + Chr(13) + Chr(10) +

            "<pdfaProperty:name>ConformanceLevel</pdfaProperty:name>" + Chr(13) + Chr(10) +

            "<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + Chr(13) + Chr(10) +

            "<pdfaProperty:category>external</pdfaProperty:category>" + Chr(13) + Chr(10) +

            "<pdfaProperty:description>The conformance level of the embedded ZuGFeRD data</pdfaProperty:description>" + Chr(13) + Chr(10) +

            "</rdf:li>" + Chr(13) + Chr(10) +

            "</rdf:Seq>" + Chr(13) + Chr(10) +

            "</pdfaSchema:property>" + Chr(13) + Chr(10) +

            "</rdf:li>" + Chr(13) + Chr(10) +

            "</rdf:Bag>" + Chr(13) + Chr(10) +

            "</pdfaExtension:schemas>" + Chr(13) + Chr(10) +

            "</rdf:Description>" + Chr(13) + Chr(10)

 

    ' Create new stream object

    Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("c:\temp\invoice_pdfa_XML-attached-ZuGFeRD.pdf")

 

    ' Save the ZuGFeRD PDF file

    doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSavePDFA)

 

    ' Close the streams

    fileRead.Close()

    fileWrite.Close()

 

    ' terminate library to free resources

    acPDFCreatorLib.Terminate()

 

    ' destroy objects

    doc.Dispose()

    page.Dispose()

End Sub

static void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";

    const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";

 

    // Initialize library

    // This should be done once

    acPDFCreatorLib.Initialize();

 

    // set license key This is needed only with licensed version

    acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Open the PDF/A-3b file

    string fileName = @"c:\temp\invoice_pdfa.pdf";

    string password = "";

 

    // Create new stream object

    System.IO.FileStream fileRead = new System.IO.FileStream(fileName,

            System.IO.FileMode.Open,

            System.IO.FileAccess.Read,

            System.IO.FileShare.Read);

 

    // Create a new PDF document

    Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();

 

    // Open PDF file

    doc.Open(fileRead, password);

 

    // Create page object

    Amyuni.PDFCreator.IacPage page;

 

    // Define first page of PDF document

    page = doc.GetPage(1);

 

    // Create an Arrow

    using (Amyuni.PDFCreator.IacObject oAttachment = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeAttachment, "ZuGFeRD-invoice.xml"))

    {

        oAttachment.Attribute("Description").Value = "(ZuGFeRD Rechnung)";

        oAttachment.Attribute("Type").Value = "text/xml";

        oAttachment.Attribute("Relationship").Value = "Alternative";

        oAttachment.Attribute("FileName").Value = "ZUGFeRD-invoice.xml";

        oAttachment.Attribute("ReadFromFile").Value = @"c:\temp\ZuGFeRD-invoice.xml";

    }

 

    // Adding Meta Information

    // Using Document Object

    doc.Attribute("Author").Value = "Amyuni";

    doc.Attribute("Subject").Value = "ZuGFeRD Invoice Sample";

    doc.Attribute("Keywords").Value = "add keywords";

    doc.Attribute("Creator").Value = "Amyuni Technologies";

    doc.Attribute("Title").Value = "ZuGFeRD INVOICE";

 

    // Addition XMP metadata to conform with ZuGFeRD

    doc.Attribute("ExtraXMPMetadata").Value =

"<rdf:Description xmlns:zf=' urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#'  rdf:about=' ' >" + "\r\n" +

"<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>" + "\r\n" +

"<zf:DocumentFileName>ZuGFeRD-invoice.xml</zf:DocumentFileName>" + "\r\n" +

"<zf:DocumentType>INVOICE</zf:DocumentType>" + "\r\n" +

"<zf:Version>1.0</zf:Version>" + "\r\n" +

"</rdf:Description>" + "\r\n" +

"<rdf:Description xmlns:pdfaExtension=' http:// www.aiim.org/pdfa/ns/extension/'  xmlns:pdfaSchema=' http:// www.aiim.org/pdfa/ns/schema#'  xmlns:pdfaProperty=' http:// www.aiim.org/pdfa/ns/property#'  rdf:about=' ' >" + "\r\n" +

"<pdfaExtension:schemas>" + "\r\n" +

"<rdf:Bag>" + "\r\n" +

"<rdf:li rdf:parseType=' Resource' >" + "\r\n" +

"<pdfaSchema:schema>ZuGFeRD PDFA Extension Schema</pdfaSchema:schema>" + "\r\n" +

"<pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>" + "\r\n" +

"<pdfaSchema:prefix>zf</pdfaSchema:prefix>" + "\r\n" +

"<pdfaSchema:property>" + "\r\n" +

"<rdf:Seq>" + "\r\n" +

"<rdf:li rdf:parseType=' Resource' >" + "\r\n" +

"<pdfaProperty:name>DocumentFileName</pdfaProperty:name>" + "\r\n" +

"<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + "\r\n" +

"<pdfaProperty:category>external</pdfaProperty:category>" + "\r\n" +

"<pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>" + "\r\n" +

"</rdf:li>" + "\r\n" +

"<rdf:li rdf:parseType=' Resource' >" + "\r\n" +

"<pdfaProperty:name>DocumentType</pdfaProperty:name>" + "\r\n" +

"<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + "\r\n" +

"<pdfaProperty:category>external</pdfaProperty:category>" + "\r\n" +

"<pdfaProperty:description>INVOICE</pdfaProperty:description>" + "\r\n" +

"</rdf:li>" + "\r\n" +

"<rdf:li rdf:parseType=' Resource' >" + "\r\n" +

"<pdfaProperty:name>Version</pdfaProperty:name>" + "\r\n" +

"<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + "\r\n" +

"<pdfaProperty:category>external</pdfaProperty:category>" + "\r\n" +

"<pdfaProperty:description>The actual version of the ZuGFeRD XML schema</pdfaProperty:description>" + "\r\n" +

"</rdf:li>" + "\r\n" +

"<rdf:li rdf:parseType=' Resource' >" + "\r\n" +

"<pdfaProperty:name>ConformanceLevel</pdfaProperty:name>" + "\r\n" +

"<pdfaProperty:valueType>Text</pdfaProperty:valueType>" + "\r\n" +

"<pdfaProperty:category>external</pdfaProperty:category>" + "\r\n" +

"<pdfaProperty:description>The conformance level of the embedded ZuGFeRD data</pdfaProperty:description>" + "\r\n" +

"</rdf:li>" + "\r\n" +

"</rdf:Seq>" + "\r\n" +

"</pdfaSchema:property>" + "\r\n" +

"</rdf:li>" + "\r\n" +

"</rdf:Bag>" + "\r\n" +

"</pdfaExtension:schemas>" + "\r\n" +

"</rdf:Description>" + "\r\n"

 

    // Create new stream object

    System.IO.FileStream fileWrite = new System.IO.FileStream(@"c:\temp\invoice_pdfa_XML-attached-ZuGFeRD.pdf",

            System.IO.FileMode.Create,

            System.IO.FileAccess.Write,

            System.IO.FileShare.Read);

 

    // Save the ZuGFeRD PDF file

    doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSavePDFA);

 

    // Close the streams

    fileRead.Close();

    fileWrite.Close();

 

    // terminate library to free resources

    acPDFCreatorLib.Terminate();

 

    // destroy pdfCreator object

    doc.Dispose();

    page.Dispose();

}