PDF Export uses colours from the active grid theme by default. Use colors to override page, body-row, alternate-row, header, text, and border colours for the exported document.
Automatic Grid Styles Copy Link
PDF Export can evaluate supported grid style definitions during serialisation:
rowStyleandgetRowStyleare applied to the exported row.colDef.cellStyleis applied to each exported body cell.colDef.headerStyleis applied to exported header cells.- A cell style overrides the row style for properties supplied by both.
For function-based cellStyle, the value parameter is the grid's display value before PDF export callbacks process it. This allows existing grid styling logic to continue working when processCellCallback changes the exported text.
Only properties represented by PdfCellStyle are converted. CSS classes, cellClass, cellClassRules, arbitrary CSS, and Cell Renderer styles are not exported.
Set skipGridStyles=true to skip grid style definitions and use only theme defaults, colors, and PDF-specific overrides. This also skips colDef.wrapText and colDef.wrapHeaderText integration.
PDF-Specific Overrides Copy Link
Use processStyleCallback to style exported elements without changing the grid. The callback receives type: 'row' | 'cell' | 'rowgroup' | 'header' | 'groupheader' and the final exported text in value for cell and header elements.
Styles returned by processStyleCallback take precedence over automatic grid styles:
- A
rowresult overridesrowStyleandgetRowStylefor that row. - A
cellorrowgroupresult overrides the resolved row style andcolDef.cellStylefor that cell. - A
headerorgroupheaderresult overridescolDef.headerStylefor that header.
processStyleCallback still runs when skipGridStyles=true.
Text And Box Styles Copy Link
PdfCellStyle supports built-in PDF fonts, font size and weight, text and background colours, borders, padding, alignment, wrapping, explicit line-break preservation, line height, maximum lines, and overflow behaviour. Margin is supported for the document title only.
Use the top-level export parameters to configure document-wide typography and table boxes:
api.exportDataAsPdf({
fontFamily: 'Times-Roman',
headerFontFamily: 'Times-Bold',
fontSize: 9,
headerFontSize: 10,
cellPadding: 4,
drawCellBorders: true,
});