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

Placing a watermark over unique text

PJELLISO
Registered: Nov 21 2007
Posts: 10

I am trying to write code to create a sequence to do the following
as a batch process:

-search for a unique text in my pDFs, for example "IMAGEA"
-calculate the x,y coordinates fo that text
-then place a watermark (a TIF file) over that text using those coordinates.

I think there is a way this can be done, but I am having trouble
calculating the x,y coordinates of that text "IMAGEA" and using
the values in the nHorizValue and nVertValue parameters of the
addWaterMarkFromFile command.

Any ideas?

My Product Information:
Acrobat Pro 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes there is a way that this can be done. Coordinates in Acrobat are points. Measured from the bottom left corner of the page. There are 72 points to an inch. If you know the bounding box of the word on the page, then you can position the water mark by offsetting it from the bottom and left edges of the page using the edges of the bounding box as the offset.

Position the watermark by setting the alignment to bottom left. If the offsets are (0,0), then the watermark will appear aligned with the bottom left edges of the page. Then just set the nHorizValue and nVertValue to bottom left edges of the word's bounding box to align the image with the bottom left edges of the word.

If you are using the "doc.getPageNthWordQuad" function to the the word coords, you will have to do a little massaging to get the quads into a proper bounding box, including a possible coordinate transformation if you pages are croped or rotated. See Example #2 for the "doc.addLink()" function in the Acrobat JavaScript Reference for a script using the "doc.getPageNthWordQuad" and coordinate transformation.

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