Core Options
PdfEngine / EngineConfig
Section titled “PdfEngine / EngineConfig”import { PdfEngine } from 'nebula-pdf-engine';
const engine = new PdfEngine({ fonts: [ { name: 'Inter', data: fontBuffer, weight: 400, style: 'normal' }, ], devicePixelRatio: 2, assetCache: 'memory', // or 'none'});| Option | Type | Description |
|---|---|---|
fonts |
FontConfig[] |
Required. At least one font buffer |
devicePixelRatio |
number |
Optional. PNG scale factor (default 2) |
assetCache |
'memory' | 'none' |
Optional. Image cache strategy |
imageOptions |
ImageOptions |
Optional. Sharp quality / max dimensions |
FontConfig
Section titled “FontConfig”| Field | Description |
|---|---|
name |
Family name used in styles (fontFamily) |
data |
Buffer or ArrayBuffer of a TTF/OTF file |
weight |
100–900 (default 400) |
style |
'normal' | 'italic' |
generate(element, options?)
Section titled “generate(element, options?)”const pdf: Buffer = await engine.generate(element, { title: 'Q1 Statement', author: 'Billing', subject: 'Customer statement',});| Option | Description |
|---|---|
title |
PDF metadata title |
author |
PDF metadata author |
subject |
PDF metadata subject |
element should be a <Page> or a fragment/wrapper containing one or more <Page>s.