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.
Copy link to clipboard
You're confusing two different things.
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.
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.