exportToPdfDocument method

PdfDocument exportToPdfDocument(
  1. SfDataGrid dataGrid,
  2. List<DataGridRow>? rows
)

Exports the SfDataGrid to PdfDocument.

If the rows is set, the given list of DataGridRow collection is exported. Typically, you can set this property to export

Implementation

PdfDocument exportToPdfDocument(
    SfDataGrid dataGrid, List<DataGridRow>? rows) {
  final PdfDocument pdfDocument = PdfDocument();

  //adding page into pdf document
  final PdfPage pdfPage = pdfDocument.pages.add();

  _exportHeaderFooter(pdfPage, pdfDocument.template);

  //export pdf grid into pdf document
  final PdfGrid pdfGrid = exportToPdfGrid(dataGrid, rows);

  //Draw the pdf grid into pdf document
  pdfGrid.draw(page: pdfPage, bounds: Rect.zero);

  return pdfDocument;
}