The most common and annoying problem to deal with in a PDF workflow is adding new text to a PDF. Whether there are pages that need to be numbered or slug information that needs to be added for proofing or printing, something that should be so simple can be complicated within a PDF. The same is true when trying to automate the simple addition of text to PDF files; Javascript allows only certain commands to be automated within Acrobat and is subject to the same errors encountered when adding text manually.
The Touch Up Text tool allows you to add text to existing text boxes; however, the system font encoding error message can change all the text in the text box – not to mention cause the problem with a font that is now not embedded. The tool can work properly when custom font sets are loaded but when a system font like Arial, Helvetica or Times is used, the system font encoding error will often be encountered.
For slug information to appear on each page, a watermark can be added. This is static and the Javascript command AddWatermarkFromText can be used to apply the text to the pages you want. You cannot add page numbers using this command. A new watermark must be created for each different item, and it is best to optimize the file between watermarks if you want different data on different pages.
Acrobat does have a page numbering function, but there is no Javascript command to perform the same task. Both the watermark and page numbering allow you to use fonts that are already embedded in the PDF so you do not run into problems with font encoding or embedding. The page numbering function, also called the Header or Footer menu, allows you to place your page numbers and slugs left, center or right aligned within a specific distance from the trim. Like the Watermark tool, you can choose even or odd pages to apply to a specific range.
One thing that can be used to add text to a new text box in a PDF and can be automated using Javascript is the form field tool. Creating a form field to act as a page number and slug on right and left pages can be achieved with a simple Javascript. By selecting the default font, the font can change when opened on any computer and does not need to be embedded. Imposition programs, batch optimize or third-party optimizer programs will all flatten the form field. Or you can choose to ignore the form field (if you were only using it for soft or hard copy proofing).
With the form field tool in Acrobat, you can add text anywhere on your PDF pages without disrupting other text on the page or worrying about font embedding. When the default font used in the form field is flattened, it uses the default font that is embedded in the PDF. In Javascript, using the addfield method, you can define the size of the box for text, the actual text, the text size, rotation, colour and fill colour of the box (white and transparent are options).
A Javascript can be created to add page numbers and slugs to right and left pages based on the number of pages in the document. By placing this script in an Acrobat Configurator in FullSWITCH, you can create hot folders to add page numbers and slugs to any PDF. You can specify whether the text appears at the edge of the bleed of each page and make the text box knock out a 1/16” of the image in the bleed to accommodate the slug and page number.
Finding the best way to automate a task will often involve manual trial and error with different tools in Acrobat. Not all tools in Acrobat are available as commands in Javascript, however it is Acrobat that we want to automate more and more.
The FullSWITCH Acrobat Configurator makes it easy to plug in a Javascript and have Acrobat run the script when a PDF file has entered the hot folder. FullSWITCH takes care of saving the file and sending it on to the next task so you are just working on scripting the simple tasks you want to perform.