The pdfMachine SDK can be used to attach xml files to PDFA/3b PDF files to form valid ZUGFeRD 1.0 invoices. The input xml and PDF files must conform to the ZUGFeRD 1.0 documentation.
When the fileName parameter of the attachFile method is "zugferd-invoice.xml" then the ZUGFeRD 1.0 metadata will also be inserted into the PDF.
The wsdl file for the SOAP Web service installs with the SDK.
Attach an xml to a PDF to form a ZUGFeRD 1.0 compliant PDF.
Parameters <input> :
inPDF
Array of base64 Binary encoded bytes.
The PDFA/3b PDF component of the invoice.
fileData
Array of base64 Binary encoded bytes.
he xml representation of the invoice.
fileName
string
The name that will be used for the embedded xml. Must be "zugferd-invoice.xml"
fileDescription
string
The PDFA/3b PDF component of the invoice.
ZUGFeRDtype
string
The corresponding ZUGFeRD 1.0 conformance level consistent with the xml file passed in.
BASIC, COMFORT or EXTENDED
Parameters <output> :
Result
Object consisting of
outPDF
Array of base64 Binary encoded bytes.
The resulting PDF.
errorMessage
string
Error Message.
C# Parameters : Input PDF path and filename, Input xml attachment path and filename, output PDF path and filename. Optional : url for EndPoint address.
using System; using System.Text; using System.IO; using System.ServiceModel; namespace CSharpSoapClientTest { class Program { static void Main(string[] args) { try { string inPDF = args[0]; string inXML = args[1]; string fileName = "ZUGFeRD-invoice.xml"; string fileDescription = """; string ZUGFeRDtype = "BASIC"; string outputPDF = args[2]; string url = ""; if (args.Length > 3) url = args[3]; ServiceReference1.pdfServMachinePortTypeClient pdfM; pdfM = new CSharpSoapClientTest.ServiceReference1.pdfServMachinePortTypeClient(); if (url.Length > 0) pdfM.Endpoint.Address = new EndpointAddress(url); byte[] pdf = File.ReadAllBytes(inPDF); byte[] xml = File.ReadAllBytes(inXML); string errorMessage; byte[] outPDF = pdfM.attachFile(pdf, xml, fileName, fileDescription, ZUGFeRDtype, out errorMessage); if (errorMessage.Length > 0) System.Console.WriteLine("Error testing attachFile : " + errorMessage); System.IO.File.WriteAllBytes(outputPDF, outPDF); } catch (System.Exception ex) { System.Console.WriteLine(ex); } } } }
The pdfMachine SDK can be used to attach xml files to PDFA/3b PDF files to form valid ZUGFeRD 2.1.1 / Factur-x 1.0 invoices. The input xml and PDF files must conform to the rules for the ZUGFeRD 2.1.1 / Factur-x 1.0 documentation. Attachments and Explanatory Documents for Invoices can also be attached consistent.
The wsdl file for the SOAP Web service installs with the SDK. The API consists of :
Exceptions should be caught to trap errors.
Attach an xml to a PDF to form a ZUGFeRD 2.1.1 / Factur-x 1.0 compliant PDF.
Parameters <input> :
inPDF
Array of base64 Binary encoded bytes.
The PDFA/3b PDF component of the invoice.
inXML
Array of base64 Binary encoded bytes.
The xml representation of the invoice.
xmlDisplayName
string
The name to be used for the attached xml.
e.g. "factur-x.xml" or "xrechnung.xml"
xmlFileDescription
string
The file description for the embedded xml.
e.g. "ZUGFeRD 2.1 Rechnung" or "XRechnung Rechnung"
ZUGFeRDversion
string
The major and minor version of the underlying invoice data specification.
e.g. "1.0"
ZUGFeRDtype
string
The corresponding ZUGFeRD 2.1.1 conformance level consistent with the xml file passed in.
e.g. MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED, XRECHNUNG
ZUGFeRDrelationship
string
The data relationship the xml file has to the PDF.
e.g. Data, Source, Alternative, Supplement, Unspecified
logid
string
An identifier that can be used to identify the call if logging is switched on.
Parameters <output> :
Result
Object consisting of
outPDF
Array of base64 Binary encoded bytes.
The resulting PDF.
errorMessage
string
Error Message.
Attach an additional or explanatory document to a ZUGFeRD 2.1.1 / Factur-x 1.0 compliant PDF.
Parameters <input> :
inPDF
Array of base64 Binary encoded bytes.
The PDFA/3b PDF component of the invoice.
inAttachment
Array of base64 Binary encoded bytes.
The additional or explanatory document to be attached.
xmlDisplayName
string
The name to be used for the attached xml.
e.g. "factur-x.xml" or "xrechnung.xml"
attachDisplayName
string
The name to be used for the additional or explanatory document. The suffix will be used to identify the appropriate MIME type for the document.
e.g. "report.xlsx"
xmlFileDescription
string
The file description for the ZUGFeRD invoice xml.
e.g. "ZUGFeRD 2.1 Rechnung" or "XRechnung Rechnung"
attachFileDescription
string
The file description for the additional or explanatory document.
e.g. "Progress report"
ZUGFeRDversion
string
The major and minor version of the underlying invoice data specification.
e.g. "1.0"
ZUGFeRDtype
string
The corresponding ZUGFeRD 2.1.1 conformance level consistent with the xml file passed in.
e.g. MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED, XRECHNUNG
attachRelationship
string
The relationship the additional or explanatory file has to the PDF.
e.g. Data, Source, Alternative, Supplement, Unspecified
logid
string
An identifier that can be used to identify the call if logging is switched on.
Parameters <output> :
Result
Object consisting of
outPDF
Array of base64 Binary encoded bytes.
The resulting PDF.
errorMessage
string
Error Message.
C# Parameters : Input PDF path and filename, Input xml attachment path and filename, output PDF path and filename. Optional : url for EndPoint address.
namespace CSharpSoapClientTest { class Program { static void Main(string[] args) { try { string inPDF = args[0]; string inXML = args[1]; string inExplanatory = args[2]; string outputPDF = args[3]; string url = ""; if (args.Length > 4) url = args[3]; ServiceReference1.pdfServMachinePortTypeClient pdfM; pdfM = new CSharpSoapClientTest.ServiceReference1.pdfServMachinePortTypeClient(); // ("http://localhost:3981"); //"http://tempuri.org/pdfServMachine.xsd");//"http://localhost:80/Service.wsdl");//"pdfServeMachineSoap"); // "http://localhost:80/Service.wsdl");//"http://tempuri.org/pdfServMachine.xsd");//"http://localhost:3981"); if (url.Length > 0) pdfM.Endpoint.Address = new EndpointAddress(url); byte[] pdf = File.ReadAllBytes(inPDF); byte[] xml = File.ReadAllBytes(inXML); string errorMessage = ""; try { // Attach a ZUGFeRD MINIMUM xml to a PDFA/3b PDF xml = File.ReadAllBytes(inXML); byte[] outPDF = pdfM.attachZugferdInvoice(pdf, xml, "factur-x.xml", "ZUGFeRD 2.1 Rechnung", "1.0", "EN 16931", "Data", "EN 16931_data.pdf", out errorMessage); if (errorMessage.Length > 0) System.Console.WriteLine("Error testing EN 16931_data : " + errorMessage); else System.IO.File.WriteAllBytes(outputPDF, outPDF); // Attach an explanatory file to the ZUGFeRD PDFA byte[] info = File.ReadAllBytes(inExplanatory); outPDF = pdfM.attachZugferdInformation(outPDF, info, "factur-x.xml", "report.txt", "ZUGFeRD 2.1 Rechnung", "progress report", "1.0", "EN 16931", "Source", "EN16931_alt_info", 0, out errorMessage); if (errorMessage.Length > 0) System.Console.WriteLine("Error testing EN16931_alt_info : " + errorMessage); else System.IO.File.WriteAllBytes(outputPDF, outPDF); } catch (System.IO.IOException ex1) { System.Console.WriteLine("Exception : " + ex1.Message); if (errorMessage.Length > 0) System.Console.WriteLine("Error : " + errorMessage); } catch (Exception ex) { System.Console.WriteLine("Exception : " + ex.Message); } if (errorMessage.Length > 0) System.Console.WriteLine("Error : " + errorMessage); } catch (System.Exception ex) { System.Console.WriteLine(ex); } System.Console.WriteLine("Done"); } } }