Data Grid PDF export
What it does
Section titled “What it does”toPdf(grid, options?) writes a Data Grid’s view as a PDF document (Promise<Blob>), with our own PDF writer: no dependencies, nothing uploaded. For paper, the grid’s own print() prints a real table without a file.
import { DataGrid } from '@absoluteui/components/data-grid';import { toPdf } from '@absoluteui/components/data-grid/pdf';
interface Invoice { id: string; total: number;}
const host = document.createElement('div');host.style.setProperty('block-size', '200px');document.body.append(host);const grid = DataGrid.create<Invoice>(host, { label: 'Invoices', rows: [{ id: 'INV-1', total: 120 }], rowId: (r) => r.id, columns: [ { id: 'id', header: 'Invoice', field: 'id' }, { id: 'total', header: 'Total', field: 'total', type: 'number' }, ],});const blob = await toPdf(grid, { title: 'Invoices', pageSize: 'a4', orientation: 'landscape' });console.log(blob.type, blob.size);Behavior
Section titled “Behavior”- Pages carry the title, the column group and header rows repeated on every page, bold group and total rows, end-aligned numbers, and “Page n of N”.
- A4 or Letter (
pageSize), landscape by default (orientation), withmargin,fontSize, andpageLabel(“Page {page} of {pages}”); the grid’s column widths are scaled down to fit the page. - Latin text uses the standard PDF fonts. Other scripts need
fonts: { regular, bold }(TrueType or OpenType bytes): the fonts are embedded with a ToUnicode map so text can be searched and copied, and fonts whose license forbids embedding are refused.parseFontreads a font’s tables. - Right-to-left grids mirror the columns.
visualOrder(text, rtl)is the simplified bidirectional ordering used for right-to-left text (not the full Unicode algorithm; no Arabic shaping). - The document properties carry the title (shown as the window title) and the grid’s language.
Errors
Section titled “Errors”- Invalid options throw a
TypeErrorthat names the property (“Invalid PDF export: … must be …”). - A font that cannot be read or may not be embedded throws “Invalid PDF font: …”.
API reference
Section titled “API reference”General
Section titled “General”Functions
Section titled “Functions”toPdf
The grid as a PDF Blob: the toCsv row and column choices, column widths scaled to the page, header rows
repeated on every page, bold group and total rows, end-aligned numbers, and page numbers. More than 100,000
rows throws. The PDF is not tagged: assistive technology reads the text in reading order; for structure,
prefer the grid itself, CSV, or Excel.
function toPdf<Row>(grid: DataGrid<Row>, options?: DataGridPdfOptions): Promise<Blob>;visualOrder
Simplified bidirectional ordering for right-to-left text: runs of right-to-left letters are reversed and the runs are laid out from the right; digits and Latin runs keep their order. Not the full Unicode algorithm; no Arabic shaping.
function visualOrder(text: string, rtl: boolean): string;Interfaces
Section titled “Interfaces”DataGridPdfOptions
interface DataGridPdfOptions extends Omit<DataGridExportOptions, 'text'> { readonly title?: string; readonly pageSize?: 'a4' | 'letter'; readonly orientation?: 'portrait' | 'landscape'; readonly margin?: number; readonly fontSize?: number; readonly fonts?: { readonly regular: Uint8Array | ArrayBuffer; readonly bold?: Uint8Array | ArrayBuffer; }; readonly rightToLeft?: boolean; readonly columnGroups?: boolean; readonly pageLabel?: string;}Functions
Section titled “Functions”parseFont
Parse a TrueType or OpenType font (throws for other files or fonts whose license forbids embedding).
function parseFont(input: Uint8Array): ParsedFont;winAnsiByte
The WinAnsi byte of a code point, or null when the standard fonts cannot show it.
function winAnsiByte(cp: number): number | null;Interfaces
Section titled “Interfaces”ParsedFont
The parts of a TrueType or OpenType font the writer needs.
interface ParsedFont { readonly bytes: Uint8Array; readonly cff: boolean; readonly unitsPerEm: number; readonly ascent: number; readonly descent: number; readonly capHeight: number; readonly bbox: readonly [number, number, number, number]; readonly italicAngle: number; readonly name: string; glyph(cp: number): number; advance(glyph: number): number;}PdfFont
A font the writer can use: its PDF resource, how to measure, and how to encode text.
interface PdfFont { width(text: string, size: number): number; encode(text: string): string;}(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.