4 Replies Latest reply on Mar 25, 2013 12:58 PM by KuddRoww

    Exporting PDFs with document filename

    dinosaurbruce

      I am new to InDesign scripting and I'm am trying to edit the Adobe ExportPDFWithPreset.jsx so that it will just name the PDF export the same as the InDesign file name. Currently it just names it ExportPDFWithPreset.pdf. How would I go about doing that?

       

       

      //ExportPDFWithPreset.jsx

      //An InDesign CS6 JavaScript

      //

      //Shows how to export as PDF using a given PDF export preset.

      main();

      function main(){

          mySnippet();

          myTeardown();

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

                if(app.documents.length != 0){

                          if (app.activeDocument.stories.length != 0){

                          }

                          else{

                                    alert("The document does not contain any text. Please open a document containing text and try again.");

                          }

                }

                else{

                          alert("No documents are open. Please open a document and try again.");

                }

      }

      //<snippet>

      function mySnippet(){

                //<fragment>

                var myDocument = app.documents.item(0);

                //The document.export parameters are:

                //Format as (use either the ExportFormat.pdfType enumeration

                //or the string "Adobe PDF")

                //To as File

                //ShowingOptions as boolean (setting this option to true displays the

                //PDF Export dialog box)

                //Using as PDF export preset (or a string that is the name of a

                //PDF export preset)

                //The default PDF export preset names are surrounded by square breackets

                //(e.g., "[High Quality Print], [Press Quality], or [Smallest File Size]").

                var myPDFExportPreset = app.pdfExportPresets.item("[Press Quality]");

                myDocument.exportFile(

                          ExportFormat.pdfType,

                          File(Folder.desktop + "/ExportPDFWithPreset.pdf"),

                          false,

                          myPDFExportPreset

                );

          //</fragment>

      }

      //</snippet>

      //<teardown>

      function myTeardown(){

      }

      //</teardown>