0 Replies Latest reply on Jan 28, 2014 12:08 PM by creativejoan0425

    Print(false)

    creativejoan0425 Level 1

      my script showm below, if I use myDoc.print(false) will have R6025 Run time Error, but If I use myDoc.print(true) or myDoc.print() that will be ok, can anyone fix it?

       

      #targetengine "myHandler";

       

      if(app.documents.length > 0){

      var myDoc = app.activeDocument;

      var myPrintPrefs = myDoc.printPreferences;

       

       

      if (app.printerPresets.item("PDF_fit on paper") == null) {

         alert("Printer preset \"PDF_fit on paper\" is not installed.");

         exit();

      }

      else {

         myPrintPrefs.activePrinterPreset = app.printerPresets.item("PDF_fit on paper"); 

      }

       

      for(var i = 0; i < app.documents.length; i++)

      {

                                    if(app.documents[i].undoHistory.length > 0)

      {

                                              if(app.documents[i].textVariables.item("User_id") != null)

                                              {

                                                        app.documents[i].textVariables.item("User_id").variableOptions.c ontents = myLog_status;

                                              }

                                    }

                          }

       

       

      var myDocProof = myDoc.textVariables.item('proof').variableOptions.contents;

      var currentYear = new Date().getFullYear();

      var currentMonth = new Date ().getMonth()+1;

      var currentDate = new Date().getDate();

      var currentHours = new Date().getHours();

      var currentMinutes = new Date().getMinutes();

      var PreMon = ((currentMonth < 10) ? "0" : "")+currentMonth;

      var PreDate = ((currentDate < 10) ? "0" : "")+currentDate;

      var PreHours = ((currentHours < 10) ? "0" : "")+currentHours;

      var PreMinutes = ((currentMinutes < 10) ? "0" : "")+currentMinutes;

       

       

      var myFileName = myDoc.name.replace(/\.indd$/i, "") + "_" + myDocProof.replace(/st Proof|nd Proof|rd Proof|th Proof| Proof/i, "P") + "_" + currentYear + PreMon + PreDate + "_" + PreHours + PreMinutes +".ps";

      var myPsFolder = new Folder("~desktop/" + "/LowRes/In");

      var myFile = new File(myPsFolder + "/" + myFileName);

      myPrintPrefs.printFile = myFile;

      myDoc.print(false);

      alert(myFileName.replace(/\.ps$/i, ".pdf").replace(/%20/g, " ")+"\rSmallest File Size PDF Done!");

                          }

       

       

      below is my part of login script:

       

      funEventListener();

       

      function funEventListener() {

                var myEventNames = ["beforeQuit", "beforeOpen", "afterNew", "afterOpen", "beforeClose", "afterSave", "afterSaveAs", "afterSaveACopy", "afterPrint", "afterExport", "beforeSave", "beforeSaveAs", "beforeSaveACopy", "beforePrint", "beforeExport"];

                for (var i = 0; i < myEventNames.length; i++) {

                          app.addEventListener(myEventNames[i], funEvent);

                }

       

       

                if (myLog_status == "undefined" && myEvent.eventType != "beforeQuit") {

                          myEvent.stopPropagation();

                          myEvent.preventDefault();

                          return;

                }

                var myString = "";

                if (myEvent.target.constructor.name == "Document") {

                          myDocument = myEvent.target;

                          if (myEvent.eventType == "afterNew") myString = "Opened a New Document.";

                          if (myEvent.eventType == "afterOpen") myString = "Opened File " + (myDocument.saved ? myDocument.fullName : myDocument.name + " [Converted]");

                          if (myEvent.eventType == "beforeClose") myString = myDocument.saved ? "Closed File " + myDocument.fullName : "Closed New Document without saving.";

                          if (myEvent.eventType == "afterSave") myString = "Saved File " + myDocument.fullName;

                          if (myEvent.eventType == "afterSaveAs") myString = "Saved File (Save As) " + myDocument.fullName;

                          if (myEvent.eventType == "afterSaveACopy") myString = "Saved File (Save A Copy) " + myDocument.fullName;

                          if (myEvent.eventType == "afterPrint") myString = myDocument.saved ? "Printed " + myDocument.fullName : "Printed New Document.";

               if (myEvent.eventType == "afterExport") myString = myDocument.saved ? "Exported " + myDocument.fullName : "Exported New Document.";

               if (myEvent.eventType == "beforeSave" || myEvent.eventType == "beforeSaveAs" || myEvent.eventType == "beforeSaveACopy" || myEvent.eventType == "beforePrint" || myEvent.eventType == "beforeExport") {

                                    for (var i = 0; i < app.documents.length; i++) {

                                              if (app.documents[i].undoHistory.length > 0) {

                                                        if (app.documents[i].textVariables.item("User_id") != null) {

                                                                  app.documents[i].textVariables.item("Us er_id").variableOptions.contents = myLog_status;

                                                        }

                                              }

                                    }

                          }

                } else if (myEvent.target.constructor.name == "LayoutWindow") {

                          if (myEvent.eventType == "afterOpen") {

                                    app.activeDocument.stories.everyItem().trackChanges = true;

                          }

                }

                if (myString) funWriteLogFile(myLog_status, myString);

       

       

                function funGetPhaseName(myPhase) {

                          switch (myPhase) {

                          case EventPhases.atTarget:

                                    myPhaseName = "At Target";

                                    break;

                          case EventPhases.bubblingPhase:

                                    myPhaseName = "Bubbling";

                                    break;

                          case EventPhases.done:

                                    myPhaseName = "Done";

                                    break;

                          case EventPhases.notDispatching:

                                    myPhaseName = "Not Dispatching";

                                    break;

                          }

                          return myPhaseName;

                }

      }