In Germany it is compulsory to add an XML attachment with invoice data from 1.1.2025.
The attachment has to be added as an associated file. This option ist not available in GemBox.PDF at the moment.
I am currently facing the problem, that adding the XML to the pdf seems to be corrupting the PDF. The official validtor for elektronic invoices rejects my pdf file.
I would appreciate any feedback if someone successfully created an ZUGFerd Invoice thru gembox.
Regards Karl
Can you please check this “Associated Files” example:
If the problem remains, please send us a small Visual Studio project that reproduces your issue so we can investigate it.
Also, please specify the “official validator for electronic invoices” you use.
I’m also trying to add ZUGFeRD XML as an attachment to a PDF and have already seen the example. Unfortunately I can’t find the functionality I need. Maybe you can help me with this.
Below is a code snipped:
var options = new GemBox.Document.RtfLoadOptions() { Encoding = Encoding.GetEncoding(1252) };
GemBox.Document.DocumentModel document = GemBox.Document.DocumentModel.Load(sFileName, options);
foreach (var section in document.Sections)
section.PageSetup.PaperType = GemBox.Document.PaperType.A4;
GemBox.Document.Paragraph paragraph = new GemBox.Document.Paragraph(document);
GemBox.Document.Run run = new GemBox.Document.Run(document);
paragraph.Inlines.Add(run);
//ToDo: Adding the XML as Attachment
GemBox.Document.CustomXmlPart part = new GemBox.Document.CustomXmlPart();
//part.Data = File.ReadAllBytes(@"D:\Downloads\CII.xml");
part.Id = "4711";
using (StreamReader sr = new StreamReader(@"D:\Downloads\xmp.txt"))
{
while(sr.Peek() > 0)
part.Schemas.Add(sr.ReadLine());
}
string sFilePDF = sFileName.Replace(".RTF", ".PDF");
document.Save(sFilePDF);