Skip to content

Buffers & Responses

PdfEngine.generate() (and NebulaPdfService.generate()) returns a Promise<Buffer> containing the full PDF. There is no streaming / chunked PDF API yet.

import fs from 'fs';
const pdf = await engine.generate(<Page>…</Page>);
fs.writeFileSync('output.pdf', pdf);
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', 'inline; filename="doc.pdf"');
res.send(pdf);
return new Response(pdf, {
headers: {
'Content-Type': 'application/pdf',
'Content-Disposition': 'attachment; filename="doc.pdf"',
},
});

Return the buffer from a controller and set @Header('Content-Type', 'application/pdf'), or use @Res() to write manually.

Each page is rasterized to PNG before assembly. Large tables + high devicePixelRatio increase peak memory. Prefer lowering DPI or splitting huge documents across multiple generate calls if you hit serverless limits.