How to Add Multiple Unique Text Values to PDF Templates
Question details
The user needs to automate the insertion of unique text codes from a data file into a single PDF template to generate individual PDF documents for each code.

- Product
- Adobe Acrobat / PDF Editors
- Device & OS
- not provided
- Scenario
- Generating multiple customized PDF documents from a single template using a list of unique codes or text values.
- Observed behavior
- The goal is to efficiently batch-process a text file to output a separate PDF for every unique value placed into a designated form field or watermark location.
Ensure you have your list of unique text values saved in an accessible format (like a TXT or CSV file) and a prepared PDF template with a designated form field or watermark area.
Use a Custom Adobe Acrobat JavaScript
Utilize a custom JavaScript within Adobe Acrobat to automate reading values from a file and generating separate PDFs.
Adobe Acrobat supports JavaScript, which allows you to create custom scripts that can loop through a text file, extract each unique value, and place it into a designated form field or as a watermark.
This method requires familiarity with JavaScript and Acrobat's API. For users who cannot code, pre-made paid scripts or external batch-processing tools are available online.
Open your template in Adobe Acrobat and use the 'Prepare Form' tool to add a text field where the unique codes should appear. Name the field clearly, such as 'UniqueCodeField'.
Navigate to 'Tools' > 'Action Wizard' to create a new action, or open the JavaScript Debugger console to run a script manually.
Insert your custom JavaScript that prompts for your TXT/CSV file, loops through each line, sets the value of 'UniqueCodeField', and uses the `saveAs` function to output a new PDF file for each entry.

Use an External Batch Processing Application
Use a dedicated batch watermarking or form-filling application if you are not comfortable writing custom scripts.
Batch Generate Unique PDFs with WPS Office Mail Merge
Skip the complicated JavaScript coding. With WPS Office, you can easily use the Mail Merge feature to link a spreadsheet of unique codes to a document template and automatically export a separate PDF for every value.
- 1. Prepare your Data in Spreadsheet: Open WPS Spreadsheet, enter your unique text values into a single column, add a header (e.g., 'Codes'), and save the file.
- 2. Set up your Document Template: Open WPS Writer and design your document template where the codes will be placed.
- 3. Import the Data: Go to the 'References' tab, click 'Mail Merge', then select 'Open Data Source' and choose your saved spreadsheet.
- 4. Insert the Merge Field: Place your cursor where you want the code to appear, click 'Insert Merge Field', and select your 'Codes' column.
- 5. Export as PDFs: Click 'Merge to Different New Document' (or similar export options) and choose the PDF format to automatically generate separate PDF files for each code.

Frequently Asked Questions
Can I use Excel data instead of a text file to add multiple values to a PDF?
Yes, using mail merge features in word processors like WPS Office, you can easily link an Excel (.xlsx) or CSV file to your document template and export the merged results directly as separate PDF files.
Do I need to know how to code to add unique text to PDFs?
If you are using Adobe Acrobat directly, a custom JavaScript is usually required. However, utilizing batch watermarking tools or the Mail Merge function in WPS Writer allows you to accomplish this without any coding knowledge.
How can I ensure the text values are placed in the exact same spot on every PDF?
When setting up your template, either place a static text form field in a specific location (if using a PDF editor) or insert a merge field in your document template (if using Mail Merge) before exporting. This locks the position for all generated files.




