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.
<script setup lang="ts">
import { Stimulsoft } from 'stimulsoft-reports-js-vuejs'
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, null, settings);
Stimulsoft.System.StiObject.saveAs(pdfData, report.reportAlias + ".pdf", "application/pdf");
}
</script>
<template>
<div class="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 class="container-button">
<button @click="saveReportPdf" class="button" title="Export Report to PDF File">Export to PDF</button>
</div>
</div>
</template>StiPdfExportSettings carries options such as creatorString, embeddedFonts and passwordInputUser; passing it to exportDocumentAsync2 applies them to the generated PDF.