6 Replies Latest reply: Jan 23, 2011 1:28 PM by mrdior RSS

    Exporting individual pages to PDF / Indesign

    jmituzas

      Have downloaded some sample scripts from

       

      http://www.adobe.com/products/indesign/scripting/index.html

       

      This is all well and all but it creates a document and prints it as individual pdf files. Yes this is what I wanted but how can I change the script to either let me browse for or call to my own already created .indd file?

       

      Please help.

       

      Thanks in advance,

      regards,

       

      jmituzas

        • 1. Re: Exporting individual pages to PDF / Indesign
          Shonkyin Community Member

          Hi,

           

          Find below code, now this will run on open indesing file.

           

          //ExportEachPageAsPDF.jsx
          //An InDesign CS4 JavaScript
          //
          //Exports each page of an InDesign CS document as a separate PDF to 
          //a selected folder using the current PDF export settings.
          //Display a "choose folder" dialog box.
          
          main();
          
          function main(){
              mySnippet();
          }
          
          function mySnippet(){
               //<fragment>
               var myPageName, myFilePath, myFile;
               var myDocument = app.activeDocument;
               var myBaseName = myDocument.name.replace(/\.indd/, "");
               var myPDFExportPreset = app.pdfExportPresets.item("[Press Quality]");
               for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
                    myPageName = myDocument.pages.item(myCounter).name;
                    app.pdfExportPreferences.pageRange = myPageName;
                    //The name of the exported files will be the base name + the 
                    //page name + ".pdf". If the page name contains a colon (as it will 
                    //if the document contains sections), then remove the colon.
                    var myRegExp = /:/gi;
                    myPageName = myPageName.replace(myRegExp, "_");
                    myFilePath = Folder.desktop + "/" + myBaseName + "_" + myPageName + ".pdf";
                    myFile = new File(myFilePath);
                    myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset);
               }
          }
          
          

           

           

           

          Shonky

          • 2. Re: Exporting individual pages to PDF / Indesign
            jmituzas Community Member

            Thanks for helping... one more thing,

             

            How can I get a prompt asking to Browse for .indd file in question?

            • 3. Re: Exporting individual pages to PDF / Indesign
              Shonkyin Community Member

              You can select InDesign file with below code:

               

              var myINDDfile = File.openDialog( 'Select InDesign file','*.indd',false);
              

               


              Shonky

              • 4. Re: Exporting individual pages to PDF / Indesign
                jmituzas Community Member

                You are awesome! Thanks.

                • 5. Re: Exporting individual pages to PDF / Indesign
                  mrdior Community Member

                  Shonky (or anyone!!)...

                   

                  How can I open a dialogue to choose a path to where I would like the output PDF files to be saved??

                  • 6. Re: Exporting individual pages to PDF / Indesign
                    mrdior Community Member

                    Scratch that. I found the solution here... after coming up empty-handed in the ID Scripting Tutorial...

                     

                    var myPath= Folder.selectDialog ("Choose a Folder");

                    myPath = myPath + "/";