5 Replies Latest reply on Jul 12, 2010 11:22 AM by jay fresno

    Batch sequence to remove document JavaScript

    jay fresno Level 1

      Does anyone know of a batch sequence that can remove the document JavaScript from a group of Acrobat 9 Pro PDFs?

        • 1. Re: Batch sequence to remove document JavaScript
          try67 MVP & Adobe Community Professional

          If you know the script's name, use this:

          this.addScript("ScriptName", "");

          • 2. Re: Batch sequence to remove document JavaScript
            jay fresno Level 1

            Hi Try67,

            Thanks so much for your reply. I really appreciate your help.

            I need to remove the script rather than add it, but your answer gave me the clue I needed for how to construct the remove script. Problem solved.

            • 3. Re: Batch sequence to remove document JavaScript
              gkaiseril MVP & Adobe Community Professional

              You use the "addScript" method to add or modify a document level script. You use the 'setAction' method for adding or modifying page triggers, bookmark triggers, and field actions. And you use the 'setPageAction, for adding or modifying page actions. A null string for a script is the same as a "NOP" command, No Operation. But you need to know the various script names.

               

              With the PDF Optimizer in Acrobat Professional, you can remove all JavaScirpt actions.

              1 person found this helpful
              • 4. Re: Batch sequence to remove document JavaScript
                wildcathoya Level 1

                If the doc-level Javascript names are not known in advance, then the only way I found to remove all of the Javascripts is with doc.extractPages(), which will create a new doc object, and then newDoc.saveAs() followed by newDoc.closeDoc().

                 

                I don't do this in a batch sequence but in a .Net app, so I'm not entirely sure how you would write this in a batch sequence.  Here's a code snippet that shows the basic logic:

                 

                                object AcroJS = AcroPDDoc.GetJSObject();

                                string PdfFullPath = "C:\\filename.pdf";

                 

                                              ...

                 

                                Type T = AcroJS.GetType();
                                object newDoc = T.InvokeMember("extractPages", InvokeMethodFlags, null, AcroJS, null);
                                AcroJS = null;
                                AcroPDDoc.Close();
                                object[] saveAsDataParam = { PdfFullPath };
                                T.InvokeMember("saveAs", InvokeMethodFlags, null, newDoc, saveAsDataParam);
                                T.InvokeMember("closeDoc", InvokeMethodFlags, null, newDoc, null);
                                newDoc = null;
                                AcroPDDoc.Open(PdfFullPath);
                                AcroJS = AcroPDDoc.GetJSObject();

                 

                 

                This can also be used to create a new doc GUID.

                 

                Bill

                • 5. Re: Batch sequence to remove document JavaScript
                  jay fresno Level 1

                  Bill,

                  Thanks for this information. I've made a note of it in case I need it in the future.