Page 1 of 1

Export to PDF using toolbar and code

Posted: Mon Nov 14, 2016 6:24 am
by qiera
I am doing some experiment with this sample https://www.stimulsoft.com/en/samples/j ... ort-to-pdf

i found that you can't export report with image using this method, new pdf will be created but if there are image in that report, the image will be empty,

however you can export correctly using viewer toolbar

attached are the sample report, pdf created using sample method, and pdf created using viewer toolbar export to pdf

we want to export report to pdf via custom button but a lot of our report include one or more image

Re: Export to PDF using toolbar and code

Posted: Wed Nov 16, 2016 6:16 am
by Alex K.
Hello,

Thank you for the sample.
We have found some issues. We need some time to fix the issue. We will let you know about the result.

Thank you.

Re: Export to PDF using toolbar and code

Posted: Fri Nov 18, 2016 12:04 pm
by Alex K.
Hello,

Please try to use the following code:

Code: Select all

var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/test.mrt");
report.render();
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 () {                 
    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);
Thank you.