@nestjsforge/pdfme
PdfmeService API
Complete API reference for PdfmeService methods.
generate
Generates a PDF document from a template and input data. Returns a Uint8Array containing the PDF binary.
const pdf: Uint8Array = await this.pdfme.generate({
template: myTemplate,
inputs: [
{ fieldA: 'value1', fieldB: 'value2' },
{ fieldA: 'page2value', fieldB: 'page2b' }, // Multiple pages
],
options: {
font: { NotoSansBold: { data: boldFontBuffer, fallback: false } }, // Per-call font override
},
});generateWithFonts
Generates a PDF with additional per-call font overrides merged with the global font configuration:
const pdf = await this.pdfme.generateWithFonts(
{ template, inputs },
{ CustomFont: { data: customFontBuffer, fallback: false } }
);validate
Validates a template and input data against the schema definitions without generating a PDF. Returns a validation result.
const result = await this.pdfme.validate({ template, inputs });
if (!result.valid) {
console.error('Validation errors:', result.errors);
}| Method | Signature | Description |
|---|---|---|
| generate | generate(params): Promise | Generate PDF from template and inputs |
| generateWithFonts | generateWithFonts(params, fonts): Promise | Generate with per-call font overrides |
| validate | validate(params): Promise | Validate template and inputs |