Keep the document definition#
Supported text, named styles, tables, and header/footer definitions follow a familiar model. The same definition can be passed to each engine, but line metrics and pagination can differ.
const definition = {
content: [
{ text: 'Invoice', bold: true, fontSize: 18 },
{ table: { widths: ['*', 100], body: [
['Description', 'Amount'], ['Consulting', 'USD 100.00']
] } }
]
};How the implementations differ#
| Area | MinkPDF | pdfmake 0.3.13 |
|---|---|---|
| Engine | Own layout, pagination, TrueType subsetting, and PDF serialization | Uses PDFKit, linebreak, and xmldoc as runtime package dependencies |
| Entry points | Built ESM; full root or core + optional feature factories | Client build and server entry point; separate default font assets for the browser |
| Capabilities | Select report, graphics, font, security, and output capabilities at engine construction | Broader document-definition surface |
| Document creation | createPdf(definition) | createPdf(definition, options?) in 0.3 |
| Binary output | await getBuffer() → Uint8Array | Promise-based buffer, Blob, base64, data URL, and stream methods |
| Download / open / print | print(target?); standalone downloadPdf() and openPdf() adapters | Client methods download(), open(), and print() |
| Server file output | writePdf(document, path) through the Node adapter | write(path) on the server-side document |
| Fonts | ASCII Helvetica by default; register TrueType bytes or base64 for Unicode | Default browser setup includes Roboto virtual font assets; custom fonts supported |
pdfmake sources: 0.3.13 manifest, browser setup, client methods, and server setup.
Adapt the output step#
pdfmake · browser bytes
import pdfMake from 'pdfmake/build/pdfmake.js';
import pdfFonts from 'pdfmake/build/vfs_fonts.js';
pdfMake.addVirtualFileSystem(pdfFonts);
const bytes = await pdfMake
.createPdf(definition).getBuffer();MinkPDF · browser bytes
import pdf from 'minkpdf';
// ASCII + built-in Helvetica
const bytes = await pdf
.createPdf(definition).getBuffer();
// Embed a TrueType font for Unicode.For downloads, replace pdfMake.createPdf(definition).download('invoice.pdf') with getBlob() and an object URL. The complete browser example includes cleanup. Browser print(target?) supports the same preopened-window pattern as pdfmake 0.3. Standalone adapters expose downloadPdf(), openPdf(), and writePdf(). Documents expose getStream(); select streaming() for incremental serialization with backpressure. See the feature compatibility guide for caching and memory limits.
Register files explicitly#
For a matching font, supply the same TrueType bytes and variants to both engines. In MinkPDF, map virtual filenames to bytes or base64, then register the font dictionary and set defaultStyle.font.
pdf.addVirtualFileSystem({ 'Inter-Regular.ttf': fontBytes });
pdf.addFonts({ Inter: { normal: 'Inter-Regular.ttf' } });
const document = pdf.createPdf({
defaultStyle: { font: 'Inter' },
content: 'José García · ₱100'
});addFonts() merges families; assigning pdf.fonts replaces them. Register every variant your document uses. Supply local or fetched bytes yourself; URL and filesystem font fetching are not part of MinkPDF’s registration API.
Compatibility at a glance#
| Document capability | MinkPDF status |
|---|---|
| Styled text, stacks, columns, named styles | Supported · optional reports adds justification and style inheritance |
| Tables, repeated headers, row/column spans, custom layouts | Supported · spans cannot cross the repeated-header boundary |
| Page breaks, headers/footers, metadata, watermarks | Supported · optional graphics adds shapes |
| TrueType fonts and searchable Unicode text | Supported · requires a font containing the characters |
| PNG / JPEG base64 data URLs | Supported · PNG limits are documented in the API |
| Absolute/relative positioning, per-side margins, named colors | Supported · positioned nodes do not advance flow |
| SVG, QR codes, lists | Optional factories · declared SVG subset |
| Attachments, encryption, PDF/A | Optional factories · R6 AES-256; PDF/A-2b and PDF/A-3b |
| Semantic tagging / PDF/UA-1 | Optional profile · human accessibility review required |
| Complex-script shaping | Outside the API |
| Pixel-identical layout with pdfmake | Not guaranteed · metrics and pagination differ |
Before switching an application#
- Inventory the document features and output helpers your app uses.
- Check the supported types, colors, image formats, and font variants.
- Match each required capability to the historical root or explicit feature factories; advanced features are not all included by the root.
- Adapt downloads, file writes, and any callback-based output handling.
- Render representative real documents. Check text, totals, page breaks, and visual output.
- Measure your own workload. Use the recorded benchmarks as a reference, not a prediction.