There are two ways to get a worksheet out of the browser and onto paper, and one page-setup model that drives both. This page is the map — pick the route that matches the output you need.
Note: Printing, PDF export, and page layout are all Pro-edition features.
Pick your route
| You want to… | Route | One-liner |
|---|---|---|
| Open the browser’s print dialog now | Print to HTML | printWorksheet(grid.worksheet) |
| Produce a real PDF file | Print to PDF | grid.saveAsPdf({ locale: 'ja' }) |
| Set paper size, margins, page breaks | Page Layout | ws.setPrintSettings({ paperSize: 'A4' }) |
How to print
Step 1 — set up the page (optional, but do it for anything multi-page)
Paper size, orientation, margins, and scale live on the worksheet, and the on-screen page-break preview shows exactly where pages will split. Both output routes can reuse this model, so configuring it once keeps the screen, the print dialog, and the PDF in agreement.
const ws = grid.worksheet
ws.setPrintSettings({ paperSize: 'A4', orientation: 'landscape', scale: 1 })
ws.setShowPageBreaks(true) // Excel-style page-break preview on the grid
ws.insertRowPageBreak(40) // force a new page at row 40
→ Full reference: Page Layout
Step 2 — choose an output
A. Print to HTML — the sheet is converted to a styled HTML table and handed to the browser’s native print dialog. Nothing to install, no font to load; the user can also choose “Save as PDF” inside the dialog.
import { printWorksheet } from '@reogrid/pro'
printWorksheet(grid.worksheet, { usePageBreaks: true })
→ Options and details: Print to HTML
B. Print to PDF — the sheet is rendered to a real, vector PDF by our own engine: text, borders, fills, merges, and cell-anchored images, with a TrueType font embedded. No dialog, no server, no external library.
import { preloadPdfFont } from '@reogrid/pro'
await preloadPdfFont('ja') // once — a font is required, and export stays sync
grid.saveAsPdf({ locale: 'ja', usePageBreaks: true, filename: 'report.pdf' })
→ Options and details: Print to PDF
Which one should I use?
| Print to HTML | Print to PDF | |
|---|---|---|
| Output | Browser print dialog | A .pdf file (or raw bytes) |
| Entry point | printWorksheet(ws, options) | grid.saveAsPdf(options) / grid.exportPdf(options) |
| User interaction | Dialog is shown; the user confirms | Silent — downloads or returns bytes |
| Fonts | The browser’s fonts | The locale’s font, or bytes you supply (required) |
| Pagination | usePageBreaks: true, or one long table | usePageBreaks: true, or option-driven paging |
| Cell-anchored images | Not drawn | Drawn (showImages) |
| Custom cell types | Only with renderHTML() | Rendered by the PDF engine |
| Server round-trip | None | None |
| Best for | Ad-hoc printing, “just print this” buttons | Invoices, ledgers, archived or emailed documents |
Rule of thumb: if the result is a document you keep, attach, or send, use PDF. If the user just wants paper out of the printer in front of them, the HTML route is one line and needs no font.
Saving as PDF from the browser’s print dialog is not the same as PDF export: the browser re-lays out the HTML table, may add its own headers and footers, and substitutes fonts. Use Print to PDF when the output has to be exact.
Related samples
- PDF & Page Layout demo — a multi-page sales report with the page-break preview on and an Export PDF button (Japanese font included).
- Recipe: Export a PDF — the shortest working path from grid to PDF file.
- Recipe: Fill a Report Template — design a form with
{{token}}cells, bind data, then print or export it.
Related articles
- ReoGrid Web v1.4 — page layout, print-perfect PDF export, and Excel-grade data features — where the paging model and the PDF engine came from.
- When Excel is your layout tool: move merged-cell forms to the web — bringing print-oriented Excel forms to the browser without rebuilding them.
Related docs
- Page Layout — paper size, margins, scale, manual breaks, page-break preview.
- PDF Export — the full
ExportPdfOptionsreference. - Print to HTML — the full
PrintOptionsreference. - XLSX Import & Export — page setup travels with the file, so Excel paginates it the same way.