20 Replies Latest reply on Dec 6, 2018 12:55 PM by shaylag45954664

    Script to Export Multiple PDFs at Once

    rahulb1976 Level 1

      Hi All

       

      I’m trying to find out how to export two PDF's at once from Indesign CC. I'm aiming to get 1 PDFx-1a PDF (High res with crop and bleed) and 1 smallest File Size (Cropped, no marks)? Could you point me in the right direction or if anyone has a working script I could use that would be amazing. My brain is going to fall out my ears.

       

      Many thanks

       

      Rahul

        • 2. Re: Script to Export Multiple PDFs at Once
          rahulb1976 Level 1

          Thank you however I've tried this but the coding is incorrect. Could you resupply it on here? I keep getting an error with it.

          Want to test this today 20th April if possible. Many thanks.

          • 3. Re: Script to Export Multiple PDFs at Once
            [Jongware] Most Valuable Participant

            Why not share the error? It may help us help you.

            • 4. Re: Script to Export Multiple PDFs at Once
              rahulb1976 Level 1

              Got an error with it - I don't know anything about scripts, so any help or reconfiguration would be amazing!

              // BS"D

              // All rights reserved (c) 2015 by Id-Extras.com

              // Free to use and modify but do not delete this copyright attribution.

              // This script will export 2 pdfs of the current document

              // Choose the PDF presets by altering their names below

              // The second PDF gets a suffix added to its name.

              // Modify the line below beginning name2 = to change the suffix.

              // For more InDesign scripts: www.Id-Extras.com

              d = app.activeDocument;

              // Here you can choose the PDF preset

              preset1 = app.pdfExportPresets.itemByName("200dpi");

              preset2 = app.pdfExportPresets.itemByName("300dpi");

              if (!(preset1.isValid && preset2.isValid)){

              alert("One of the presets does not exist. Please check spelling carefully.");

              exit();

              }

              if (d.saved){

              thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";

              thePath = String(new File(thePath).saveDlg());

              }

              else{

              thePath = String((new File).saveDlg());

              }

              thePath = thePath.replace(/\.pdf$/, "");

              name1 = thePath.replace(/AW$/, "LR")+".pdf";

              name2 = thePath.replace(/AW$/, "HR") +".pdf";

              d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

              d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

              Screen Shot 2018-04-20 at 09.26.33.png

              • 5. Re: Script to Export Multiple PDFs at Once
                Peter Kahrel Adobe Community Professional & MVP

                Looks as if you're treating this as an AppleScript. But it's JavaScript.

                2 people found this helpful
                • 6. Re: Script to Export Multiple PDFs at Once
                  rahulb1976 Level 1

                  Hi Peter thanks for this. If it does work - I know its a silly question but how do I make this work with indesign? I know nothing about scripts - apple or java. Does this script work?

                  • 7. Re: Script to Export Multiple PDFs at Once
                    Peter Kahrel Adobe Community Professional & MVP

                    Copy the script to InDesign's script folder, then run it from InDesign's Scripts panel. See here for details:

                     

                    https://indesignsecrets.com/how-to-install-scripts-in-indesign.php

                     

                    P.

                    1 person found this helpful
                    • 8. Re: Script to Export Multiple PDFs at Once
                      rahulb1976 Level 1

                      Peter - great work - however can you tell me what im doing wrong. I'm almost there but not sure about the characters for the indesign pdf presets.

                       

                      d = app.activeDocument;

                      // Here you can choose the PDF preset

                      preset1 = app.pdfExportPresets.[HighQualityPrint]("300dpi");

                      preset2 = app.pdfExportPresets.[Smallest File Size]("100dpi");

                      if (!(preset1.isValid && preset2.isValid)){

                      alert("One of the presets does not exist. Please check spelling carefully.");

                      exit();

                      }

                      if (d.saved){

                      thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";

                      thePath = String(new File(thePath).saveDlg());

                      }

                      else{

                      thePath = String((new File).saveDlg());

                      }

                      thePath = thePath.replace(/\.pdf$/, "");

                      name1 = thePath.replace(/AW$/, "LR")+".pdf";

                      name2 = thePath.replace(/AW$/, "HR") +".pdf";

                      d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

                      d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);Screen Shot 2018-04-20 at 15.32.17.png

                       

                      Cheers for your help so far, greatly appreciated.

                      • 9. Re: Script to Export Multiple PDFs at Once
                        Peter Kahrel Adobe Community Professional & MVP

                        You'll have to specify PDF presets that exist on your disk. This one:

                         

                        preset1 = app.pdfExportPresets.[HighQualityPrint]("300dpi");

                         

                        should be this:

                         

                        preset1 = app.pdfExportPresets.item ('[High Quality Print]');

                         

                        and for preset2 you should use a similar format.

                         

                        (mind the spaces). The ones in Ariel's script are specific for his system (sorry, Ariel, I seem to have hijacked this thread. . .)

                         

                        P.

                        2 people found this helpful
                        • 10. Re: Script to Export Multiple PDFs at Once
                          rahulb1976 Level 1

                          Okay - so the script worked! Yay! however its only creating one pdf - not two and its not renaming _LR _HR. I dont have a clue why it's working completley. Ive created two presets myself Print 1 and Lowres as test presets. Only one is working. See Code. I'm happy to wait on this, but just really need it by the end of next week. So close I can feel it!

                           

                          d = app.activeDocument;

                          // Here you can choose the PDF preset

                          preset1 = app.pdfExportPresets.item ('Print1');

                          preset2 = app.pdfExportPresets.item ('Lowres');

                          if (!(preset1.isValid && preset2.isValid)){

                          alert("One of the presets does not exist. Please check spelling carefully.");

                          exit();

                          }

                          if (d.saved){

                          thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";

                          thePath = String(new File(thePath).saveDlg());

                          }

                          else{

                          thePath = String((new File).saveDlg());

                          }

                          thePath = thePath.replace(/\.pdf$/, "");

                          name1 = thePath.replace(/AW$/, "LR")+".pdf";

                          name2 = thePath.replace(/AW$/, "HR") +".pdf";

                          d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

                          d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

                          • 11. Re: Script to Export Multiple PDFs at Once
                            rahulb1976 Level 1

                            Okay - so the script worked! Yay! however its only creating one pdf - not two and its not renaming _LR _HR. I dont have a clue why it's working completly. Ive created two presets myself Print 1 and Lowres as test presets. Only one is working. See Code. I'm happy to wait on this, but just really need it by the end of this week. So close I can feel it!

                             

                            d = app.activeDocument;

                            // Here you can choose the PDF preset

                            preset1 = app.pdfExportPresets.item ('Print1');

                            preset2 = app.pdfExportPresets.item ('Lowres');

                            if (!(preset1.isValid && preset2.isValid)){

                            alert("One of the presets does not exist. Please check spelling carefully.");

                            exit();

                            }

                            if (d.saved){

                            thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";

                            thePath = String(new File(thePath).saveDlg());

                            }

                            else{

                            thePath = String((new File).saveDlg());

                            }

                            thePath = thePath.replace(/\.pdf$/, "");

                            name1 = thePath.replace(/AW$/, "LR")+".pdf";

                            name2 = thePath.replace(/AW$/, "HR") +".pdf";

                            d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

                            d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

                            • 12. Re: Script to Export Multiple PDFs at Once
                              Peter Kahrel Adobe Community Professional & MVP

                              Looks as if the script expects the names of the InDesign files to end in AW. Try this:

                               

                              name1 = thePath + "LR.pdf";
                              name2 = thePath + "HR.pdf";
                              
                              2 people found this helpful
                              • 13. Re: Script to Export Multiple PDFs at Once
                                rahulb1976 Level 1

                                Fantastic - Thanks very much for your help! Greatly appreciated!

                                 

                                Rahul

                                • 14. Re: Script to Export Multiple PDFs at Once
                                  TᴀW Adobe Community Professional & MVP

                                  Thanks for the help, Peter!

                                   

                                  The script that rahul1976 is posting here has been modified (possibly by me for someone else). The original version on the website that I linked to initially should work fine as is (see my initial post above).

                                   

                                  Ariel

                                  • 15. Re: Script to Export Multiple PDFs at Once
                                    rahulb1976 Level 1

                                    Thanks guys - Ariel your right I couldn't figure out the bit where I wanted to customise it.

                                    Many thanks

                                    • 16. Re: Script to Export Multiple PDFs at Once
                                      charur94718007 Level 2

                                      I hope this change in script will help you

                                       

                                      d = app.activeDocument; preset1 = app.pdfExportPresets.itemByName("[PDF/X-1a:2001]"); preset2 = app.pdfExportPresets.itemByName("[Smallest File Size]"); if (!(preset1.isValid && preset2.isValid)) { alert("One of the presets does not exist. Please check spelling carefully."); exit(); } if (d.saved) { thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf"; thePath = String(new File(thePath).saveDlg()); } else { thePath = String((new File).saveDlg()); } thePath = thePath.replace(/\.pdf$/, ""); name1 = thePath + "_LR.pdf"; name2 = thePath + "_HR.pdf" d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);
                                      
                                      1 person found this helpful
                                      • 17. Re: Script to Export Multiple PDFs at Once
                                        schuba Level 1

                                        Hello

                                         

                                        Im looking for a way to iprove this script a little - that it will

                                        - save pdfs in current indd document location

                                        - add active layer name to output name - filename_layername_LR

                                        anyone could help me with it ?

                                        • 18. Re: Script to Export Multiple PDFs at Once
                                          fragmichnicht Level 1

                                          Hello

                                           

                                          Im looking for a way to iprove this script a little - that it will

                                          - save pdfs in current indd document location

                                          - add active layer name to output name - filename_layername_LR

                                          anyone could help me with it ?

                                          d = app.activeDocument;
                                          preset1 = app.pdfExportPresets.itemByName("[PDF/X-1a:2001]");
                                          preset2 = app.pdfExportPresets.itemByName("[Smallest File Size]");
                                          
                                          if (!(preset1.isValid && preset2.isValid))
                                          {
                                               alert("One of the presets does not exist. Please check spelling carefully.");
                                               exit();
                                          }
                                          
                                          thePath = d.filePath + "/" + d.name.replace(".indd", "") + "_" + d.activeLayer.name;
                                          name1 = thePath + "_HR.pdf";
                                          name2 = thePath + "_LR.pdf";
                                          
                                          //export PDFs as Background Tasks
                                          d.asynchronousExportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); //Hi-Res PDF
                                          d.asynchronousExportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2); //Lo-Res PDF
                                          
                                          • 19. Re: Script to Export Multiple PDFs at Once
                                            schuba Level 1

                                            Thank you very much. it is working, you've made my day

                                            • 20. Re: Script to Export Multiple PDFs at Once
                                              shaylag45954664 Level 1

                                              This is freaking fantastic!! I adjusted the code (below) to save out 3 PDFs at once and it works. YAY! What a time saver.

                                               

                                               

                                              // BS"D

                                              // All rights reserved (c) 2015 by Id-Extras.com

                                              // Free to use and modify but do not delete this copyright attribution.

                                              // This script will export 3 pdfs of the current document

                                              // Choose the PDF presets by altering their names below

                                              // The second PDF gets a suffix added to its name.

                                              // Modify the line below beginning name2 = to change the suffix.

                                              // For more InDesign scripts: www.Id-Extras.com

                                              d = app.activeDocument;

                                              // Here you can choose the PDF preset

                                              preset1 = app.pdfExportPresets.itemByName("PRINT");

                                              preset2 = app.pdfExportPresets.itemByName("PRESS");

                                              preset3 = app.pdfExportPresets.itemByName("[Smallest File Size]");

                                              if (!(preset1.isValid && preset2.isValid)){

                                              alert("One of the presets does not exist. Please check spelling carefully.");

                                              exit();

                                              }

                                              if (d.saved){

                                              thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";

                                              thePath = String(new File(thePath).saveDlg());

                                              }

                                              else{

                                              thePath = String((new File).saveDlg());

                                              }

                                              thePath = thePath.replace(/\.pdf$/, "");

                                              name1 = thePath+"_PRINT.pdf";

                                              // Here you can set the suffix at the end of the name

                                              name2 = thePath+"_PRESS.pdf";

                                              name3 = thePath+"_DIGITAL.pdf";

                                              d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);

                                              d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2);

                                              d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset3);