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

# PDF Export - Rows

PDF Export includes rows after the grid's filtering and sorting by default. Export parameters can select rows, use the unprocessed row order, exclude pinned rows, or choose rows programmatically.

## Export Selected Rows

Set `onlySelected=true` to export selected rows instead of every row in the current export set.

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

When using pagination, set `onlySelectedAllPages=true` to include selected rows from every page.

## Text Wrapping And Row Height

Cells, including numeric cells, remain on one line by default. Set `wrapText=true` for all exported cells, use `colDef.wrapText` or `colDef.wrapHeaderText`, or return `wrapText: true` from `processStyleCallback` for an individual PDF element.

PDF Export also translates CSS white-space properties returned by `cellStyle`. For example, `white-space: normal` enables wrapping, `white-space-collapse: preserve-breaks` preserves explicit line breaks without wrapping, and `white-space: pre-line` enables both behaviours. The `pre`, `pre-wrap`, and `break-spaces` values also preserve repeated, leading, and trailing spaces. The equivalent PDF-specific properties are `preserveLineBreaks` and `preserveSpaces`.

Wrapped text breaks on whitespace and falls back to character-level wrapping for words wider than the cell. Explicit newline characters start distinct lines when wrapping is enabled. `lineHeight` defaults to the resolved font size, `maxLines` is unlimited by default, and `overflow` defaults to `'ellipsis'`.

When `rowHeight` is omitted, each row grows to its tallest cell. An automatically sized row that is taller than the printable area continues across pages, with its backgrounds and borders repeated for each fragment. An explicit `rowHeight` or `headerRowHeight` is a fixed clipping boundary and does not grow or continue onto another page. Use `maxLines` when a line-count limit is preferable to a fixed height.

## Export All Unprocessed Rows

The default `exportedRows='filteredAndSorted'` exports rows after filtering and sorting, in their displayed order. Set `exportedRows='all'` to ignore filtering and sorting and export rows in their original order.

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

> **Note**
>
> `exportedRows='all'` controls which rows form the export set. Options such as `onlySelected` and `shouldRowBeSkipped` can still remove rows from that set.

## Row Groups

Row-group labels are indented according to their displayed depth. Use `rowGroupIndentSize` to configure the indentation in points; `processRowGroupCallback` changes the exported label independently.

Set `skipRowGroups=true` to omit row-group rows from the export.

## Pinned Rows

Pinned top and bottom rows are exported by default. Set `skipPinnedTop` or `skipPinnedBottom` to omit the corresponding pinned section.

Manually pinned rows also remain in the exported body by default. Set `skipPinnedRowDuplicates=true` to omit those body copies while retaining the rows in their pinned sections.

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

The example below demonstrates wrapped rows, group indentation, line limits, and pinned-row sections.

#### Wrapping, Grouping And Pinning

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

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  PinnedRowModule,
  RowAutoHeightModule,
  RowGroupingModule,
  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 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,
    },
  ],
};

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

  gridApi.exportDataAsPdf({
    rowGroupIndentSize: 16,
    skipPinnedTop: !includeTop,
    skipPinnedBottom: !includeBottom,
    maxLines: limitLines ? 2 : undefined,
    overflow: "ellipsis",
    columnWidth: ({ column }) =>
      column?.getColId() === "summary" ? 190 : "auto",
  });
}

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).onBtExport = onBtExport;
}
```

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

## Choose Rows Programmatically

Use `rowPositions` to export explicit row positions, or `shouldRowBeSkipped` to decide whether each row in the export set should be omitted.

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

The example below combines selected-row export, processed or unprocessed row order, and pinned-row controls.

#### PDF Export - Rows

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

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  PinnedRowModule,
  RowApiModule,
  RowSelectionModule,
  TextFilterModule,
  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);
  },
};

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

function onBtExport() {
  const params: PdfExportParams = {
    onlySelected: isChecked("onlySelected"),
    exportedRows: isChecked("allRows") ? "all" : "filteredAndSorted",
    skipPinnedTop: isChecked("skipPinnedTop"),
    skipPinnedBottom: isChecked("skipPinnedBottom"),
    columnWidth: "auto",
  };

  gridApi.exportDataAsPdf(params);
}

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).onBtExport = onBtExport;
}
```

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