Copy link to clipboard
Copied
I have a pdf with 200 emplyee letters, each page is to a differnt employee. I would liek to take the letter and mail merge the employee ID number onto the letter in the header. I have an excel document with the employee number in the same order as the pdf pages in the letters.
Copy link to clipboard
Copied
Create a field called ID on the first page of the PDF and place it where you want it. Run the following script in the console:
var rc=this.getField("ID").rect;
Remove the field. Next, create an array of the ID numbers like this:
var aray=[
12345,
678910,
11121314]
If the ID numbers contain any characters besides numbers they will need to be in quotes. You can easily create this script in Excel by putting a formula in a cell that puts " at the beginning and ", at the end of a referenced cell containing the ID Number, then drag the formula all the way down, then copy and paste the column between [ ] in the console. Remove the last comma after the last item in the array.
Next, run the following script in the console:
for(var i=0; i<this.numPages; i++)
{
var f=this.addField("ID."+i, "text", i, rc);
f.value=aray[i];
}
this.flattenPages();
Copy link to clipboard
Copied
If the letter is the same for all people then you can do it by extracting a single letter from the file, adding an ID Number field to it and then performing a Mail Merge on that file and the data file, using a script.
One such script is this (paid-for) tool I've developed that will allow you to do just that, and can even be used to automatically send out the letters to the employees, if you add a (hidden) field with their email address to the form:
https://www.try67.com/tool/acrobat-mail-merge-and-email-pdf-files