Node.js SDK reference
The package uses named exports in ESM and CommonJS. TypeScript declarations are bundled with the package.
BladePdf client
| API | Result |
|---|---|
new BladePdf(options) | Configured native BladePDF client and asset resolver. |
BladePdf.fromDependencies({ client, assetResolver }) | SDK using an injected RenderClient and optional resolver. |
fromHtml(html, { baseDirectory? }) | HTML render builder. |
fromTemplate(templateId, context?) | Cloud-template render builder. |
PendingRender
HTML methods are headerHtml() and footerHtml(). Template context methods are context() and mergeContext().
PDF and readiness methods include pdfOptions(), format(), paperSize(), margins(), landscape(), portrait(), printBackground(), transparentBackground(), scale(), pageRanges(), taggedPdf(), preferCssPageSize(), waitForFonts(), outline(), emulateMedia(), waitUntil(), and waitForFunction().
Request methods include reference(), templateName(), metadata(), storePdf(), webhook(), resolveAssets(), assetFile(), and assetData().
Results and submissions
| Method or type | API |
|---|---|
render() / RenderResult | Readonly pdf: Buffer, optional storedPdfUrl/requestId, toBase64(), and asynchronous save(). |
renderStream() / RenderStreamResult | One-shot Node Readable plus optional stored URL and request ID. |
renderToFile() / RenderFileResult | Safely committed path plus optional stored URL and request ID. |
submit() / RenderSubmission | Required requestId and optional reference. |
RenderRequest | Readonly transport snapshot passed to RenderClient implementations and test fakes. |
Errors
Catch BladePdfError. Specific classes are MissingApiKeyError, InvalidRenderConfigurationError, AssetNotFoundError, AssetAccessDeniedError, UnableToWritePdfError, and RenderFailedError.
RenderFailedError exposes readonly statusCode, requestId, responseBody, and standard cause. Its message includes only a bounded response excerpt. Caller cancellation remains a standard AbortError.
Webhook signatures
verifyWebhookSignature() accepts exact raw body bytes, timestamp and signature header values, secret, optional tolerance, and optional current Unix timestamp for deterministic tests.
1const valid = verifyWebhookSignature({
2 rawBody,
3 timestamp: request.headers['bladepdf-timestamp'],
4 signature: request.headers['bladepdf-signature'],
5 secret,
6});