• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

PDF Scripting - Forms - Images

New Here ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

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
TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF forms

Views

408

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2023 Jan 19, 2023

Copy link to clipboard

Copied

Hi,

Thank for sending this information over. I am going to take a read now

If that is not possible in terms of a watermark. Is it possible to create a simple form with tick boxes on each pdf through an action so instead of it importing it via a water mark it creates it on each page then the script runs through so, then can work out what to load based on the filename etc.

Or if that does not work could you set a rule for use of redaction marks to only highlight certain keywords in the document if the filename contained specific text? So kinda highlight on demand rather to have several actions to run different redaction highlighting

I really appreciated your time and expertise

Many Thanks,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2023 Jan 19, 2023

Copy link to clipboard

Copied

LATEST

Hi,

I have managed to work out how to highlight text based on what the file name is with If Else logic and also can create a text based watermark based also on what the filename is called.

In this case is it possible to load an image based watermark instead of a text based watermark via javascript, so therefore I wouldn't need any buttons or forms as it could all be done with javascript on the action?

 

Thanks,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines