Hello.
I'm trying to generate a PDF from a report, to eventually upload it to a server.
I am using the method Stimulsoft.System.StiObject.saveAs(data, filename + ".pdf", "application/pdf");, but the problem is that the generated PDF is downloaded to local machine.
Is there any method to generate the PDF in code, so that it would eventually be uploaded to a server as a file?
Thank you.
Generate PDF without downloading it (upload to server)
-
- Posts: 7292
- Joined: Tue Mar 20, 2018 5:34 am
Re: Generate PDF without downloading it (upload to server)
Hello,
In that case, you should export report on the server side, for example - node.js
https://github.com/stimulsoft/Samples-J ... 20PDF-file
Thank you.
In that case, you should export report on the server side, for example - node.js
https://github.com/stimulsoft/Samples-J ... 20PDF-file
Thank you.
Re: Generate PDF without downloading it (upload to server)
Hello. I've managed to solve it by making a BLOB and a FILE from the array stream.
In case someone needs it:
In case someone needs it:
Code: Select all
var report = new $window.Stimulsoft.Report.StiReport();
report.load(scope.reportFile.toJSON());
var dataSet = new $window.Stimulsoft.System.Data.DataSet("SimpleDataSet");
dataSet.readJson({ root: data });
var filename = attr.filename || "document"; // custom filename (if such)
report.regData(dataSet.dataSetName, "", dataSet);
report.renderAsync(function() {
var settings = new $window.Stimulsoft.Report.Export.StiPdfExportSettings();
var service = new $window.Stimulsoft.Report.Export.StiPdfExportService();
var stream = new $window.Stimulsoft.System.IO.MemoryStream();
service.exportTo(report, stream, settings);
var data = stream.toArray();
// making a file from Stimulsoft Stream
var blob = new Blob([new Uint8Array(data)], { type: "application/pdf" });
var resultFile = new File([blob], filename + ".pdf", { type: "application/pdf" });
});
Re: Generate PDF without downloading it (upload to server)
Hello,
Thank you for sharing your solution.
Thank you for sharing your solution.