Include SVG image in PDF reports - NodeJS

Stimulsoft Reports.JS discussion
Post Reply
cristian.craciun
Posts: 6
Joined: Mon Apr 27, 2020 7:02 am

Include SVG image in PDF reports - NodeJS

Post by cristian.craciun »

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 !
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Include SVG image in PDF reports - NodeJS

Post by HighAley »

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.
cristian.craciun
Posts: 6
Joined: Mon Apr 27, 2020 7:02 am

Re: Include SVG image in PDF reports - NodeJS

Post by cristian.craciun »

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:

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
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Include SVG image in PDF reports - NodeJS

Post by HighAley »

Hello.

We are sorry, it's impossible to export SVG images to PDF in node.js.
There is no necessary API.

Thank you.
cristian.craciun
Posts: 6
Joined: Mon Apr 27, 2020 7:02 am

Re: Include SVG image in PDF reports - NodeJS

Post by cristian.craciun »

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.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Include SVG image in PDF reports - NodeJS

Post by HighAley »

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.
Post Reply