Skip to main content
Participant
January 13, 2023
Question

PDF Scripting - Forms - Images

  • January 13, 2023
  • 1 reply
  • 1235 views

Hi,

I am fairly new to Javascripting with in Adobe DC but I am basically trying to get the follwoing solution.

I have multiple pdf files files that I want a watermark added to when an action is run, but Ideally I would like it to have document level java script as the pdf files I am using wouldn't so essentially following


PDF File - > Then Add Watermark that has an interactive form that will overly the original PDF File. As this document will also have document level javascript it will look at the title and tick a box if it contains specific text- I have got this to work seperately, but when adding a watermark iinto DC via an action it seems to remove the Javascript and form buttons which is problematic and not sure if there is a way to add tick box forms via an action in javascript in spie of adding a watermark.

Once the tickbox has been ticked like I said I plan load an image in the form of a stamp based on if a particular tickbox is ticked. I have written this code but not sure if it is correct?


this.getField("UV - DEPT").checkThisBox(0, /UV/.test(this.documentFileName));
if (this.getField('UV - DEPT').isBoxChecked(0)) {
this.getField('UV - DEPT_af_image').value = 'C:\Users\Computer Name\Documents\STAMPS\UV-STAMP.png';
} else {
this.getField('UV - DEPT_af_image').value = '';
}

So essentially if the checkbox is check load an image from the computer which can then be printed onto the PDF.

Like I mentioned I can rename the form pdf and it ticks a box automatically, but the image doesn't load and also not sure when I add a pdf watermark it is removing everything?

Any help would be much appreciated
This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 13, 2023

To load an image as the icon of a button field you must use the buttonImportIcon method.

However, to do so with the path specified would require running the code from a privileged context, such as a folder-level script that needs to be installed on the local machine of each user who will use this file. Also, the file-path for the image must be the same on each computer, of course.

Is all of that possible in your case?

Participant
January 13, 2023

Hi, Thanks for replying.

With regards to your question, yes it will only need one computer running this, so it wouldn't be needed across multiple machines so that file path location would be the only path required, so could add a script to the specific machine.

Do you know if it is possible to import a pdf form as a watermark without losings its Javascript of interactive buttons? The only way I have got it to work is inserting it as a page but need it on the page in question, so doesn't help me unfortuntely.

Thanks for your help

try67
Community Expert
Community Expert
January 13, 2023

In that case I suggest reading these tutorials:

https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

https://acrobatusers.com/tutorials/using_trusted_functions

Also, to reset a field's image you can't set the value to an empty string (buttons don't have a value property, anyway). You need to copy the image from another, empty, button field.

 

And no, you can't use a form as a watermark and have its fields remain in tact.