---
product: "AG Grid"
title: "PDF Export - Rows"
description: "PDF Export includes rows after filtering and sorting by default. Export options can select rows, change their order, omit groups, and control pinned rows."
enterprise: true
framework: javascript
version: "36.2.0"
related:
    - title: "Styles"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-styles/"
    - title: "Languages"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-languages/"
    - title: "Extra Content"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-extra-content/"
    - title: "Customising Content"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-customising-content/"
    - title: "Images"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-images/"
    - title: "Watermarks"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-watermarks/"
    - title: "Columns"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-columns/"
    - title: "Hyperlinks"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-hyperlinks/"
    - title: "Master Detail"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-master-detail/"
    - title: "Page Setup"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-page-setup/"
    - title: "API Reference"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/pdf-export-api/"
llms: "https://www.ag-grid.com/archive/36.2.0/llms.txt"
---

# PDF Export - Rows

PDF Export includes rows after filtering and sorting by default. Export options can select rows, change their order, omit groups, and control pinned rows.

## Export Selected Rows

Set `onlySelected=true` to export selected rows. With pagination, use `onlySelectedAllPages=true` to include selections from every page.

```js
api.exportDataAsPdf({
    onlySelected: true,
});
```

## Text Wrapping And Row Height

Cells remain on one line by default. Enable wrapping globally with `defaultCellStyle.wrapText`, per column with `colDef.wrapText`, or per element with `processStyleCallback`.

```js
api.exportDataAsPdf({
    defaultCellStyle: {
        wrapText: true,
        maxLines: 3,
    },
});
```

Without a fixed height, rows grow to fit wrapped content and can continue across pages. An explicit `rowHeight` or `headerRowHeight` fixes the available height and clips overflowing text.

Supported `white-space` values returned by `cellStyle` are also translated into wrapping, line-break preservation, and space preservation.

## Row Order

The default `exportedRows='filteredAndSorted'` follows the displayed row order. Use `'all'` to export the original unfiltered and unsorted row set.

```js
api.exportDataAsPdf({
    exportedRows: 'all',
});
```

Selection and `shouldRowBeSkipped` can still remove rows from this set.

## Row Groups

Row groups are exported with indentation based on their displayed level. Set `rowGroupIndentSize` to change the indentation, or `skipRowGroups=true` to omit group rows.

```js
api.exportDataAsPdf({
    rowGroupIndentSize: 12,
});
```

## Pinned Rows

Pinned top and bottom rows are exported by default. Use `skipPinnedTop` or `skipPinnedBottom` to omit them.

Manually pinned rows can also appear in the body. Set `skipPinnedRowDuplicates=true` to keep only their pinned copies.

```js
api.exportDataAsPdf({
    skipPinnedTop: true,
    skipPinnedRowDuplicates: true,
});
```

#### Wrapping, Grouping And Pinning

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  PdfColumnWidthCallback,
  PdfExportParams,
  PinnedRowModule,
  RowAutoHeightModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ContextMenuModule,
  PdfExportModule,
  RowGroupingModule,
} from "ag-grid-enterprise";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  PinnedRowModule,
  RowAutoHeightModule,
  RowGroupingModule,
  ContextMenuModule,
  PdfExportModule,
]);

interface ProjectData {
  division: string;
  team: string;
  project: string;
  summary: string;
  owner: string;
  budget: number;
}

const rowData: ProjectData[] = [
  {
    division: "Product",
    team: "Grid",
    project: "Column Tooling",
    summary: "Improve column workflows.\nAdd keyboard controls.",
    owner: "Ava",
    budget: 185000,
  },
  {
    division: "Product",
    team: "Grid",
    project: "PDF Export",
    summary:
      "Deliver paginated reports with configurable widths, wrapping, styling, and extra content.",
    owner: "Mateo",
    budget: 240000,
  },
  {
    division: "Product",
    team: "Charts",
    project: "Financial Series",
    summary:
      "Add range, volume, and technical-indicator workflows for financial dashboards.",
    owner: "Priya",
    budget: 210000,
  },
  {
    division: "Operations",
    team: "Cloud",
    project: "Regional Hosting",
    summary:
      "Expand regional hosting capacity while keeping deployment and monitoring consistent.",
    owner: "Noah",
    budget: 320000,
  },
  {
    division: "Operations",
    team: "Support",
    project: "Service Portal",
    summary:
      "Consolidate customer requests, service status, and escalation history into one portal.",
    owner: "Mei",
    budget: 145000,
  },
];

let gridApi: GridApi<ProjectData>;

const columnWidth: PdfColumnWidthCallback = ({ column }) =>
  column?.getColId() === "summary" ? 190 : "auto";

const gridOptions: GridOptions<ProjectData> = {
  columnDefs: [
    { field: "division", rowGroup: true, hide: true },
    { field: "team", rowGroup: true, hide: true },
    { field: "project", minWidth: 180 },
    { field: "summary", minWidth: 260, wrapText: true, autoHeight: true },
    { field: "owner" },
    {
      field: "budget",
      valueFormatter: (params) => `$${Number(params.value).toLocaleString()}`,
    },
  ],
  defaultColDef: { flex: 1, minWidth: 110 },
  autoGroupColumnDef: { headerName: "Portfolio", minWidth: 220 },
  groupDefaultExpanded: -1,
  rowData,
  pinnedTopRowData: [
    {
      division: "",
      team: "",
      project: "Approved Portfolio",
      summary: "Current approved programme of work",
      owner: "Leadership",
      budget: 1100000,
    },
  ],
  pinnedBottomRowData: [
    {
      division: "",
      team: "",
      project: "Contingency",
      summary: "Unallocated portfolio contingency",
      owner: "Finance",
      budget: 125000,
    },
  ],
  defaultPdfExportParams: {
    rowGroupIndentSize: 16,
    defaultCellStyle: {
      overflow: "ellipsis",
    },
    columnWidth,
  },
};

function getPdfExportParams(): PdfExportParams {
  const includeTop =
    document.querySelector<HTMLInputElement>("#includeTop")!.checked;
  const includeBottom =
    document.querySelector<HTMLInputElement>("#includeBottom")!.checked;
  const limitLines =
    document.querySelector<HTMLInputElement>("#limitLines")!.checked;

  return {
    rowGroupIndentSize: 16,
    skipPinnedTop: !includeTop,
    skipPinnedBottom: !includeBottom,
    defaultCellStyle: {
      maxLines: limitLines ? 2 : undefined,
      overflow: "ellipsis",
    },
    columnWidth,
  };
}

function onPdfExportOptionsChanged() {
  gridApi.setGridOption("defaultPdfExportParams", getPdfExportParams());
}

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

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

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

[Live example: Wrapping, Grouping And Pinning](https://www.ag-grid.com/archive/36.2.0/examples/pdf-export-rows/pdf-wrapping-grouping-pinning/typescript/)

## Choose Rows Programmatically

Use `rowPositions` to export specific row positions, or `shouldRowBeSkipped` to omit rows conditionally.

```js
api.exportDataAsPdf({
    shouldRowBeSkipped: ({ node }) => node.data?.status === 'Archived',
});
```

#### PDF Export - Rows

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  PdfExportParams,
  PinnedRowModule,
  RowApiModule,
  RowSelectionModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, PdfExportModule } from "ag-grid-enterprise";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  PinnedRowModule,
  RowApiModule,
  RowSelectionModule,
  TextFilterModule,
  ContextMenuModule,
  PdfExportModule,
]);

interface ProjectData {
  id: string;
  employee: string;
  team: string;
  country: string;
  status: string;
}

const rowData: ProjectData[] = [
  {
    id: "p1",
    employee: "Asha Patel",
    team: "Grid",
    country: "United Kingdom",
    status: "Active",
  },
  {
    id: "p2",
    employee: "Marc Dubois",
    team: "Charts",
    country: "France",
    status: "Planning",
  },
  {
    id: "p3",
    employee: "Sofia Rossi",
    team: "Grid",
    country: "Italy",
    status: "Active",
  },
  {
    id: "p4",
    employee: "Noah Williams",
    team: "Cloud",
    country: "United States",
    status: "Planning",
  },
  {
    id: "p5",
    employee: "Mei Chen",
    team: "Support",
    country: "Singapore",
    status: "Active",
  },
  {
    id: "p6",
    employee: "Lucas Silva",
    team: "Grid",
    country: "Brazil",
    status: "Archived",
  },
];

let gridApi: GridApi<ProjectData>;

const gridOptions: GridOptions<ProjectData> = {
  columnDefs: [
    { field: "employee", minWidth: 170 },
    { field: "team" },
    { field: "country", minWidth: 150 },
    { field: "status" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 110,
    filter: true,
  },
  getRowId: (params) => params.data.id,
  rowSelection: {
    mode: "multiRow",
    headerCheckbox: false,
  },
  rowData,
  pinnedTopRowData: [
    {
      id: "top",
      employee: "Quarterly Plan",
      team: "All Teams",
      country: "Global",
      status: "Summary",
    },
  ],
  pinnedBottomRowData: [
    {
      id: "bottom",
      employee: "Project Total",
      team: "4 Teams",
      country: "6 Countries",
      status: "Summary",
    },
  ],
  onFirstDataRendered: () => {
    gridApi.getRowNode("p1")?.setSelected(true);
    gridApi.getRowNode("p3")?.setSelected(true);
  },
  defaultPdfExportParams: {
    columnWidth: "auto",
  },
};

function isChecked(id: string): boolean {
  return document.querySelector<HTMLInputElement>(`#${id}`)!.checked;
}

function getPdfExportParams(): PdfExportParams {
  return {
    onlySelected: isChecked("onlySelected"),
    exportedRows: isChecked("allRows") ? "all" : "filteredAndSorted",
    skipPinnedTop: isChecked("skipPinnedTop"),
    skipPinnedBottom: isChecked("skipPinnedBottom"),
    columnWidth: "auto",
  };
}

function onPdfExportOptionsChanged() {
  gridApi.setGridOption("defaultPdfExportParams", getPdfExportParams());
}

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

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

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

[Live example: PDF Export - Rows](https://www.ag-grid.com/archive/36.2.0/examples/pdf-export-rows/pdf-export-rows/typescript/)

## API

### Export Options

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

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `defaultCellStyle` | `PdfCellStyle` |  |  |  |
| `rowGroupIndentSize` | `number` |  |  |  |
| `rowHeight` | `number` |  |  |  |
| `headerRowHeight` | `number` |  |  |  |
| `rowPositions` | `RowPosition[]` |  |  |  |
| `exportedRows` | `'all' \| 'filteredAndSorted'` |  |  |  |
| `onlySelected` | `boolean` |  |  |  |
| `onlySelectedAllPages` | `boolean` |  |  |  |
| `skipRowGroups` | `boolean` |  |  |  |
| `skipPinnedTop` | `boolean` |  |  |  |
| `skipPinnedBottom` | `boolean` |  |  |  |
| `skipPinnedRowDuplicates` | `boolean` |  |  |  |
| `shouldRowBeSkipped` | `Function` |  |  |  |

### ShouldRowBeSkippedParams

Properties available on the `ShouldRowBeSkippedParams&lt;TData = any, TContext = any&gt;` interface.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `node` | `IRowNode` |  |  |  |
| `api` | `GridApi` |  |  |  |
| `context` | `TContext` |  |  |  |

### RowPosition

Properties available on the `RowPosition` interface.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `rowIndex` | `number` |  |  |  |
| `rowPinned` | `RowPinnedType` |  |  |  |
