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

How to run a script after password security added to pdf

Explorer ,
May 01, 2018 May 01, 2018

Copy link to clipboard

Copied

I have a document which is placed on the company intranet (it needs to be password protected), if a copy is downloaded, the next time it is opened a watermark will show on each page.

The script is placed as an action on the page open event.

this.addWatermarkFromText("Uncontrolled document", 0, font.Helv, 24, color.red);

This script works however once the pdf is password protected it will no longer run the script.

NotAllowedError: Security settings prevent access to this property or method.

Doc.addWatermarkFromText:1:Page undefined:Open

Can anyone please advise how an embedded javascript can run after the document is password protected?

Thanks

TOPICS
Acrobat SDK and JavaScript

Views

394

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

correct answers 1 Correct answer

Community Expert , May 01, 2018 May 01, 2018

You're confusing two different things.

JavaScript can absolutely run on a document after it has been password protected. However, JavaScript can't modify the document in ways that the protection prohibits... just like if you had manually tried to add a watermark.

In short, you won't be able to add a watermark after the document has been protected.

What you can do instead is put a button field over the entire page that and then use a script to control it's visibility. The button icon would be a PDF

...

Votes

Translate

Translate
Community Expert ,
May 01, 2018 May 01, 2018

Copy link to clipboard

Copied

You're confusing two different things.

JavaScript can absolutely run on a document after it has been password protected. However, JavaScript can't modify the document in ways that the protection prohibits... just like if you had manually tried to add a watermark.

In short, you won't be able to add a watermark after the document has been protected.

What you can do instead is put a button field over the entire page that and then use a script to control it's visibility. The button icon would be a PDF of the watermark you want. Because the field will always appear on top of the page content, you'll want to make it somewhat transparent as well.

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
Explorer ,
May 01, 2018 May 01, 2018

Copy link to clipboard

Copied

LATEST

Thank you for your assistance Joel. I added a button the same size as the pdf page and used the following page open action script. var f = this.getField("Button"); f.display = display.visible It works perfectly, much appreciated.

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