Angular Spreadsheet PDF Export
The Spreadsheet provides built-in support for exporting the active worksheet to a PDF file directly from the browser. The export renders the sheet content, including cell values, formatting, and column widths, as a print-ready PDF document.
The following example demonstrates the PDF export feature with a products inventory Spreadsheet. In the File menu, click the Export as PDF... option to download the file. Use the configuration panel to adjust the export settings before downloading.
Configuring the Export
To control the PDF output, bind a PDFExportSettings object to the pdfExportSettings input. The object lets you specify the paper size and orientation, page margins, whether the content should scale to fit the page width, the name of the downloaded file, and the document title metadata.
Use fileName to control the name of the downloaded file. If not set, the file is saved as 'Workbook.pdf' by default. You can also set the title property to embed a descriptive title in the PDF document metadata, which PDF readers display in the document properties panel. If title is not set, it defaults to the value of fileName.
public pdfExportSettings: PDFExportSettings = {
paperSize: 'A4',
landscape: true,
margin: '1cm',
fitWidth: false,
title: 'Products Inventory',
fileName: 'Products-Inventory.pdf'
};Setting the Page Layout
The layout properties control how the sheet content renders on the PDF page. You can set the paper size, orientation, and margins independently to match your printing requirements.
Paper Size
Use paperSize to set the paper dimensions. The property accepts a SpreadsheetPaperSize string for standard sizes such as 'A4' or 'Letter', or a [width, height] array in points for custom dimensions. The default value is 'A4'.
// Standard paper size
public pdfExportSettings: PDFExportSettings = { paperSize: 'A4' };
// Custom dimensions in points (width × height)
public pdfExportSettings: PDFExportSettings = { paperSize: [595, 842] };
Orientation
Set landscape to false to switch to portrait orientation. The default is landscape, which suits most wide Spreadsheet layouts.
public pdfExportSettings: PDFExportSettings = {
paperSize: 'A4',
landscape: false
};
Margins
Use margin to control the whitespace around the content. It accepts a string with units ("mm", "cm", "in", "pt"), a plain number in points, or a PDFMargin object when you need different values for each side. The default is '1cm'.
// Uniform margin
public pdfExportSettings: PDFExportSettings = { margin: '1.5cm' };
// Per-side margin
public pdfExportSettings: PDFExportSettings = {
margin: {
top: '2cm',
bottom: '2cm',
left: '1cm',
right: '1cm'
}
};
Fitting and Scaling Content
When your sheet has more columns than can fit within the selected paper size, use fitWidth to automatically scale the content down so the entire row fits on a single page. This is the quickest way to avoid columns being clipped or wrapping to a second page. When fitWidth is true, the scale property is ignored.
For more precise control, use scale directly. A value of 0.8 renders the content at 80% of its original size, which is useful when you need a consistent reduction across all sheets regardless of their width.
// Fit the sheet to the page width
public pdfExportSettings: PDFExportSettings = {
paperSize: 'A4',
fitWidth: true
};
// Or apply a fixed scale instead
public pdfExportSettings: PDFExportSettings = {
paperSize: 'A4',
scale: 0.8
};