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?
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