Page 1 of 1
PDF export in Node with a report accessing databases
Posted: Wed May 10, 2017 4:00 pm
by rafa_ariadna
Has anyone experimented exporting to PDF in Node with a report that access databases?
The example that Stimultsoft gives, is a report that loads information from a JSON file, but I can't do the same with a report that access databases.
By the way, How can we access in node, attributes like report.dictionary.databases.list or report.dataSources.items? Because I use them to build database connection and sql string, but it seems that node module (stimulsoft-reports-js) doesn't create report object with that attributes.
Thank you.
Re: PDF export in Node with a report accessing databases
Posted: Fri May 12, 2017 7:21 am
by Alex K.
Re: PDF export in Node with a report accessing databases
Posted: Fri May 12, 2017 9:24 am
by rafa_ariadna
Hi Aleksey, thank you for your replay.
In Node there isn't StiOptions.WebServer.url option. I'm talking about a project rendered inside Node not HTML, as the example in
https://github.com/stimulsoft/Samples-J ... 20PDF-file but not loading JSON, accessing a database instead.
Thank you.
Re: PDF export in Node with a report accessing databases
Posted: Fri May 12, 2017 1:09 pm
by Alex K.
Hello,
Yes, please check the following sample which shows how to connect to the database:
https://github.com/stimulsoft/Samples-J ... p%20Server
Thank you.
Re: PDF export in Node with a report accessing databases
Posted: Fri Jun 09, 2017 10:24 am
by payoff
Hello,
I've the same issue. I'm trying to generate a pdf in node calling it from a .net core application but the resulting pdf are empty. Here the code
https://gist.github.com/roadrunner75/f3 ... 434afead43
Thanks in advance
Andrea
Re: PDF export in Node with a report accessing databases
Posted: Fri Jun 09, 2017 2:57 pm
by payoff
I found the way
report.dictionary.databases.clear();
report.dictionary.databases.add(new Stimulsoft.Report.Dictionary.StiPostgreSQLDatabase("BloxSQL", "BloxSQL", connectionString));
report.dictionary.synchronize();
report.renderAsync(function () {
// export to memory stream
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
var service = new Stimulsoft.Report.Export.StiPdfExportService();
var stream = new Stimulsoft.System.IO.MemoryStream();
service.exportTo(report, stream, settings);
var data = stream.toArray();
var buffer = new Buffer(data, "utf-8");
// store into a file
var fs = require("fs");
fs.writeFileSync(compiledReportPath, buffer);
callback(/* error */null, "DONE");
});
Re: PDF export in Node with a report accessing databases
Posted: Mon Jun 12, 2017 7:04 pm
by Alex K.
Hello
Ok.
Please let us know if you need any additional help.
Thank you.