Problem with images when export to PDF

Stimulsoft Reports.JS discussion
Post Reply
agodoo
Posts: 9
Joined: Tue May 22, 2018 10:56 pm

Problem with images when export to PDF

Post by agodoo »

Hello,
I'm using your report.JS version. I have a simple report where I need to insert a company logo in the header.

As I will run and view the report on Apache as a web page, I tried inserting the logo image using the image control, and setting hyperlink as "http://localhost:8080/myapp/reports/logo-report.png"

If I open my report.html page it shows, but when I export the report to pdf with the following code, the image is not present in the PDF.

Code: Select all

        // Create an PDF settings instance. You can change export settings.
        var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
        // Create an PDF service instance.
        var service = new Stimulsoft.Report.Export.StiPdfExportService();

        // Create a MemoryStream object.
        var stream = new Stimulsoft.System.IO.MemoryStream();
        // Export PDF using MemoryStream.
        service.exportTo(report, stream, settings);

        report.reportName = "MyReport";
        report.reportAlias = "MyReport";
        // Get PDF data from MemoryStream object
        var data = stream.toArray();
        // Get report file name
        var fileName = String.isNullOrEmpty(report.reportAlias) ? report.reportName : report.reportAlias;
        // Save data to file
        Object.saveAs(data, fileName + ".pdf", "application/pdf");


How can I fix this problem?

kind regards,
Matteo
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Problem with images when export to PDF

Post by Lech Kulikowski »

Hello,

Please try to use the exportToAsync() method.

Thank you.
Post Reply