Changing an Export Settings on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.Export settings can be adjusted on the server when the user exports from the viewer, through the onBeginExportReport event.
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.
The event exposes the target format, file name and the format-specific settings object, so you can enforce naming, metadata or security on every export from the server side.
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.
$viewer->onBeginExportReport = function (StiExportEventArgs $args) {
$args->fileName = "MyExportedFileName.$args->fileExtension";
if ($args->format == StiExportFormat::Pdf) {
/** @var StiPdfExportSettings $settings */
$settings = $args->settings;
$settings->creatorString = 'My Company Name';
$settings->embeddedFonts = false;
}
};
$viewer->process();onBeginExportReport— fires on the server when an export starts, before the file is produced.$args->fileName— overrides the name of the exported file.$args->format— identifies the export format so you can branch on it (herePdf).$settings->creatorString / embeddedFonts— format-specific export options applied to the PDF.
The event exposes the target format, file name and the format-specific settings object, so you can enforce naming, metadata or security on every export from the server side.