Issue with Adding ZUGFeRD XML Data as an Attachment in ReportBuilder 22.03
Hello,
To create a ZUGFeRD invoice, I add an attachment using the following command:
ppReport1.PDFSettings.Attachments.AddObject('ZUGFeRD-invoice.xml=', streamAttach);
The variable `streamAttach` is a `MemoryStream`. It contains XML data that complies with the ZUGFeRD format. This works correctly with ReportBuilder Enterprise Edition version 20.04. After upgrading to version 22.03 Build 340, I encounter an exception when executing the command:
ppReport1.Print;
The exception displays the following message:
XML Parser Error, Line 0: Start tag not found, expected "<"
I also get this exception when using the `AddPair` command, for example, like this:
Attachments.AddPair('ZUGFeRD-invoice.xml=', '', streamAttach);
Attachments.AddPair('ZUGFeRD-invoice.xml=', sXML); // sXML is a string
The exception is not entirely surprising, as upon closer inspection, the attachment contains no data. It is evidently empty. What do I need to do to programmatically add ZUGFeRD XML data to the attachment in the code, either as a string or as a stream?
By the way, I do get a valid ZUGFeRD invoice when I provide the XML data in a separate file using a statement like:
ppReport.PDFSettings.Attachments.Add('c:\Temp\ZUGFeRD-invoice.xml');
However, due to the required separate file handling, I would prefer not to implement this approach.
Many thanks in advance and best regards,
Michael
To create a ZUGFeRD invoice, I add an attachment using the following command:
ppReport1.PDFSettings.Attachments.AddObject('ZUGFeRD-invoice.xml=', streamAttach);
The variable `streamAttach` is a `MemoryStream`. It contains XML data that complies with the ZUGFeRD format. This works correctly with ReportBuilder Enterprise Edition version 20.04. After upgrading to version 22.03 Build 340, I encounter an exception when executing the command:
ppReport1.Print;
The exception displays the following message:
XML Parser Error, Line 0: Start tag not found, expected "<"
I also get this exception when using the `AddPair` command, for example, like this:
Attachments.AddPair('ZUGFeRD-invoice.xml=', '', streamAttach);
Attachments.AddPair('ZUGFeRD-invoice.xml=', sXML); // sXML is a string
The exception is not entirely surprising, as upon closer inspection, the attachment contains no data. It is evidently empty. What do I need to do to programmatically add ZUGFeRD XML data to the attachment in the code, either as a string or as a stream?
By the way, I do get a valid ZUGFeRD invoice when I provide the XML data in a separate file using a statement like:
ppReport.PDFSettings.Attachments.Add('c:\Temp\ZUGFeRD-invoice.xml');
However, due to the required separate file handling, I would prefer not to implement this approach.
Many thanks in advance and best regards,
Michael
Comments
In my testing with RB 23.0, PDF ZUGFeRD with stream attachments works.
If you would like to upgrade to RB 23, you can email support@ and we can provide a working example.
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com