Prompt

How do I fill out PDF forms with data from my database?

Technology / Developer Tools1 observationLast seen Oct 12, 2026

Latest observation

Oct 12, 2026OpenAI APIWeb search: off

You typically do this in one of two ways:

1) Fill a PDF form template programmatically

If the PDF already has form fields (AcroForm), you can load it, map database values to field names, and save a filled copy.

Common tools

  • Python: pypdf, pdfrw, PyMuPDF
  • Java: iText, PDFBox
  • Node.js: pdf-lib
  • .NET: iText, PDFsharp, Syncfusion, Telerik

Basic workflow

  1. Get the record from your database.
  2. Open the PDF form template.
  3. Set each field value by field name.
  4. Save the filled PDF.
  5. Optionally flatten the form so it can’t be edited.

Example in Python with pypdf

from pypdf import PdfReader, PdfWriter

# Example database record
data = {
    "first_name": "Ada",
    "last_name": "Lovelace",
    "email": "ada@example.com"
}

reader = PdfReader("template.pdf")
writer = PdfWriter()
writer.clone_document_from_reader(reader)

# Fill form fields
writer.update_page_form_field_values(writer.pages[0], {
    "FirstName": data["first_name"],
    "LastName": data["last_name"],
    "Email": data["email"]
})

# Write output
with open("filled.pdf", "wb") as f:
    writer.write(f)

2) Generate the PDF from scratch

If your PDF is not an interactive form, you can create a new PDF and place text at fixed positions.

Common tools

  • Python: ReportLab
  • Java: PDFBox, iText
  • Node.js: pdfkit, puppeteer
  • .NET: QuestPDF, iText

This is better when:

  • You control the layout
  • The document isn’t an existing form
  • You want full automation and consistency

Important considerations

Field names

PDF form field names must match exactly. You can inspect them with tools like:

  • pdftk template.pdf dump_data_fields
  • pdfinfo/qpdf
  • script-based field enumeration

Flattening

If you want the values to be non-editable:

  • Flatten after filling, or
  • Save as a static PDF

Fonts and appearance

Sometimes filled fields look blank in some PDF viewers unless appearance streams are updated. Many libraries have options like:

  • regenerate appearances
  • auto-appearance
  • flatten form

Special field types

  • Checkboxes/radio buttons need the correct on-value
  • Dropdowns must use valid option values
  • Multi-line text fields may need wrapping or font sizing

Typical architecture

  1. User requests a document.
  2. Backend fetches DB record.
  3. Backend fills PDF template.
  4. Return PDF as download or store it in S3/blob storage.

If you tell me:

  • your language/framework
  • whether the PDF is an existing form or a custom document
  • your database type

…I can give you a ready-to-run example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.