---
title: "PDF Export"
enterprise: true
framework: javascript
version: "36.1.0"
---

# PDF Export

PDF Export creates a paginated PDF representation of grid data without requiring third-party libraries. The export follows the grid's current data state and displayed columns, but it is not a screenshot and does not reproduce every visual feature rendered in the browser.

## Enabling PDF Export

PDF export is available through the [Grid API](https://www.ag-grid.com/javascript-data-grid/grid-api/):

```js
api.exportDataAsPdf();
```

The enterprise [Context Menu](https://www.ag-grid.com/javascript-data-grid/context-menu/) also includes a **PDF Export** item. For module-based builds, register `PdfExportModule` and register `ContextMenuModule` when the menu item is required:

```js
import { ModuleRegistry } from 'ag-grid-community';
import { ContextMenuModule, PdfExportModule } from 'ag-grid-enterprise';

ModuleRegistry.registerModules([
    PdfExportModule,
    ContextMenuModule,
]);
```

Set `suppressPdfExport=true` to disable both `exportDataAsPdf()` and `getDataAsPdf()`.

## Default PDF Export

The export uses the current column order and visibility, together with the filtered, sorted, and grouped row data. Exported values are produced independently of the rendered grid cells:

- Value Getters are used.
- Value Formatters are used by default through [Use Value Formatter for Export](https://www.ag-grid.com/javascript-data-grid/value-formatters/#formatting-for-export).
- Cell Renderer output and HTML are not exported.
- Supported grid styles can be reused, but browser rendering and CSS classes are not copied into the PDF.

Reorder columns or apply filtering and sorting in the following example, then export from the context menu or with the **Export to PDF** button.

#### Default PDF Export

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ContextMenuModule,
  PdfExportModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextFilterModule,
  NumberFilterModule,
  ClientSideRowModelModule,
  PdfExportModule,
  ColumnMenuModule,
  ContextMenuModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    {
      headerName: "Group A",
      children: [
        { field: "athlete", minWidth: 200 },
        { field: "country", minWidth: 200 },
      ],
    },
    {
      headerName: "Group B",
      children: [
        { field: "sport", minWidth: 150 },
        { field: "gold" },
        { field: "silver" },
        { field: "bronze" },
        { field: "total" },
      ],
    },
  ],
  defaultColDef: {
    filter: true,
    minWidth: 100,
    flex: 1,
  },
};

function onBtExport() {
  gridApi!.exportDataAsPdf();
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/small-olympic-winners.json")
  .then((response) => response.json())
  .then(function (data) {
    gridApi!.setGridOption("rowData", data);
  });

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onBtExport = onBtExport;
}
```

[Live example: Default PDF Export](https://www.ag-grid.com/examples/pdf-export/pdf-default-export/typescript/)

By default, regular columns use their current grid widths and the Row Numbers column is sized from its exported content. Columns are proportionally reduced when their combined width exceeds the printable page width. Cells remain on one line unless wrapping is enabled, and table headers repeat when a table continues onto another page.

PDF Export uses the built-in PDF Base 14 fonts with WinAnsi encoding. Characters outside the supported WinAnsi character set are replaced with `?`.

## Support And Limitations

| Area | Supported | Not Supported |
| --- | --- | --- |
| Grid state | Displayed column order and visibility, sorting, filtering, selected-row export options, grouping, pinned rows, column spans | Cell Renderer output or custom HTML |
| Layout | Named and custom page sizes, margins, orientation, column widths, text wrapping, automatic row height, repeated table headers | Automatic page size, horizontal pagination, page headers and footers |
| Styling | Theme colours, `colors`, supported `rowStyle`, `cellStyle`, and `headerStyle` properties, PDF-specific style callbacks | `cellClass`, `cellClassRules`, arbitrary CSS, browser fonts |
| Content | Value Getters, Value Formatters, export value callbacks, document title, additional content, external URI hyperlinks | Images, SVG, internal page links, embedded files |
| Text | Built-in Helvetica, Times, and Courier families; WinAnsi characters | Embedded custom fonts, full Unicode, RTL layout |

## PDF Export Sections

- **[API Reference](https://www.ag-grid.com/javascript-data-grid/pdf-export-api/)**: PDF export methods, grid options, interfaces, and types.
- **[Styles](https://www.ag-grid.com/javascript-data-grid/pdf-export-styles/)**: Reuse supported grid styles and apply PDF-specific overrides.
- **[Extra Content](https://www.ag-grid.com/javascript-data-grid/pdf-export-extra-content/)**: Customise exported values, titles, and additional content.
- **[Rows](https://www.ag-grid.com/javascript-data-grid/pdf-export-rows/)**: Select rows and configure filtered, sorted, and pinned-row export.
- **[Columns](https://www.ag-grid.com/javascript-data-grid/pdf-export-columns/)**: Choose columns, headers, groups, Row Numbers, and widths.
- **[Hyperlinks](https://www.ag-grid.com/javascript-data-grid/pdf-export-hyperlinks/)**: Add external URI links to grid cells and custom content.
- **[Master Detail](https://www.ag-grid.com/javascript-data-grid/pdf-export-master-detail/)**: Include a PDF representation of detail data below master rows.
- **[Page Setup](https://www.ag-grid.com/javascript-data-grid/pdf-export-page-setup/)**: Configure page size, orientation, margins, and repeated table headers.
