These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Placing Variable Images on a PDF

PJELLISO
Registered: Nov 21 2007
Posts: 10

I am looking for some sample code in JavaScript that will allow me to place images (which are variable) on a PDF based on certain text that appears at the top. Here is the situation:

1. 4 page PDF 11x17
2. Two images need to be placed on a certain spot on the first page.
3. These images are variable and are determined by code. At the top of the
first page, there will be small text (eg. "backround1" for some people, backround2, etc.)
4. The code will be as such:
If background1, then place image1.tif and image2.tif in certain spots on page 1
Else If background2, then place image3.tif and image image4.tif in certain spots on page 1.
etc.
etc.

I would like to run this as a batch process, and be able to edit the code for other projects.

Does anyone have any sample code for this?

Thanks

My Product Information:
Acrobat Pro 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The only two ways to dynmically place an image from an external file onto a PDF is with either a watermark, or a button.

Buttons are the traditional way of doing this in code since a button can be loaded with an image using the "field.buttonImportIcon()" function. If there is not already a Button on the document, then one can be created dynamically and precisely place with the "doc.addField()" function. In this method the image is not really on the page. It exists on an interactive form element and can be changed moved, and deleted.

Watermarks are a slightly different way of doing the same thing. A watermark is added with the "doc.addWatermarkFromFile()" function. Watermarking puts the image directly into the page content. It cannot be moved, changed, or deleted.

Look up these functions in the Acrobat JavaScript Reference

Also take a look at this post
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=12515

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script