5 Replies Latest reply on Dec 14, 2015 4:25 PM by K159

    How to display the watermark for each page number?

    K159 Level 1

      Hi.

       

      app.documents.item(0).watermarkPreferences.watermarkText = "page";
      app.documents.item(0).watermarkPreferences.watermarkVisibility = true;
      
      

       

      This are all the same watermark settings.

       

      It is impossible to set a non-zero value from the item.

       

      I want to display the watermark for each page number.

       

      If there is no way, I want to create that similar functionality.

       

      Any Ideas?

       

      And please tell me if already the function exists.

       

      Thanks.

        • 1. Re: How to display the watermark for each page number?
          Peter Kahrel Adobe Community Professional & MVP

          > This are all the same watermark settings.

           

          What do you mean by this?

           

          > It is impossible to set a non-zero value from the item.

           

          Which item?

           

          > I want to display the watermark for each page number.

           

          You probably mean for each page, correct?

           

          > If there is no way, I want to create that similar functionality.

           

          Similar to what?

           

          It's not clear what your problem is. Those two lines of code you gave place a watermark 'page' on every page.

           

          Peter

          • 2. Re: How to display the watermark for each page number?
            Johnwhite Level 1

            Hi

             

            will this help?

             

            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++

             

             

            Creating watermarks

             

            You can apply watermarks to documents in InDesign or InDesign Server using scripting. Currently, no user

             

            interface component exists in InDesign for managing watermarks.

             

            A document’s watermark preferences can be set in two ways using scripting:

             

            •   Application-level watermark preferences, if any are set, are applied to the document watermark

             

            preferences for each new document created by InDesign. This setting has no effect on existing

             

            1. documents.

             

            •   Document-level watermark preferences apply only to that document. Setting or changing a

             

            document’s watermark preferences replaces any previous watermark settings for the document.

             

            Both the document and application watermark preference settings persist after the document or

             

            application is closed until a script changes them.

             

            The same group of watermark preferences exist for both the document and the application objects.

             

            Setting watermark preferences

             

            The following script fragment shows how to set watermarks at the application level. A watermark will be

             

            applied to all documents created after this code finishes. (For the complete script for setting application

             

            preferences, see ApplicationWatermark.)

             

            1. app.watermarkPreferences.watermarkVisibility = true;
            2. app.watermarkPreferences.watermarkDoPrint = true;
            3. app.watermarkPreferences.watermarkDrawInBack = true;
            4. app.watermarkPreferences.watermarkText = "Confidential";
            5. app.watermarkPreferences.watermarkFontFamily = "Arial";
            6. app.watermarkPreferences.watermarkFontStyle = "Bold";
            7. app.watermarkPreferences.watermarkFontPointSize = 72;
            8. app.watermarkPreferences.watermarkFontColor = UIColors.red;
            9. app.watermarkPreferences.watermarkOpacity = 60;
            10. app.watermarkPreferences.watermarkRotation = -45;
            11. app.watermarkPreferences.watermarkHorizontalPosition =
            12. WatermarkHorizontalPositionEnum.watermarkHCenter;
            13. app.watermarkPreferences.watermarkHorizontalOffset = 0;
            14. app.watermarkPreferences.watermarkVerticalPosition =
            15. WatermarkVerticalPositionEnum.watermarkVCenter;
            16. app.watermarkPreferences.watermarkVerticalOffset = 0;

                                           

             

             

            The same preferences can be applied to a document object by referring to a document, rather than to the

             

            1. application. (For the complete script for setting document preferences, see DocumentWatermark.)

             

            var myDocument = app.documents.item(0);

             

            1. myDocument.watermarkPreferences.watermarkVisibility = true;
            2. myDocument.watermarkPreferences.watermarkDoPrint = true;
            3. myDocument.watermarkPreferences.watermarkDrawInBack = true;
            4. myDocument.watermarkPreferences.watermarkText = "Confidential";
            5. myDocument.watermarkPreferences.watermarkFontFamily = "Arial";
            6. myDocument.watermarkPreferences.watermarkFontStyle = "Bold";
            7. myDocument.watermarkPreferences.watermarkFontPointSize = 72;
            8. myDocument.watermarkPreferences.watermarkFontColor = UIColors.blue;
            9. myDocument.watermarkPreferences.watermarkOpacity = 60;
            10. myDocument.watermarkPreferences.watermarkRotation = -45;
            11. myDocument.watermarkPreferences.watermarkHorizontalPosition =
            12. WatermarkHorizontalPositionEnum.watermarkHCenter;
            13. myDocument.watermarkPreferences.watermarkHorizontalOffset = 0;
            14. myDocument.watermarkPreferences.watermarkVerticalPosition =
            15. WatermarkVerticalPositionEnum.watermarkVCenter;
            16. myDocument.watermarkPreferences.watermarkVerticalOffset = 0;

                                           

            Disabling watermarks

             

            After turning off the application setting for watermarks, InDesign no longer turns on the watermark

             

            settings for new documents by default. However, you can still set watermarks for individual documents.

             

            The following script fragment shows how to turn off application-level watermarks.

             

            1. app.watermarkPreferences.watermarkVisibility = false;

             

            You can turn off watermarks in an individual document at any time, as shown in the following script

             

            1. fragment.
            2. app.documents.item(0).watermarkPreferences.watermarkVisibility = false;

               

             

            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++

            • 3. Re: How to display the watermark for each page number?
              Laubender Adobe Community Professional & MVP

              I think I know what you want.

              You need a different watermark for every page of one document.

               

              This seems not to be possible since watermarkPreference is not a page preference but a document preference.

               

              If you need this for e.g. PDF export, you could export single pages in single PDF files and change the watermarkText according to the page name you are currently exporting.

              After exporting all pages you could assemble them in Acrobat Pro. Or place them in InDesign page by page and export again to a multipage PDF document.

               

              // ExportPages-ChangeWatermarkForEveryPage.jsx
              // Uwe Laubender
              
              /**
              * @@@BUILDINFO@@@ ExportPages-ChangeWatermarkForEveryPage.jsx !Version! Mon Dec 14 2015 20:28:23 GMT+0100
              */
              
              
              var doc = app.documents[0];
              var pages = doc.pages.everyItem().getElements();
              
              // You can also assign a preset by its name
              // For simplicity here the second preset listed in assigned:
              var pdfExportPreset = app.pdfExportPresets[1];
              
              // Loop through all the pages:
              
              for(var n=0;n<pages.length;n++){
                 
                  app.pdfExportPreferences.pageRange = "+"+String(pages[0].documentOffset + 1);
                 
                  var pageName = pages[n].name;
                  var pdfFile = File(doc.fullName +"_"+ pageName +"."+"pdf");
                 
                  doc.watermarkPreferences.properties =
                  {
                      watermarkVisibility : true,
                      watermarkDoPrint : true,
                      watermarkDrawInBack : false,
                     
                      watermarkFontColor : [255,255,0],
                      watermarkOpacity : 50,
                     
                      watermarkFontFamily : "Minion Pro",
                      watermarkFontStyle : "Bold",
                      watermarkFontPointSize : 400,
                      watermarkHorizontalPosition : WatermarkHorizontalPositionEnum.WATERMARK_H_CENTER,
                      watermarkVerticalPosition : WatermarkVerticalPositionEnum.WATERMARK_V_CENTER,
                     
                      /*
                          ... other properties ...
                      */
                     
                      // Text is the name of the page
                      watermarkText : pages[n].name
                  };
              
                  // Export to PDF. Page by page with a different name and a different watermark text:
                  doc.asynchronousExportFile(ExportFormat.PDF_TYPE , pdfFile , false , pdfExportPreset);
              
              };
              

               

              Hope, that helps.

               

              Uwe

              • 4. Re: How to display the watermark for each page number?
                Peter Kahrel Adobe Community Professional & MVP

                If that's the case, Uwe (different watermark on each page), then don't bother with watermarks. Just add a frame on each master page with the autonumber marker in it, that's all you need.

                 

                Peter

                • 5. Re: How to display the watermark for each page number?
                  K159 Level 1

                  I wanted to keep different watermarks on each page.

                   

                  But Uwe's answer has also been a great help.

                   

                  Thanks all.