1 Reply Latest reply on Mar 9, 2009 8:37 AM by try67

    How to insert unique text into many PDFs?

      I'm working on a project which will require some scripting beyond my skill level.

      The part that I'm having trouble with is this: Our client has requested that custom text be inserted into each PDF file (there several hundred PDFs). The custom text is something that was written by the client, and is not necessarily associated with the PDF they want to insert it into. This is hard to explain, so I'll illustrate below.

      Our client provided us with a list of document titles. For the sake of example, let's say the titles they provided are these:

      1.2 Actions
      1.3 Discussions
      1.4 Editing
      1.5 Coding

      Let's say there are 4 PDF documents at this path: c:\files, and the file names are as follows:


      How exactly do I automatically insert the title provided by the client into the appropriate document. Ex: The title "1.2 Actions" should be inserted into participation.pdf and "1.3 Discussions" should be inserted into forum.pdf and so on. There are several hundred PDFs, and I don't want to manually insert the title for each one.

      I am using Acrobat 8 Pro for Windows. I have a working script that will insert text (filename) into each page of each PDF. And I have batched this script. It works perfectly. The client has since changed their requirements as described above.

      function insText()
      for (var p = 0; p < this.numPages; p++)
      var fd = this.addField("Path", "text", p, [10,10, 300,28]);
      fd.textSize=8; fd.value = this.documentFileName

      I am inclined to put the list of titles into an array (maybe read from a db or something) and create a script to step through a directory, open each file, insert the appropriate text, move to the next, etc until complete. I suspect that the script will have to be run outside of Acrobat, which is where I get lost.

      Any help would be greatly appreciated.
        • 1. Re: How to insert unique text into many PDFs?
          try67 MVP & Adobe Community Professional
          Hi Cheryl,

          I think the best (and possibly only) way to do this with a script is through a batch-process, which version 8 Pro is capable of doing.
          The main problem I'm seeing here is how to match the file name with the text your client wants to insert. There doesn't seem to be any correlation between the two (unless I'm missing something), which means that you either have to hard-code it, or indeed to use a database.

          If this is above your programming skill, contact me by email and I might be able to help you out.