Hello,
No, that can't be the case and it's not possible that that was my original Code.
Are you sure you used my PDF file because I use a completely different XML name in the code.
Code: Select all
<script type="text/javascript">
var options = new Stimulsoft.Viewer.StiViewerOptions();
options.toolbar.showSendEmailButton = true;
options.toolbar.displayMode = Stimulsoft.Viewer.StiToolbarDisplayMode.Separated;
options.appearance.fullScreenMode = true;
options.appearance.scrollbarsMode = true;
options.height = "600px"; // Height for non-fullscreen mode
var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
function loadJsonFile(filePath) {
return fetch(filePath)
.then(response => {
if (!response.ok) {
throw new Error('err net');
}
return response.json();
})
.catch(error => {
console.error('error fetch: ', error);
});
}
const jsonFilePath = 'reports/SimpleList.json';
const xmlFilePath = 'reports/SimpleList.xml';
var report = new Stimulsoft.Report.StiReport();
var n = Stimulsoft.System.Guid.newGuid().toString().substr(0, 8);
report.loadFile("reports/SimpleList.mrt" + "?n=" + n);
report.culture = "de-DE";
var dataSet = new Stimulsoft.System.Data.DataSet("data");
viewer.renderHtml("viewerContent");
loadJsonFile(jsonFilePath).then(reportdata => {
dataSet.readJson(reportdata);
report.regData(dataSet.dataSetName, "", dataSet);
});
var saveMenu = viewer.jsObject.controls.menus.saveMenu;
var customSaveItem = viewer.jsObject.VerticalMenuItem(saveMenu, "myItemName", "test download zugferd", "emptyImage", "customItemKey");
saveMenu.innerContent.appendChild(customSaveItem);
customSaveItem.action = function () {
saveMenu.changeVisibleState(false);
var pdfExportSettings = new Stimulsoft.Report.Export.StiPdfExportSettings();
pdfExportSettings.ZUGFeRDComplianceMode = Stimulsoft.Report.Export.StiPdfZUGFeRDComplianceMode.V2_1;
pdfExportSettings.ZUGFeRDConformanceLevel = "EN 16931";
pdfExportSettings.pdfACompliance = true;
pdfExportSettings.pdfComplianceMode = Stimulsoft.Report.Export.StiPdfComplianceMode.A3;
pdfExportSettings.ZUGFeRDInvoiceData = xmlFilePath;
//Export to PDF
report.exportDocumentAsync(function (pdfData) {
//Save data to file
Stimulsoft.System.StiObject.saveAs(pdfData, "your_file.pdf", "application/pdf");
}, Stimulsoft.Report.StiExportFormat.Pdf, null, pdfExportSettings);
}
// Assigning a report to the Viewer:
viewer.report = report;
</script>
As you can see, I am attaching the file with "SimpleList.xml" so it must also be present in Acrobat Reader.
You can also have the PDF checked online at the following link:
https://belegmeister.de/zugferd-e-rechn ... -anzeigen/
If the function works without any problems for you, then please send me your example of what you used to merge as a project file like I sent you or try to run my project that I sent you, you will see that it doesn't work.
Thanks in advance.
EDIT:
I see what you mean, but the file which gets merged, is not working, see screenshot:
EDIT 2:
I think I know where the problem is, pdfExportSettings.ZUGFeRDInvoiceData only gets a path from me to the XML file, which is then written in by Stimulsoft but not the data of this path.
Edit 3:
I found the problem, it actually has to be a string and not a path as shown in the example above:
If I load it like this:
Code: Select all
function loadXmlFile(filePath) {
return fetch(filePath)
.then(response => {
if (!response.ok) {
throw new Error('err net');
}
return response.text();
})
.catch(error => {
console.error('error fetch: ', error);
});
}
customSaveItem.action = function () {
saveMenu.changeVisibleState(false);
var pdfExportSettings = new Stimulsoft.Report.Export.StiPdfExportSettings();
pdfExportSettings.ZUGFeRDComplianceMode = Stimulsoft.Report.Export.StiPdfZUGFeRDComplianceMode.V2_1;
pdfExportSettings.ZUGFeRDConformanceLevel = "EN 16931";
pdfExportSettings.pdfACompliance = true;
pdfExportSettings.pdfComplianceMode = Stimulsoft.Report.Export.StiPdfComplianceMode.A3;
loadXmlFile(xmlFilePath).then(xmldata => {
pdfExportSettings.ZUGFeRDInvoiceData = xmldata;
report.exportDocumentAsync(function (pdfData) {
Stimulsoft.System.StiObject.saveAs(pdfData, "your_file.pdf", "application/pdf");
}, Stimulsoft.Report.StiExportFormat.Pdf, null, pdfExportSettings);
});
}
It is working with the data in it!