Other PDF Issues

How to Fill a PDF Template from a SQL Database in Acrobat

Emma BrownEmma Brown Nov 3, 2026 869 views

Question details

Seeking a method to connect a PDF document directly to a SQL database to dynamically populate text and image fields.

How to Fill a PDF Template from a SQL Database
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Automating document composition by dynamically pulling text and image records from a SQL database into a PDF layout.
Observed behavior
Adobe Acrobat lacks a built-in workflow to natively connect to a SQL database and dynamically expand document fields out of the box.
Before you start

Standard desktop versions of PDF editors cannot establish direct, active connections to SQL databases. You will need to utilize a custom server-side application, an enterprise-grade document generation system, or a spreadsheet-based mail merge workaround.

Solution 1Recommended

Build a Custom Server-Side Document Generation Application

Use backend programming languages and PDF libraries to query your database and inject the data into a pre-configured PDF template.

Since standard desktop PDF clients cannot pull directly from SQL, developers typically bridge the gap using server-side libraries (such as iText, PDFtk, or Python's ReportLab). The application queries the database and programmatically injects the data into the PDF fields.

1
Create a Base PDF Template

Design your initial document and add interactive form fields (text boxes, image placeholders) using your preferred PDF editor.

2
Develop the Database Connection Script

Write a backend script using a language like Python, Node.js, or C# that establishes a secure connection to your SQL database.

3
Execute the SQL Query

Configure your script to run a SQL SELECT statement to retrieve the specific text strings and image file paths needed for the document.

4
Merge Data and Generate PDF

Use a server-side PDF manipulation library within your script to map the retrieved database values to the corresponding PDF form fields, then output the final flattened PDF file.

Build a Custom Server-Side Document Generation Application
Development Required: This method requires programming knowledge and a hosting environment to run the database query and PDF generation scripts.
Easy Document Automation

Generate PDFs from Database Records Using WPS Office Mail Merge

Bypass complex enterprise server setups and API coding by exporting your SQL data to a spreadsheet. WPS Office provides a powerful Mail Merge tool that can dynamically generate personalized documents and export them directly to PDF in seconds.

  1. 1. Export SQL to Spreadsheet: Export your SQL database query results into a CSV or Excel (.xlsx) file and open it in WPS Spreadsheet to verify your data columns.
  2. 2. Prepare Your Template: Open WPS Writer and design your document layout, leaving blank spaces where the database information and images will go.
  3. 3. Connect the Data Source: Navigate to the 'Mailings' tab, click 'Open Data Source', and select your exported spreadsheet file.
  4. 4. Insert Merge Fields: Use the 'Insert Merge Field' button to place your database columns directly into the document template.
  5. 5. Merge and Export to PDF: Click 'Merge to New Document' to generate the files, then use the 'Export to PDF' feature to save the finalized dynamic documents as PDFs.
Generate hundreds of personalized PDFs without writing a single line of code.Highly compatible with Microsoft Word (.docx) and Excel (.xlsx) formats.Built-in seamless export to PDF functionality.A lightweight, free alternative to expensive enterprise PDF server infrastructure.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use JavaScript in Acrobat to connect directly to a SQL database?

No. Standard Acrobat JavaScript (AcroJS) operates within a strict security sandbox and cannot establish direct ODBC or SQL database connections. An external application or server middleware is required to query the database.

What is the difference between a static PDF form and a dynamic PDF template?

A static PDF form (AcroForm) has a fixed page layout where only the data inside the fields changes. A dynamic PDF template (like an XFA form) can automatically add new pages, expand text boxes, and shift layouts based on the amount of data injected from the database.

Is Adobe LiveCycle still available for dynamic PDF generation?

Adobe LiveCycle has been discontinued and superseded by Adobe Experience Manager (AEM) Forms. AEM Forms now handles the enterprise-level dynamic PDF generation and direct database integration previously managed by LiveCycle servers.

Can I merge images from a database into a PDF dynamically?

Yes, but this typically requires either a custom server-side script that can retrieve image blobs (or file paths) from SQL to inject into the PDF layout, or an enterprise solution like AEM Forms.