Keep your HTML
Render EJS, Handlebars, Pug, Nunjucks, React SSR, or plain HTML inside your application and pass the result to the SDK.
Puppeteer is the right tool when you need general browser automation. BladePDF is a focused alternative for server-side PDF generation: your application sends HTML and the managed service operates Chromium.
import { BladePdf } from '@bladepdf/node';
const bladePdf = new BladePdf({
apiKey: process.env.BLADEPDF_API_KEY!,
});
await bladePdf
.fromHtml(html)
.format('A4')
.printBackground()
.renderToFile('invoice.pdf');
A Puppeteer PDF call is concise, but production owns everything below it: a compatible Chrome binary, Linux libraries, fonts, sandboxing, process cleanup, crash recovery, memory limits, concurrency, and serverless packaging.
BladePDF removes that runtime from your Node.js deployment. It is not a browser testing or scraping library. It is a managed HTML-to-PDF boundary for applications that do not need arbitrary page automation.
Render EJS, Handlebars, Pug, Nunjucks, React SSR, or plain HTML inside your application and pass the result to the SDK.
Your app owns data and templates. BladePDF owns browser installation, isolation, capacity, recovery, and updates.
Configure paper, margins, backgrounds, headers, footers, readiness, storage, metadata, and delivery without a general browser surface.
Both examples take an existing HTML string and write an A4 PDF. The difference is where Chromium runs and who is responsible for its lifecycle.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setContent(html, {
waitUntil: 'networkidle0',
});
await page.pdf({
path: 'invoice.pdf',
format: 'A4',
printBackground: true,
});
} finally {
await browser.close();
}
import { BladePdf } from '@bladepdf/node';
const apiKey = process.env.BLADEPDF_API_KEY;
if (!apiKey) throw new Error('Missing API key');
const bladePdf = new BladePdf({ apiKey });
await bladePdf
.fromHtml(html)
.format('A4')
.printBackground()
.renderToFile('invoice.pdf');
@bladepdf/node is server-only and requires Node.js 22 or later. Keep the API key in server-side environment configuration. If you need page clicks, selectors, request interception, scraping, screenshots, or browser tests, keep Puppeteer for those workflows.
Both use Chromium-quality rendering. Choose according to the control you need and the infrastructure you want to own.
Puppeteer exposes a general browser automation API and is a strong choice when PDF generation depends on custom navigation or page-level behavior.
BladePDF is a focused choice when your application has HTML and needs reliable PDF output, but a browser platform is not part of the product you want to operate.
The SDK changes where Chromium runs. It does not move your template engine, database access, or business rules into BladePDF.
Load application data and render EJS, React, Handlebars, Nunjucks, or another server-side template exactly where it lives today.
Set page options and let the SDK attach local files from explicitly configured filesystem roots when the document needs them.
BladePDF renders in managed Chromium and returns a Buffer, Node.js stream, atomic file result, or stored asynchronous job.
The important difference is not CSS fidelity—both paths use Chromium. It is the surface area your application must deploy, secure, observe, and scale.
| Capability | Self-hosted Puppeteer | BladePDF Node SDK |
|---|---|---|
| Runtime | Node.js, Puppeteer, compatible Chrome, OS libraries, fonts, and writable runtime directories | Node.js 22+ and the zero-runtime-dependency SDK; Chromium runs in BladePDF |
| Browser API | General page automation and Chrome DevTools Protocol access | Focused HTML-to-PDF options, readiness controls, assets, storage, and delivery |
| Concurrency | Build a queue, cap pages, size memory, apply back pressure, and recover browser processes | Use plan concurrency; excess short bursts can wait in the managed render queue |
| Serverless | Package a compatible Chromium build and account for cold starts, bundle size, memory, and temp space | Deploy the SDK and make an outbound API request; no browser binary in the function |
| Local assets | Embed them, expose reachable URLs, or make the browser filesystem boundary explicit | Attach referenced files from approved roots and rewrite their document references |
| Security | Own the sandbox, egress, request interception, debugging endpoints, and untrusted HTML policy | Use a constrained PDF API; BladePDF operates the isolated browser environment |
| Data boundary | HTML and assets can remain fully inside your infrastructure | HTML and attached assets are processed by the BladePDF service |
| Cost model | Your compute plus engineering and operations time | Hosted service plan based primarily on rendering capacity |
BladePDF is not a drop-in replacement for Puppeteer's complete API. It replaces the setContent() plus page.pdf() workload when a deliberate, managed PDF boundary is a better production architecture.
Install @bladepdf/node, configure a server-side API key, and render the first PDF.
Configure local asset roots, transport timeouts, retries, custom fetch, and dependency injection.
Explore sources, PDF options, delivery methods, errors, background jobs, and webhook helpers.
Read the engineering guide to browser reuse, concurrency, memory, serverless deployment, and security.
Read the guide →See the complete official SDK surface for HTML, local assets, streams, files, and background renders.
Read the guide →Generate PDFs from Express, Fastify, Next.js, React SSR, EJS, or your existing template engine.
Read the guide →fromHtml(). BladePDF does not replace your template engine.renderStream() for a one-shot Node.js Readable, render() for a Buffer result, renderToFile() for atomic file output, or storePdf().submit() for a background render.documentRoot and searchRoots values and the SDK can attach referenced local files to the request. External URLs remain external and must be reachable by the renderer.Keep your Node.js templates and replace one Puppeteer PDF path with the managed SDK.
npm install @bladepdf/node