Exporting a Report to PDF
Our sample projects and report templates can help you learn the basics of working with our products.Render the report in Angular and export it directly from code, without opening the viewer.
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.
@Component({
selector: "exporting-report-to-pdf",
template: `
<div class="container">
<h4>This sample demonstrates how to export a report to a PDF file and save it:</h4>
<div class="container-button">
<button (click)="saveReportPdf()" class="button" title="Export Report to PDF File">Export to PDF</button>
</div>
</div>
`,
styleUrls: ['../styles.css']
})
export class ExportingReportToPDF {
async saveReportPdf() {
var report = new Stimulsoft.Report.StiReport();
report.loadFile("Reports/SimpleList.mrt");
await report.renderAsync2();
var pdfData = await report.exportDocumentAsync2(Stimulsoft.Report.StiExportFormat.Pdf);
Stimulsoft.System.StiObject.saveAs(pdfData, report.reportAlias + ".pdf", "application/pdf");
}
}exportDocumentAsync2(StiExportFormat.Pdf) produces the PDF data after rendering, and StiObject.saveAs downloads it as application/pdf.