Integration • JavaScript and TypeScript

Node.js PDF API

Connect PrefillPDF to Next.js, Express, NestJS, serverless functions, queues, and TypeScript applications.

Node.js applications can call PrefillPDF from server routes, backend services, workers, and serverless functions.
Use structured JSON to generate a completed document, or send an existing PDF and continue with extracted JSON in your application.

Common Node.js workflows

Next.js API route

Receive form or database data, call PrefillPDF on the server, and return a PDF response or URL.

Upload and extract

Accept an uploaded PDF, send it for extraction, and store the normalized fields in your application.

Queue-based generation

Generate documents through background jobs to support larger workloads and retries.

How the integration works

1

Create a server-side request

Keep API credentials on the server and call PrefillPDF with fetch, Axios, or another HTTP client.

2

Send document input

Use JSON for generation or file/multipart input for extraction.

3

Handle the result

Parse JSON responses, stream files, or save the result to object storage.

4

Add retries and logging

Track failed jobs and retry transient errors in production workflows.

Node.js request example

const response = await fetch("https://api.prefillpdf.com/fill-pdf", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PREFILLPDF_API_KEY}`,
    "Content-Type": "application/json",
    Accept: "application/json",
  },
  body: JSON.stringify({
    template_id: "your-template-id",
    data: {
      customer_name: "Jane Smith",
      amount: 25000,
    },
  }),
});

if (!response.ok) {
  throw new Error(`PrefillPDF request failed: ${response.status}`);
}

const result = await response.json();

Benefits of using PrefillPDF with Node.js

Natural fit for Next.js and TypeScript
Works in serverless and traditional servers
Supports queues and background workers
Easy connection to modern SaaS applications

FAQ

Should I call PrefillPDF from the browser?

No. Keep your API key private and call PrefillPDF from a server route, backend service, or serverless function.

Can I use this in Next.js App Router?

Yes. Use a Route Handler, server action, or backend service function depending on your architecture.

Can Node.js process extraction JSON before saving it?

Yes. Validate, transform, normalize, and enrich the returned data before storing it.

Build your Node.js PDF workflow

Generate PDFs from structured data or extract structured JSON from existing documents with PrefillPDF.