Copy link to clipboard
Copied
I am trying to create a Javascript string that can apply a watermark based on user input. I need it to say something along the lines of "this document is licensed to ____. Cannot be reproduced/resold, etc." It needs to appear on every page and I would like to avoid it asking every time the document is opened. I have never worked with Javascript, but I have been able to come close to a solution by following various tutorials. Unfortunately, none of them are quite right. I am still missing how to add static text around the dynamic name. Below is what I have so far, any help would be greatly appreciated!
var dialogTitle = "Purchaser Name";
var PurchaserName = app.response("Please enter your name",
dialogTitle);
event.target.addWatermarkFromText({
cText: PurchaserName,
nTextAlign:app.constants.align.center,
cFont: "Arial",
nRotation: 0,
nScale: -1,
nOpacity: 0.06,
nFontSize: 5
});
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you so much! I am very close. Is there a way to "lock in" the watermark after the first time the pdf is opened? Ideally, I would love to have the purchaser open the document, enter their name once, then have the watermark stay from then on.
Copy link to clipboard
Copied
Your should start by only running the script if the document has not been watermarked yet (assuming the one you are adding will be the only watermark. Do this by putting your entire script inside the curly brackets of this:
if(!this.getOCGs())
{
//your script here
}
To answer your question, the document would have to be saved after the user adds the watermark by entering the name. You could pop up a SaveAs window but you can't force the user to save the document.

