I use js from node.
I have tried different way to do it.
with image variable, and with json datasource.
In designer preview mode is ok, when i export to pdf no image is inside.
Code: Select all
const Stimulsoft = require("stimulsoft-reports-js");
const report = new Stimulsoft.Report.StiReport();
/* if i not set a font the report is outputted as a garbage font (the font is standard arial) */
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(reportPath + "/reports/Roboto-Black.ttf");
/*load report*/
report.loadFile(reportPath + "/reports/TestReport.mrt");
/* try to setting image into variable*/
const image = Stimulsoft.Base.Drawing.StiImageConverter.stringToImage(associazione.blobImage);
report.dictionary.variables.getByName("imageHeader").valueObject = image;
/*try to use datasource */
/*
var dbsimpleImage = report.dictionary.databases.getByName("simpleImage");
dbsimpleImage.pathData = "C:\\Progetti\\arco\\arco-api.v2\\uploads\\reports\\simpleImage.json";
*/
const dssimpleImage = new Stimulsoft.System.Data.DataSet();
dssimpleImage.readJsonFile("simpleImage.json");
report.regData("simpleImage", null, dssimpleImage);
// Renreding report
report.render();
console.log("Report rendered. Pages count: ", report.renderedPages.count);
const pdfData = report.exportDocument(Stimulsoft.Report.StiExportFormat.Pdf);
// Converting Array into buffer
const buffer = Buffer.from(pdfData);
// File System module
const fs = require("fs");
// Saving string with rendered report in PDF into a file
fs.writeFileSync(generatedFileName, buffer);
Report
json
pdf outputted