@spoolpdf/sdk-node
v0.1.0
Published
Official Node.js client for the spoolpdf HTML/URL to PDF API
Maintainers
Readme
@spoolpdf/sdk-node
Official Node.js client for POST /v1/render. Defaults to production https://spoolpdf-api.nandra.dev.
Install
npm install @spoolpdf/sdk-nodeRequires Node 18+.
Usage
import { SpoolPdfClient } from "@spoolpdf/sdk-node";
import { writeFileSync } from "node:fs";
const client = new SpoolPdfClient({
apiKey: process.env.SPOOLPDF_API_KEY!,
});
const pdf = await client.render({
html: "<h1>Hello spoolpdf</h1>",
format: "A4",
print_background: true,
});
writeFileSync("out.pdf", pdf);Local Compose API:
const client = new SpoolPdfClient({
apiKey: process.env.SPOOLPDF_API_KEY!,
baseUrl: "http://localhost:8080",
});Create a key at spoolpdf.nandra.dev/keys.
Client API
new SpoolPdfClient({ apiKey, baseUrl?, fetchImpl? })render(input)— PDF bytes (Uint8Array)renderWithMeta(input)—{ bytes, meta: { requestId, usageCount, contentType } }SpoolPdfErroron non-2xx (status,code,requestId,body)
Exactly one of html or url is required. Prefer html for speed and to avoid ssrf_blocked on private hosts.
License
MIT
