6 Replies Latest reply on Apr 11, 2017 10:48 AM by samuelt6641188

    Never Prints OCG property

    samuelt6641188

      Greetings,

      Newbie here. Is there a way in JavaScript to programmatically set the initial state of print to Never Prints in the layer properties?

      I manage to hide OCG layers (watermark) and I don't want it to be printed.

      Is there a function or script that I can use to do that?

      Thank you.

       

        • 1. Re: Never Prints OCG property
          try67 MVP & Adobe Community Professional

          I don't think that's possible to do using JS, no.

          • 2. Re: Never Prints OCG property
            try67 MVP & Adobe Community Professional

            The only way is if you create that layer using addWatermarkFromFile or addWatermarkFromText... If you use those methods then you can set the bOnScreen and bOnPrint parameters to determine whether the OCG they create should appear on the screen and/or on the printed copy, respectively.

            • 3. Re: Never Prints OCG property
              samuelt6641188 Level 1

              Thank you for the prompt response.  Just started learning JS and I am kind

              of lost.

               

              I wanted to be able to watermark a PDF document using input from user,

              print it and then run the scripts again to key in another input, print so

              on and so forth. Below is the code that I use.

               

              Pardon my ignorance but where should I code the bOnPrint?

               

               

               

              //Get input from user

               

                              var myNetID = app.response("Enter document recipient's

              networkID", "NetworkdID");

               

               

               

                              this.addWatermarkFromText()

               

               

               

              // Print document

               

                              this.print();

               

               

               

              // Find and rename the default OCG to LayerOne

               

                              function FindOCG(cName) {

               

                                              var aOCGs = this.getOCGs();

               

                                              for (var i=0; aOCGs && i <aOCGs.length;i++)

              {

               

                                              if(aOCGs[i].name == cName) return aOCGs[i];

               

                              }

               

                              return null;

               

                              }

               

                              FindOCG("Watermark").name = "LayerOne";

               

              // Set the state of LayerOne to invisible

               

              this.setOCGOrder(this.getOCGs());

               

               

               

              function SetWatermarkState(doc, bState) {

               

              var ocgArray = doc.getOCGs();

               

              for (var i=0; i < ocgArray.length; i++) {

               

              if (ocgArray[i].name == "LayerOne") {

               

              ocgArray[i].state = bState;

               

              }

               

              return;

               

              }

               

              SetWatermarkState(this, false);

              • 4. Re: Never Prints OCG property
                try67 MVP & Adobe Community Professional

                You need to do it inside the parameters of addWatermarkFromText. Read the documentation of this method to see how to use it correctly...

                • 5. Re: Never Prints OCG property
                  JR_Boulay Adobe Community Professional

                  Hi.

                   

                  I'm not sure why you want to change the layer's name, if you want to hide the watermark layer you can use something like this:

                   

                   

                  var ocgArray = this.getOCGs(this.pageNum);
                  for (var i=0; i < ocgArray.length; i++) {
                      console.println("This layer is " +  ocgArray[i].name);
                      if (ocgArray[i].name == "Watermark") {
                          ocgArray[i].state = !ocgArray[i].state;
                      }
                  }
                  
                  • 6. Re: Never Prints OCG property
                    samuelt6641188 Level 1

                    Users need to reprint over and over again the same document with different

                    watermarks. However, the script does turn off only the visibility but print

                    the watermarks on top of each other. What we do now is run the script once

                    and then close without saving, reopen then re-run the script to have a

                    different watermark. Changing the properties in GUI is not an option.