3 Replies Latest reply on Jul 14, 2016 12:32 AM by Ravindra_KCS

    How do I export a multipage PDF as individual pages, and automate the filenames?

    madeleinew49687447

      Hi!

       

      I have a 100 page document and would like to export each page as an individual PDF, where the names are automated, drawing the data from specific paragraph styles

       

      Eg

      H1_number.pdf

      Would turn into

      CairnsCentre_08536948.pdf

       

      I've tried a few I've found through searchers but nothing seems to work.

       

      Thanks so much!

       

      Madeleine

        • 1. Re: How do I export a multipage PDF as individual pages, and automate the filenames?
          Ravindra_KCS Level 1

          Hi Madeleine,

                 As per understanding, this Script will do following..

          a) Loop run for each page and search "H1" paraStyle in each page, if found then get its corresponding Texts.

          b) it will generate Name by concatenating corresponding Texts + corresponding PageNumber.

          c) Export each page separately with named found in Step b)

           

          var myDoc = app.activeDocument;

            

          for (var i=0  ; i < myDoc.pages.length;  i++)

          {

                  var  myPage = myDoc.pages[i];

                  var  myPrintPage =myDoc.pages[i].name;

                  var  paraContent =  FindMyPara(myPage);

                

                  var  myPDFFile = myDoc.filePath+"/"+paraContent+"-"+myPrintPage;  

                         myPDFFile=new File(myPDFFile);

                         PrintPdfFunctionLR(myPrintPage ,myPDFFile);

            }

           

          function PrintPdfFunctionLR(myPrintPage, myPDFFile)

          {

                     app.pdfExportPreferences.pageRange = myPrintPage;

                     myDoc.exportFile(ExportFormat.pdfType,myPDFFile,false);

                     return true;

          }

           

          function FindMyPara(myPage)

          {

                   for (var i=0  ; i <myPage.textFrames[0].paragraphs.length;  i++)

                   {

                         if(myPage.textFrames[0].paragraphs[i].appliedParagraphStyle.name == "H1")

                           {

                             var myContents =   myPage.textFrames[0].paragraphs[i].contents;

                              myContents =myContents.replace("\r","");

                              return myContents;

                              break;

                            }

                      

                     }

            }

           

          Please confirm if it work !!!!

          Thanks and regards

          Ravindra

          • 2. Re: How do I export a multipage PDF as individual pages, and automate the filenames?
            madeleinew49687447 Level 1

            Thanks Ravinda! I just tried it and I get an error 9490.

            'unable to view this file because Acrobat was not found.'

            Line 33 ->  myDoc.exportFile(ExportFormat.pdfType,myPDFFile,false);

            What do you think?

            • 3. Re: How do I export a multipage PDF as individual pages, and automate the filenames?
              Ravindra_KCS Level 1

              Add below Code at the top in the Script

              app.pdfExportPreferences.viewPDF=false;

               

              and try again

               

               

              Thanks

              Ravindra