3 Replies Latest reply on Aug 26, 2012 12:47 PM by beh_gras_beh

    Choose resolution


      Dear Indesign Scripters,


      With below script users can export each page to JPG with a pre-defined resolution.

      My question is how can i make the script that users can choose the resolution.


      The quality of the JPG I'm going to try to build myself because I also trying to learn something.


      The script:

      var myDoc = app.documents[0];
      app.scriptPreferences.version = "6.0"
      if(app.documents.length != 0){   
          var myFolder = Folder.selectDialog ("Choose a Folder");   
          if(myFolder != null){   
          alert("Please open a document and try again.");   
      function myExportPages(myFolder){   
          var myDocument = app.activeDocument;   
          var myDocumentName = myDocument.name;   
      app.jpegExportPreferences.resolution = 72;
      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;
      app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
      app.scriptPreferences.version = "7.0"
      app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.CMYK;
      app.scriptPreferences.version = "6.0"
      app.activeDocument.sections.everyItem().includeSectionPrefix = false; 
      p = app.activeDocument.pages.everyItem().getElements();
      for (i = 0; i < p.length; i++)
      f = File (myFolder + "/" + p[i].textFrames.item ('script_label').contents + ".jpg");
      app.jpegExportPreferences.pageString = p[i].name; 
      app.activeDocument.exportFile (ExportFormat.jpg, f );

      Greetings from Holland

        • 1. Re: Choose resolution
          Muppet Mark Level 5

          You need to look at Peter's scriptUI for dummies pdf that will show you how to add dialogs with control objects to your scripts… You probably just need a dropdownlist and a slider… Links are in the featured content of this forum…

          • 2. Re: Choose resolution
            Harbs. Level 6

            A simple InDesign dialog with a text input should be adequate for requesting the resolution.


            You script displays a very bad practice of changing the script version without changing it back. That could mess up future scripts.


            When changing the script version, always wrap the script in a try/finally:


            finally {
              app.scriptPreferences.version = parseFloat(app.version);


            You can optionally catch the error too...



            • 3. Re: Choose resolution
              beh_gras_beh Level 1

              Thanks Harbs!


              Very usefull!


              I'm still learning, struggeling with the dropdownlist now.

              So I hope it wil work.