Skip to main content
Participant
February 14, 2025
Answered

Displaying Watermark OCG in Layers Panel???

  • February 14, 2025
  • 2 replies
  • 497 views

I am trying to view watermark OCGs in the layers panel. I have added three text watermarks using the watermark tool. I can see the watermarks on the page. I then ran the following to scripts one after the other:

this.getOCGs();

doc.getOCGs()

I got these scripts from a tutorial and after running them any watermark OCGs are to appear on the layer list in the layers panel as I understand it, but nothing appears.

I tried this first on a page with a couple watermarks as files and it didn’t work either. I thought maybe I had earlier run some script that didn’t work and it may have messed something up,and that is why I did it again with text watermarks.

I created a new blank document and added a couple text watermarks again and did the same with the same results

This is from the console:

this.getOCGs();

 

[object OCG="Watermark"]

 

doc.getOCGs()

 

ReferenceError: doc is not defined

1:Console:Exec

undefined

 

Does anyone have any suggestions what I might be doing wrong, some setting that needs to be set, etc?

Correct answer PDF Automation Station

To see the watermarks in the layers panel, run the following script in the console:

this.setOCGOrder(this.getOCGs());

You will will have to add one watermark, run the script, rename it in the panel, add another, run the script, rename in the panel, and repeat for each watermark.  Otherwise only one named "Watermark" will appear in the panel.

2 replies

PDF Automation Station
Community Expert
Community Expert
February 14, 2025

To see the watermarks in the layers panel, run the following script in the console:

this.setOCGOrder(this.getOCGs());

You will will have to add one watermark, run the script, rename it in the panel, add another, run the script, rename in the panel, and repeat for each watermark.  Otherwise only one named "Watermark" will appear in the panel.

try67
Community Expert
Community Expert
February 14, 2025

Nice trick!

PDF Automation Station
Community Expert
Community Expert
February 14, 2025
try67
Community Expert
Community Expert
February 14, 2025

The error message is because you're trying to access a variable ("doc") that you didn't declare before. Replace it with "this" and it should work.

The "Watermark" DO is considered an internal one and will not appear in the Layers panel. There's no workaround for that.