All articles

How to Programmatically Fill PDF Forms in 2026 (Libraries vs APIs Compared)

By Ardalan Foroughi, founder of Filly AI · August 16, 2026

How to Programmatically Fill PDF Forms in 2026 (Libraries vs APIs Compared)

Filling a PDF form from code is a solved problem, right up until the forms start changing. The mechanics are a few lines; the cost is everything around them. This compares the real options and is honest about which one you should pick — including the cases where the answer is not a library at all, and not this site's product either.

For a fixed set of forms with real AcroForm fields, use a library: pdf-lib in JavaScript or PDFtk Server from the command line, both free. Use Anvil's API if you would rather not own the field mapping. Use an AI filler only when the forms vary, arrive as scans, or need a human to check values before filing. The deciding factor is almost never the code — it is who maintains the field map when the agency reissues the form.

The options at a glance

OptionInterfaceFills existing AcroForm fieldsHandles a PDF with no fieldsCost
pdf-libJavaScript / TypeScript libraryYesNo — you draw text at coordinates yourselfFree, MIT
PDFtk ServerCommand line (FDF/XFDF)YesNoFree, GPL v2 — $995 to redistribute
AnvilREST / GraphQL, plus SDKsYes, via a hosted template of your PDFOnly with its Document AI, or you draw fields by handMetered from $0.10 per fill; AI Pack $99/mo
Zapier / MakeNo-code workflowNot natively — via a third-party appNoZapier free 100 tasks/mo; Make from ~$10.59/mo monthly-billed
Filly AIWeb app — no public APIYes, no field map neededYes, via OCRFree plan; from $19/month

Start here: does the PDF actually have form fields?

Everything downstream depends on this and it takes ten seconds to check. A PDF with an AcroForm layer has named, addressable fields; a scan or a flattened export has nothing but pixels. Every library in this comparison writes into named fields, so on a flat PDF they have nothing to write into. Your options there are to stamp text at fixed coordinates — brittle the moment the layout shifts by a few points — or to use something that reads the page and places values by position.

This single question eliminates most of the confusion in threads about "why won't pdf-lib fill my form."

pdf-lib and PDFtk: free, and the right answer more often than not

pdf-lib is MIT-licensed, pure JavaScript, and runs in Node or the browser: load the document, get the form, set field values, save. PDFtk Server is GPL v2 and does the same from a shell with FDF or XFDF data — its own page puts it plainly: the command-line PDFtk has been, and always will be, free software. Redistributing it inside your own product is the case that costs $995.

No hosted copy of your documents, no per-fill fee, no vendor to depend on. For a fixed set of forms this is genuinely hard to beat, and most teams reaching for an API would be better served here.

The cost nobody quotes: the field map

Writing to a known field is trivial. Knowing which field is which is the work. Real government and enterprise PDFs carry field names like topmostSubform[0].Page1[0].f1_07[0], and somebody has to decide that this one is the applicant's middle name. That mapping is per-form, and it is not durable: when an agency reissues a form the names move, and the code silently fills the wrong boxes rather than erroring.

That maintenance is invisible when you are shipping the first form and dominant by the twentieth. It is the honest reason to consider a hosted service or an AI filler — not because the filling is hard, but because the mapping never stops.

Anvil: pay to not own the mapping

Anvil's model is that you upload the PDF, it builds a template with named fields, and you POST JSON against that template's ID to get a filled PDF back. Official SDKs cover Node, Python and C#.

Two things to know before designing around it. First, you are filling Anvil's template derived from your PDF, not the file itself — data keys correspond to field aliases in that template rather than the PDF's own field names, and Anvil's documentation notes imported names often arrive unhelpfully named and worth renaming. Second, on a non-fillable upload Anvil states its system will not detect fields at all: you draw them yourself, or use its Document AI. So the field-mapping work does not vanish, it moves into their dashboard — done once, in a UI, rather than in your code.

On pricing, read carefully: the free plan is dashboard-only for filling, and API filling is metered from $0.10 per fill, with the AI Pack at $99/month. Anvil's own pages currently carry more than one figure for this, so confirm against your account rather than a marketing page.

Where an AI filler belongs — and where it doesn't

To be straightforward about our own product, since this is a developer question: Filly has no public API. If you want a filled PDF produced automatically when a record changes, Filly is the wrong tool and you should use a library or Anvil. Nothing in this section changes that.

What an AI filler is actually for is the case that breaks the others — compared against the other fillers here: forms that vary, arrive as scans with no field layer, and carry values a human must check before anything is filed. There is no field map to write because the model reads the form and works out which field wants which detail, and OCR places values on pages that have no fields at all. That is a different problem from "fill these three known forms ten thousand times a day," which a library does better, more cheaply, and without a vendor.

How to choose

  1. Fixed forms, real AcroForm fields, you have a developer: pdf-lib or PDFtk. Free, and you own it.
  2. Fixed forms, but you do not want to maintain the field map: Anvil.
  3. The data lives in another system and must move first: Zapier or Make for the movement, plus one of the above for the filling.
  4. Forms vary, arrive scanned, or need human review: an AI filler — but not via an API, because it does not have one.
  5. High volume of three known forms: a library, every time. Per-fill pricing at scale is the expensive way to solve a cheap problem.

Frequently asked questions

Why won't pdf-lib fill my form?

Almost always because the PDF has no AcroForm layer — it is a scan or a flattened export, so there are no named fields to set. Check for a form layer first. If there is none, either stamp text at coordinates or use a tool that reads the page with OCR.

Is PDFtk really free for commercial use?

The command-line PDFtk Server is free software under GPL v2, which covers using it. Redistributing it inside a product you ship is the case its vendor sells a $995 redistribution licence for. Read the licence against your own distribution model rather than taking a summary's word for it.

Can I fill a PDF from Zapier without code?

Not with Zapier's own native steps. PDF.co publishes a "fill PDF form fields" action inside Zapier and PDF4me publishes a "Fill a PDF Form" module for Make, so it is possible — through a second tool, with its own pricing. The CRM, ATS and HR comparison goes through that path in detail, including the split between filling an existing PDF and generating a new document.

What breaks when a government agency reissues a form?

Field names change, and code that maps to them fills the wrong boxes without raising an error. This is the failure worth designing against: pin the form edition you tested, and check the output rather than trusting the run. It is also the strongest argument against a hand-written field map for a large form set.

How current are these prices?

Taken from each vendor's own pricing page in August 2026, with the billing basis stated because several vendors show annual and monthly figures in the same view. Verify against a live quote before you commit.

Fill any form in seconds

Try Filly AI free — no credit card required.

Get started

We use optional analytics and advertising-measurement cookies to understand product usage and see which ads bring people to Filly. This includes a masked replay of your visit — layout and clicks only, never what you type or the contents of a document. You can accept, or continue with essential-only. Privacy policy.