Using a Custom Font
Our sample projects and report templates can help you learn the basics of working with our products.A single custom font file can be added to the engine and used in a report. This example loads one font and embeds it in the exported PDF.
Registering the resource. Load or register the external resource before rendering so the finished report remains portable across environments.
Registering the resource. Load or register the external resource before rendering so the finished report remains portable across environments.
var Stimulsoft = require('stimulsoft-reports-js');
Stimulsoft.Base.StiFontCollection.addFontFile('./Font/LongCang-Regular.ttf');
var report = new Stimulsoft.Report.StiReport();
report.loadFile('SimpleList.mrt');
report.renderAsync(() => {
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
settings.embeddedFonts = true;
report.exportDocumentAsync((pdfData) => {
fs.writeFileSync('./SimpleList.pdf', Buffer.from(pdfData));
}, Stimulsoft.Report.StiExportFormat.Pdf, null, settings);
});addFontFile registers an individual font file with the engine; combined with the embeddedFonts export setting, the font is baked into the PDF so the document looks the same on every machine.