Skip to main content
New Participant
January 4, 2017
Answered

Automatically add a watermark when exporting to a PDF

  • January 4, 2017
  • 6 replies
  • 28635 views

Hi, happy new year everyone!

I just wanted to know if there is a plugin or a way to automatically add a watermark when I export the document.

Or maybe automatically creating a new layer (locked if possible) with a text or an illustration when you create a new document.

Thank you!

This topic has been closed for replies.
Correct answer Manan Joshi

Quick question ... but first I wanted to thank you for this amazing script, it super helpful! Is there a way to do it as a percentage of document size rather than point size? Also it exports as filename.indd.pdf is there a way to get rid of the".indd" part? Thanks again! This is great!


Try the following

var myDoc = app.activeDocument, 

myPdfExportPreset = "[Smallest File Size]",

myPdfFile = File(myDoc.fullName.fsName.replace(/.indd$/i, "") + ".pdf");   

app.scriptPreferences.measurementUnit = MeasurementUnits.PICAS

var docHeight = myDoc.documentPreferences.pageHeight

var docWidth = myDoc.documentPreferences.pageWidth

with ( myDoc.watermarkPreferences ) 

    { 

        watermarkVisibility = true;   

        watermarkDoPrint = true;   

        watermarkDrawInBack = true;   

        watermarkText = "HAPPY NEW YEAR!  (^/)";   

        watermarkFontFamily = "Arial";   

        watermarkFontStyle = "Bold";   

        watermarkFontPointSize = Math.round(docWidth/2);   

        watermarkFontColor = [180,180,180];    

        watermarkOpacity = 60;   

        watermarkRotation = -45;   

        watermarkHorizontalPosition = WatermarkHorizontalPositionEnum.watermarkHCenter;   

        watermarkHorizontalOffset = 0;   

        watermarkVerticalPosition = WatermarkVerticalPositionEnum.watermarkVCenter;   

        watermarkVerticalOffset = 0;   

    } 

 

 

myDoc.asynchronousExportFile(ExportFormat.PDF_TYPE, myPdfFile, false, myPdfExportPreset); 

 

 

myDoc.watermarkPreferences.watermarkVisibility = false;

Line 6 and 7 gives the document height and width in PICAS and line 16 sets the fontsize of the watermark. I have set the size to 50% of docWidth you can change the calculation with what you need.

-Manan

6 replies

Known Participant
March 5, 2020

Is it possible to convert the watermark to outlines? 

 

When my client attempts to place comments on the PDF to communicate edits to me they are unable to select the text of the document because they are selecting the watermark in front of the text they are indending on highlighting for edits.

 

I am guessing if it is converted to outlines that would eliminate the problem because in the past i have placed a JPEG graphic of the word  "PROOF" across the pdf and it was not selectable

 

scott

New Participant
February 26, 2020

Hi Manan, 

the watermark only shows up over text. If my pdf has imagery or a background the watermark is hidden behind it. Is there a way to make it sit on top of the whole artwork? Would i need to flatten the imagery in the export?

Community Expert
February 29, 2020

Hi,

 

I don't see any property to fix this, see the properties that are accessible to us via scripting

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#WatermarkPreference.html#d1e411214

 

Seems this is one of the half baked implementation of watermark as point out by Uwe in a post above.

 

-Manan

New Participant
October 9, 2019

How do you add line breaks to the watermarkText? I've been trying \n and \r with no success.

jane-e
Community Expert
January 4, 2017

Acrobat Pro has Actions, and if you have questions about how to create one, please ask in the Acrobat forum.

Your Action can include adding a watermark, setting options for opening the document, security, running Javascript, etc. You have the option to do it automatically or to review and customize each step.

You might do both:

Create and enable layer, and if you forget, apply it in Acrobat after the fact. You have to decide what works for your workflow.

Setting Layer Options could also work: Printable but not visible. Be sure to Export All Layer as part of your Saved PDF Preset.

All of these require a human making sure the watermark is there. You could check the Scripting forums.

Steve Werner
Community Expert
January 4, 2017

I agree with Eugene and Jane: It would be a lot easier to create an Action in Acrobat Pro. Then you could apply it to as many PDFs as you like, all at one time.

Derek Cross
Community Expert
January 4, 2017

Hi,

Or using The Force!  At your own risks! …

Supposing the personal pdf export preset you've saved and want to use here is: "Print_WithoutCropMarks" …

ID file before:

1 light-saber hit with this code:

var myDoc = app.activeDocument,

myPdfExportPreset = "Print_SansHir",

myPdfFile = File(myDoc.fullName + ".pdf"); 

with ( myDoc.watermarkPreferences )

    {

        watermarkVisibility = true; 

        watermarkDoPrint = true; 

        watermarkDrawInBack = true; 

        watermarkText = "HAPPY NEW YEAR!  (^/)"; 

        watermarkFontFamily = "Arial"; 

        watermarkFontStyle = "Bold"; 

        watermarkFontPointSize = 65; 

        watermarkFontColor = [180,180,180];  

        watermarkOpacity = 60; 

        watermarkRotation = -45; 

        watermarkHorizontalPosition = WatermarkHorizontalPositionEnum.watermarkHCenter; 

        watermarkHorizontalOffset = 0; 

        watermarkVerticalPosition = WatermarkVerticalPositionEnum.watermarkVCenter; 

        watermarkVerticalOffset = 0; 

    }

myDoc.asynchronousExportFile(ExportFormat.PDF_TYPE, myPdfFile, false, myPdfExportPreset);

myDoc.watermarkPreferences.watermarkVisibility = false;

PDF file:

ID file after -- no changes!:

So, … HAPPY NEW YEAR TO ALL!

(^/) 


Happy new year to you too Obi.

I wonder what your real name is, maybe it's something like Les Braithwaite – any other suggestions?

Community Expert
January 4, 2017

You can apply a watermark in Acrobat after you've made the PDF. Add watermarks to PDFs in Adobe Acrobat DC

Derek Cross
Community Expert
January 4, 2017

Can't you just add it to a master page and turn it on when you need it on the exported to PDF document?

New Participant
January 4, 2017

I was thinking about it but I wanted to know if there is a way to do it automatically, we are making many indd projects per day in the agency where I work and I'm sure one day we will forget to put the watermark and we will fall on a client who send a low-res project to the print worker...

BobLevine
Community Expert
January 4, 2017

Automatically? No!

I suppose it could be scripted but, if you can’t remember to turn on a layer before outputting a PDF, you’re going to forget to run the script, too.