3 Replies Latest reply on Jul 6, 2016 7:20 AM by NCAD1

    Save As Extracted Pages with Javascript

    NCAD1

      I am working with Acrobat XI and currently using the built in javascript console and running the script with the action menu.  I have a large document ~550 pages.  It is a combination of 46 other reports.  I need to break these reports out and save them.  I am currently able to extract all of the reports using this.extractPages(0,13) and just setting the pages for each of the 46 reports.  The problem is that I still have to then save and close each of the files.  this.save() appears to only save the parent document. I am hoping that I can add to the script so that it saves the files to a location local or networked at a minimum.  Preferably I would be able to specify the name of each of the files individually as well.

       

      I have tried this.extractPages(0,13,"\\server\folder\subfolder\filename.pdf"); with no luck.  If anyone has any suggestions I would appreciate it.

        • 1. Re: Save As Extracted Pages with Javascript
          try67 MVP & Adobe Community Professional

          Your file-path parameter has an incorrect structure. You need to use the so-called "platform independent path".

          The best way to find out how it needs to look is to open a file from that folder and then run this code from the console:

          this.path;

          It will output the file-path in the correct structure that you need to use in your script.

          • 2. Re: Save As Extracted Pages with Javascript
            Karl Heinz Kremer Adobe Community Professional

            Take a look at the documentation for Doc.extractPages(): Acrobat DC SDK Documentation

             

            It shows in the examples how the path needs to be specified as a device independent path (in your case, it would be  "/server/folder/subfolder/filename.pdf"). You can find out more about device independent paths in the PDF specification.

             

            There is one other useful bit of information in the documentation: When you do not specify the output path, the method will actually return the document object for the newly created document: "If cPath is not specified, returns the Doc for the new document; otherwise, returns the null object."

             

            With that document object, you can then further modify the document and save it via the Doc.saveAs() method (but again, the path needs to be specified as device independent path).

            • 3. Re: Save As Extracted Pages with Javascript
              NCAD1 Level 1

              That took care of it.  Thank you!