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

Watermark Not Printing with JavaScript

Community Beginner ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

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?

TOPICS
JavaScript

Views

867

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

What web browser does you use?

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 Beginner ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

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

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

May be that this browsers doesn't support this. 

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

None of these browsers use Adobe software to display PDF files. Report any issues with them to their makers (Google, Mozilla and Microsoft, resp.).

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

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.  

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

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
});

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 ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

addWatermarkFromText will work in Adobe Acrobat Standard or Pro.

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 Beginner ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Sorry, I don't know if I'm following you. Can I add the script to print the current date in the watermark field? I don't want the watermark to show on the screen, just when the document is printed with the statement that says "NOT VALID FOR USE AFTER 4 DAYS FROM XX/XX/XXX" with the "X" being the current date it is printed.

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 ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Use a (print-only) text field for that. It will work in Reader and has a better chance of working elsewhere (although it will probably never work in all browsers). You can populate it when the file is opened, instead of when printed. The chances of someone keeping a file open for more than a day are slim.

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 Beginner ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

I see where the watermark can be set to only show when printed. Are you saying that the date would need to be manually entered each day as text instead of using a script? I was hoping to be able to make it an automatic option, but maybe that won't work in a Web browser.

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 ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

No, use a script to automatically set the current data in a text field. The date can be set in a document script. The field should be setup to only display on Print.  

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

LATEST

Set up the text field to have the display settings you want, set its visibility as "Hidden, but printable" and embed this code as a doc-level script (let's say the field is called "WatermarkText"):

 

var today = util.printd("mm-dd-yyyy", new Date());
var watermark = "NOT VALID FOR USE AFTER 4 DAYS FROM " + today;
this.getField("WatermarkText").value = watermark;

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
LEGEND ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

It doesn't even work in Acrobat Reader...

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