Skip to main content
Known Participant
Aug 20, 2021 5:21 PM UTC
Question

Watermark Not Printing with JavaScript

I've added a watermark to a pdf file using a JavaScript with the Document Actions > Document Will Print settings. The watermark is scripted to only show when printed, not on the screen, and adds the current date on the printed pages. It works fine from our desktops, but will not work when I try to print it from a link on our company website. I don't know if there is anything in our company browser settings that would block the script from working. I'm not very familiar with scripting. Can anyone provide any suggestions/solutions to get the watermark to print from a link in the Web browser?

This topic is closed to new replies. Start a new post to keep the conversation going.

13 replies

Thom Parker
Community Expert
Community Expert
Aug 20, 2021 8:55 PM UTC

First, What exact code is used to add the watermark?

This type of functionality is problematic in any non-Acrobat PDF viewer, but it is especially problematic if you used the "addWatermarkFromFile" function. This function does not work in Reader, so you must have Acrobat Pro on all your desktops. Further, this function is unlikely to be supported in pretty much every PDF viewer in existence except for Acrobat and a small group of the very best desktop PDF viewers.  Just in general HTLM Browsers have seriously crappy PDF viewers. I don't think any of them support any JavaScript except for some forms properties and functions, if that.

 

But back to my first point. Since this code is not supported in Reader, it is not suitable for use in a document script. Its intended for use in Automation scripts. To display a dynamic date and other information on a header or footer, use form fields.  

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
louriehAuthor
Known Participant
Aug 23, 2021 4:26 PM UTC

From what I am hearing from everyone, the JavaScript will most likely not work in any of the Web browsers, but here is the code I'm using in Acrobat > Document Actions > Document Will Print > JavaScript Editor:

 

var today = util.printd("mm-dd-yyyy", new Date());

var watermark = "NOT VALID FOR USE AFTER 4 DAYS FROM " + today;

this.addWatermarkFromText({
cText: watermark,
cFont: "Verdana",
nOpacity: 1,
bOnScreen: false,
nFontSize:10,
aColor: color.red,
nHorizAlign:app.constants.align.center,
nHorizValue: 0,
nVertAlign:app.constants.align.bottom,
nVertValue: 26
});

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 23, 2021 4:38 PM UTC

addWatermarkFromText will work in Adobe Acrobat Standard or Pro.

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 20, 2021 5:26 PM UTC

What web browser does you use?

Translate
louriehAuthor
Known Participant
Aug 20, 2021 5:33 PM UTC

I've tried Chrome, Firefox, and MS Edge and none of them will print the watermark through the Web link.

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 20, 2021 6:29 PM UTC

May be that this browsers doesn't support this. 

Translate