AG Studio Launch Week 🚀🚀🚀 28 Sep - 2 Oct 2026 🚀🚀🚀 Join now




Core Features

Advanced Features

Angular Data GridPDF Export - Styles

Version 36.2.0
Enterprise

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.

<ag-grid-angular
    [colors]="colors"
    /* other grid options ... */ />

this.colors = {
    headerBackgroundColor: '#123a5a',
    headerTextColor: '#ffffff',
    oddRowBackgroundColor: '#f3f6f8',
};

Export the following example to see the effect of these overrides: the exported PDF uses the configured header and row colours rather than the grid's on-screen theme.

Automatic Grid Styles Copy Link

PDF Export evaluates supported grid style definitions during serialisation:

  1. rowStyle and getRowStyle are applied to the exported row.
  2. colDef.cellStyle is applied to each exported body cell.
  3. colDef.headerStyle is applied to exported header cells.
  4. A cell style overrides the row style for properties supplied by both.
const columnDefs: ColDef[] = [
    {
        field: 'status',
        cellStyle: {
            color: '#b42318',
            fontWeight: 'bold',
        },
    },
];

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.

this.gridApi.exportDataAsPdf({
    skipGridStyles: true,
});

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.

this.gridApi.exportDataAsPdf({
    processStyleCallback: ({ type, value }) => {
        return type === 'cell' && value === 'Late' ? { color: '#b42318', fontWeight: 'bold' } : undefined;
    },
});

Styles returned by processStyleCallback take precedence over automatic grid styles:

  1. A row result overrides rowStyle and getRowStyle for that row.
  2. A cell or rowgroup result overrides the resolved row style and colDef.cellStyle for that cell.
  3. A header or groupheader result overrides colDef.headerStyle for that header.

processStyleCallback still runs when skipGridStyles=true.

Export the following example to see the callback override the "Late" cells with a red, bold style in the PDF:

Text And Box Styles Copy Link

PdfCellStyle supports registered TrueType and built-in PDF fonts, font size, weight and style, text direction, 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. See Languages for custom font registration and Unicode text.

Use defaultCellStyle and defaultHeaderStyle to configure table-wide typography and box styles. defaultCellStyle applies to body cells, including custom content rows. Header and group-header cells use defaultHeaderStyle, with every unset property inherited from defaultCellStyle.

this.gridApi.exportDataAsPdf({
    defaultCellStyle: {
        fontFamily: 'Times-Roman',
        fontSize: 9,
        padding: 4,
    },
    defaultHeaderStyle: {
        fontSize: 10,
    },
    drawCellBorders: true,
});

The cascade is applied separately to each property. For example, if defaultCellStyle.fontSize is 9 and defaultHeaderStyle.fontSize is not set, both body and header cells use 9pt text. Set the header value explicitly when it should differ.

When neither style sets a font size, body cells use 10pt text and headers use 11pt text. Headers derive a bold face from the resolved body font when no font weight is inherited or set.

API Copy Link

Export Options Copy Link

See below the functions on the PdfExportParams interface to customise exported grid values.

colorsCopy Link
PdfColors
Override PDF colours. Any missing values fall back to the current theme.
skipGridStylesCopy Link
boolean
default: false
Set to true to skip applying grid style definitions and callbacks (rowStyle, getRowStyle, colDef.cellStyle, colDef.headerStyle). Use this when you want to rely only on colors and theme defaults.
processStyleCallbackCopy Link
Function
Callback that allows overriding styles for rows, cells, row groups, headers and group headers during PDF export. Returned styles are merged after resolved grid styles and take precedence.
defaultCellStyleCopy Link
PdfCellStyle
default: { fontFamily: 'Helvetica', fontSize: 10, padding: 4 }
Default style applied to every body cell, including custom content rows. Grid styles, row and cell styles, and processStyleCallback results override these values. When no style is provided, body cells use Helvetica at 10 points.
defaultHeaderStyleCopy Link
PdfCellStyle
default: { fontFamily: 'Helvetica-Bold', fontSize: 11, padding: 4 }
Default style applied to header and group-header cells. Each unset property inherits from defaultCellStyle; values set here take precedence. If neither style sets fontSize, headers use 11 points. If no font weight is inherited or set, headers use the bold variant of the resolved body font.
drawCellBordersCopy Link
boolean
default: true
Set to false to skip drawing cell borders.

PdfColors Copy Link

Properties available on the PdfColors interface.

backgroundColorCopy Link
string
default: theme backgroundColor
Background colour for the PDF page.
dataBackgroundColorCopy Link
string
default: theme dataBackgroundColor
Background colour for body rows.
oddRowBackgroundColorCopy Link
string
default: theme oddRowBackgroundColor
Alternate background colour for odd body rows.
foregroundColorCopy Link
string
default: theme foregroundColor
Text colour for body rows.
headerBackgroundColorCopy Link
string
default: theme headerBackgroundColor
Background colour for header rows.
headerTextColorCopy Link
string
default: theme headerTextColor
Text colour for header rows.
borderColorCopy Link
string
default: theme borderColor
Border colour for cell outlines.

PdfCellStyle Copy Link

Properties available on the PdfCellStyle interface.

backgroundColorCopy Link
string
Background colour.
borderColorCopy Link
string
Border colour.
borderWidthCopy Link
number
Border width in points. Defaults to 1 when borderColor is set, otherwise 0.
paddingCopy Link
number | PdfMargin
Padding inside the cell in points. A number applies to all sides.
alignmentCopy Link
PdfTextAlignment
Horizontal alignment for the cell text.
wrapTextCopy Link
boolean
default: false
Whether text should wrap onto multiple lines. Wrapped content increases the row height as required.
preserveLineBreaksCopy Link
boolean
default: true when wrapText is true, otherwise false
Whether explicit line breaks should be preserved.
preserveSpacesCopy Link
boolean
default: false
Whether repeated, leading and trailing spaces should be preserved when text wraps.
maxLinesCopy Link
number
Maximum number of rendered text lines.
overflowCopy Link
PdfTextOverflow
default: 'ellipsis'
How text exceeding the available width, height or line limit is indicated.
fontSizeCopy Link
number
Font size in points.
fontFamilyCopy Link
PdfFontFamily
Font family.
fontWeightCopy Link
PdfFontWeight
Font weight. When omitted, the weight from the resolved font family is preserved.
fontStyleCopy Link
PdfFontStyle
default: 'normal'
Font style.
directionCopy Link
PdfTextDirection
Text direction. auto uses the first strong directional character. When omitted, the export-level direction is used. Text direction does not change exported column order.
languageCopy Link
string
BCP 47 language tag used when selecting language-specific OpenType features. When omitted, the export-level language is used.
string
Text colour.
lineHeightCopy Link
number
Distance between text baselines in points. Defaults to the natural line height from the resolved font metrics, with a minimum of fontSize.