Fill existing PDF templates with JavaScript. Set up a PDF template, send data to Anvil, and get back a completed PDF — no manual entry required.
import fs from 'fs'
import Anvil from '@anvilco/anvil'
const pdfTemplateID = 'kA6Da9CuGqUtc6QiBDRR'
const apiKey = '7j2JuUWmN4fGjBxsCltWaybHOEy3UEtt'
const exampleData = {
"title": "My PDF Title",
"fontSize": 10,
"textColor": "#CC0000",
"data": {
"someFieldId": "Hello World!"
}
}
const anvilClient = new Anvil({ apiKey })
const {
statusCode,
data
} = await anvilClient.fillPDF(pdfTemplateID, exampleData)
console.log(statusCode) // => 200
// Data will be the filled PDF raw bytes
fs.writeFileSync('output.pdf', data, { encoding: null })
The @anvilco/anvil package is MIT-licensed and maintained in the open on GitHub.
$ npm install @anvilco/anvilInstall the Anvil Document SDK plugin in Claude Code and Claude will scaffold the SDK into your codebase — discovery, planning, and production-ready code.
/plugin marketplace add anvilco/anvil-plugins
/plugin install anvil-document-sdk@anvil-pluginsNo API key setup needed. The plugin connects to your Anvil account with OAuth and logs you in automatically.
Instantly fill your PDF templates with JSON data. Try an example below and see documentation when ready to fill your own.