Exporting a Report from Code with Changing Export Settings
Our sample projects and report templates can help you learn the basics of working with our products.Export output can be tuned through a settings object. This example exports to PDF while adjusting metadata, font embedding and a user password.
Exporting the document. Load and render the report, configure the requested export format, and deliver the generated bytes as a file, stream, or web response.
Exporting the document. Load and render the report, configure the requested export format, and deliver the generated bytes as a file, stream, or web response.
import { Stimulsoft } from 'stimulsoft-reports-js-react';
async function saveReportPdf() {
var report = new Stimulsoft.Report.StiReport();
report.loadFile('Reports/SimpleList.mrt');
await report.renderAsync2();
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
settings.creatorString = 'My Company Name';
settings.keywordsString = 'SimpleList Report Export';
settings.embeddedFonts = false;
settings.passwordInputUser = '123';
var pdfData = await report.exportDocumentAsync2(Stimulsoft.Report.StiExportFormat.Pdf, undefined, settings);
Stimulsoft.System.StiObject.saveAs(pdfData, report.reportAlias + '.pdf', 'application/pdf');
}
function App() {
return (
<div className='container'>
<h4>This example shows how to export a report to a PDF file and adjust the export settings via code. Please, enter the password <b>123</b> to show report</h4>
<div className='container-button'>
<button onClick={saveReportPdf} className='button' title='Export Report to PDF File'>
Export PDF
</button>
</div>
</div>
);
}
export default App;StiPdfExportSettings carries options such as creatorString, embeddedFonts and passwordInputUser; passing it to exportDocumentAsync2 applies them to the generated PDF.