Stimulsoft.JS: Exporting to PDF and images

Stimulsoft Reports.JS discussion
Post Reply
thesaurus
Posts: 5
Joined: Wed Nov 02, 2016 4:36 pm

Stimulsoft.JS: Exporting to PDF and images

Post by thesaurus »

Hello,

we are trying to load, render and export a report to a PDF file without showing any controls (like viewer or designer).

Using your sample does not work for embedded images whereas exporting it via the HTML viewer does work.

The programming guide doesn't contain any helpful information on how to make this scenario work.
We tried to have a look at stimulsoft.reports.js, but as it is compressed code, it's really hard to read.

Version: Stimulsoft.JS Trial 2016.3

Reproduction:
Please find the slightly modified Demo example attached.
1)
- Select Images report in left panel
- Click "Save" -> "Adobe PDF File..." in the top toolbar, use default settings
- A PDF will be downloaded. Report contains images as expected
2)
- Select Images report in left panel
- Click the "STIMULSOFT REPORTS JS" image in the top left of the page
- A PDF will be downloaded. Report does not contain images

We have bound a onclick listener to the "STIMULSOFT REPORTS JS" image which executes the sample code for exporting as PD>F from here.

Any help is appreciated. Thank you!
Attachments
Demo.zip
Modified Demo
(3.46 MiB) Downloaded 298 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Stimulsoft.JS: Exporting to PDF and images

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

 function saveReportPdf(report) {
        // 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.exportToAsync(function(){
      // 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");
      
    }, report, stream, settings);
      }
Also, we have some issues. We have added fixes, will be available in the release which will be reloaded on our site within several hours.

Thank you.
Post Reply