Hello!
I am trying to include SVG images in a PDF report using the NodeJS libraries (i have the feb 2020 library). The PDF report is rendered without any issues , but the image is not included - that part of the page is just empty. I tried the same with png/jpg/gif images and did not encounter any issue.
If I generate the PDF file from the Angular designer (using the same .mrt), the SVG file is shown successfully, which would point that svgs are supported in the Reports.JS , I just see this issue in NodeJS.
Can you please confirm that svg files are indeed supported in the NodeJS library, and if there is anything special I should do (any PDF export settings?) to have them included in my PDF reports.
Thank you !
Include SVG image in PDF reports - NodeJS
-
- Posts: 6
- Joined: Mon Apr 27, 2020 7:02 am
Re: Include SVG image in PDF reports - NodeJS
Hello, Cristian.
It seems that you should use the async methods to render and export the report.
Please, look at this sample:
https://github.com/stimulsoft/Samples-J ... e/index.js
Thank you.
It seems that you should use the async methods to render and export the report.
Please, look at this sample:
https://github.com/stimulsoft/Samples-J ... e/index.js
Thank you.
-
- Posts: 6
- Joined: Mon Apr 27, 2020 7:02 am
Re: Include SVG image in PDF reports - NodeJS
I tried to use the async methods, as shown in the provided link , but the result is the same. I am attaching here a sample .mrt file (that contains just a svg on a blank page) and the code that generates an empty PDF file. I am using the following version : "stimulsoft-reports-js@2020.2.1"
The same .mrt file shows the correct svg image while exported from the Designer.
NodeJS code:
The same .mrt file shows the correct svg image while exported from the Designer.
NodeJS code:
Code: Select all
var report = new Stimulsoft.Report.StiReport();
report.loadFile("error-svg.mrt");
report.renderAsync(() => {
report.exportDocumentAsync((pdfData) => {
var buffer = Buffer.from(pdfData)
var fs = require('fs');
fs.writeFileSync('./ErrorSvg.pdf', buffer);
}, Stimulsoft.Report.StiExportFormat.Pdf);
});
- Attachments
-
- error-svg.mrt
- (4.8 KiB) Downloaded 138 times
Re: Include SVG image in PDF reports - NodeJS
Hello.
We are sorry, it's impossible to export SVG images to PDF in node.js.
There is no necessary API.
Thank you.
We are sorry, it's impossible to export SVG images to PDF in node.js.
There is no necessary API.
Thank you.
-
- Posts: 6
- Joined: Mon Apr 27, 2020 7:02 am
Re: Include SVG image in PDF reports - NodeJS
Hello,
Thank you for your reply!
In this case, it is currently unclear for me why the Angular designer supports exporting SVG images in reports ? From what i can see the same libraries are used, I'm not sure why NodeJS wouldn't work in this case.
Can you please let me know what necessary API you are referring to ? Is this a Stimulsoft API that is missing in the NodeJS library (not implemented yet), or an external dependency that is preventing svg files to be exported, such as another library.
Either way, are there any plans to add 'svg' support in the near future ?
Thank you.
Thank you for your reply!
In this case, it is currently unclear for me why the Angular designer supports exporting SVG images in reports ? From what i can see the same libraries are used, I'm not sure why NodeJS wouldn't work in this case.
Can you please let me know what necessary API you are referring to ? Is this a Stimulsoft API that is missing in the NodeJS library (not implemented yet), or an external dependency that is preventing svg files to be exported, such as another library.
Either way, are there any plans to add 'svg' support in the near future ?
Thank you.
Re: Include SVG image in PDF reports - NodeJS
Hello.
We are using the HTMLCanvasElement.toDataURL() method.
It is not available in node.js and we don't have plans to add it in the nearest feature.
Thank you.
We are using the HTMLCanvasElement.toDataURL() method.
It is not available in node.js and we don't have plans to add it in the nearest feature.
Thank you.