3 Replies Latest reply on Feb 3, 2016 2:30 AM by DBLjan

    pageRange and app.print

    DBLjan Level 2

      Hi there, im using a batch-print javascript, lets me select a folder and a preset, and prints. No rocketscience.

       

      But, i dont know how to fiddle in a pageRange, since i'm not opening any documents. Does anyone know how to "hotfix" this and quickly house a pagerange in there?

       

      files = myFolder.getFiles("*.indd");
      // app.activeDocument.printPreferences.pageRange = "4";
      app.print(files, false, mypreset);
      
        • 1. Re: pageRange and app.print
          tpk1982 Level 4

          I thought range means you have to give 'from to 'to with hyphen like below:

           

          app.printPreferences.pageRange = "1, 3-6";

           

           

          useful one:

           

          Re: app.swfExportPreferences.pageRange?

          • 2. Re: pageRange and app.print
            Vamitul Level 4

            "app" does not have a printPreferences object, so the simplest way is to actually open each document in turn, set the printPrefs individually (and this is a good time to actually check is the document has a page "4"or whatever you need), print it and then close it.

            • 3. Re: pageRange and app.print
              DBLjan Level 2

              Hmm, i dont have the JS-skills to modify the script to that extend. To try'n'error out how to loop what files = myFolder.getFiles("*.indd") get it will be ages for me.

               

              Since it isnt too much code, maybe you would rearrange it for me? I dont need a fancy pageRange-Dialog, i could just modify the script withing each time i want to print a different page.

               

              function selectPreset() {
              var myPrint = app.printerPresets.everyItem().name;
              var w = new Window ("dialog");
              w.orientation = 'row';
              var myDropDown = w.add ("statictext", undefined, "Print Preset Style Name");
              var myDropDown = w.add ("dropdownlist", undefined, myPrint);
              myDropDown.selection = 0;
              var myButtonGroup =  w.add ("group");
              myButtonGroup.add ("button", undefined, "OK");
              w.center();
              w.show();
              preset_name=myDropDown.selection.text;
              mypreset=app.printerPresets.itemByName(preset_name);
              }
              
              
              function createDialog(folder, allFilesList) {
                  var d, showDialog, winspec;
                  winspec = [
                  "dialog { orientation: 'column', alignChildren: 'top', text: 'Multiple Print',",
                  "  folderPanel: Panel {",
                  "    name: 'Files to Print',",
                  "    alignment: 'fill',",
                  "    StText1: StaticText { },",
                  "    StText2: StaticText { }",
                  " }, okCancelGroup: Group {",
                  "  orientation: 'row', alignment: 'center',",
                  " } ",
                  "}"].join("");
              
                  d = new Window(winspec);
                  d.folderPanel.StText1.text = myFolder.fullName;
                  d.folderPanel.StText2.text = '(Found ' + myAllFilesList.length + ' files)';
                  d.okCancelGroup.add('button', undefined, 'Go', { name: 'ok' } );
                  d.okCancelGroup.add('button', undefined, 'Cancel', { name: 'cancel' } );
              
                  showDialog = d.show();
                  $.writeln("s"+showDialog);
                  return showDialog;
              }
              
              
              var InDesignVersion=app.version.split(".")[0]
              
              var myFolder = Folder.selectDialog();
              if (!myFolder) exit();
              var myAllFilesList = myFolder.getFiles("*.indd");
              
              if (!myAllFilesList.length) {
                  alert("No files to print.");
                  exit();
              }
              
              var myDialogResult = createDialog();
              if (myDialogResult == 2) {
                  exit();
              }
              
              selectPreset()
              
              var i, f, files, uil;
              
              suil = app.scriptPreferences.userInteractionLevel;
              app.scriptPreferences.userInteractionLevel =
                UserInteractionLevels.neverInteract;
              
              try {
                files = myFolder.getFiles("*.indd");
                app.print(files, false, mypreset);
              } catch (e) {
                alert("Caught error:" + e);
              } finally {
                app.scriptPreferences.userInteractionLevel = uil;
              }