Skip to content

RevoGrid PDF Export

Export RevoGrid data to clean, shareable PDF files with a small browser-side plugin powered by pdfmake.

@revolist/revogrid-pdf-export is a lightweight add-on package for teams that need a practical PDF export button without building a full reporting pipeline. It reads visible RevoGrid data, preserves column headers, respects trimmed or filtered rows, and creates a simple pdfmake document definition that can be downloaded, previewed, uploaded, or customized.

Add-on package

PDF export is delivered as a separate package. Core RevoGrid includes CSV export through the built-in export plugin. Excel-focused export workflows are available in RevoGrid Pro.

Why use it

  • Lightweight client-side PDF export for RevoGrid.
  • Works through the standard RevoGrid plugin API.
  • Exports visible rows and visible columns.
  • Supports grouped column headers.
  • Lets you download a PDF, return a browser Blob, or access the pdfmake document definition.
  • Provides a cancelable beforepdfexport hook for customization.
  • Keeps the first version focused: fast to adopt, easy to reason about, and simple to extend.

Install

sh
npm install @revolist/revogrid-pdf-export

The package expects RevoGrid to be present in your app. Install RevoGrid separately if your project does not already use it:

sh
npm install @revolist/revogrid

Quick start

Register ExportPdfPlugin in the grid plugin list, then retrieve the plugin instance with getPlugins().

ts
import { ExportPdfPlugin } from '@revolist/revogrid-pdf-export';

const grid = document.querySelector('revo-grid');

if (grid) {
  grid.plugins = [ExportPdfPlugin];

  const plugins = await grid.getPlugins();
  const pdf = plugins.find(plugin => plugin instanceof ExportPdfPlugin);

  await pdf?.exportPdf({
    filename: 'orders.pdf',
    title: 'Orders',
  });
}

API

exportPdf(options?)

Creates and downloads a PDF file.

ts
await pdf.exportPdf({
  filename: 'orders.pdf',
  title: 'Orders Report',
});

exportBlob(options?)

Creates a PDF and returns it as a browser Blob. Use this when you want to upload, preview, store, or handle the file yourself.

ts
const blob = await pdf.exportBlob({
  title: 'Orders Report',
});

getDocumentDefinition(options?)

Returns the pdfmake document definition before a PDF is created. Use this when you want full control over the final pdfmake rendering step.

ts
const definition = await pdf.getDocumentDefinition({
  pageOrientation: 'portrait',
});

Options

OptionTypeDefaultDescription
filenamestringrevogrid-export.pdfDownload filename. .pdf is added automatically when omitted.
titlestringRevoGrid ExportTitle shown above the exported table.
pageOrientation'portrait' | 'landscape'landscapePDF page orientation.
includeColumnHeadersbooleantrueIncludes the column header row.
includeGroupHeadersbooleantrueIncludes grouped column header rows when present.
maxRowsnumberunlimitedLimits exported data rows.
tableLayoutstringlightHorizontalLinespdfmake table layout name.

Customize the PDF

The plugin emits a cancelable beforepdfexport event with { data, documentDefinition, options }.

Use it to adjust the pdfmake document definition, add metadata, change styles, add headers or footers, or stop the export.

ts
grid.addEventListener('beforepdfexport', event => {
  event.detail.documentDefinition.info = {
    title: 'Orders Report',
    subject: 'Monthly order export',
  };

  event.detail.documentDefinition.footer = currentPage => ({
    text: `Page ${currentPage}`,
    alignment: 'center',
    fontSize: 8,
  });
});

Call event.preventDefault() to cancel the export.

What gets exported

The plugin focuses on data, not pixel-perfect rendering. It exports:

  • visible row data
  • visible columns
  • column names
  • grouped column headers
  • filtered or trimmed grid state through RevoGrid's visible source APIs

It does not attempt to reproduce custom cell renderers, DOM styling, images, row headers, pinned layout visuals, or editor UI. This keeps the PDF output small and predictable.

Framework usage

The plugin is framework-agnostic. Use it anywhere you can pass RevoGrid plugins:

When to use each export option

RequirementRecommended option
Simple CSV data exportCore CSV export
Browser-side PDF table export@revolist/revogrid-pdf-export
Excel workbook export/importRevoGrid Pro Excel export
Fully custom report layoutUse getDocumentDefinition() and customize pdfmake output