3 Replies Latest reply on Feb 4, 2013 12:56 AM by R-Bala-Krishnan

    Click to cancel Export to PDF

    shilpa25 Level 1

      hi Everybody,

       

      I have problem with my script..... when i Click "OK" button, PDF export... also when I click "Cancel" button, also PDF export.... ( i assume, button Cancel should be in seperate group).

       

      can anybody tweak this... so when i click Cancel.... PDF should not export...

       

        var myCapsWin = new Window('dialog', 'Export PDF with preflight errors');

          myCapsWin.orientation = 'row';       

          myCapsWin.minimumSize = [230, 50];

          with(myCapsWin){

              myCapsWin.optPNL = add('panel');

              myCapsWin.optPNL.orientation = 'row';

              myCapsWin.btnGrp = add('group');

              myCapsWin.btnGrp.orientation = 'row';

              with(myCapsWin.btnGrp){

                  myCapsWin.btnGrp.btnOK = add('button', undefined, 'OK');

                  myCapsWin.btnGrp.btnCancel = add('button', undefined, 'Cancel');

                 

              }

          };

          myCapsWin.center();

          var myCaps = myCapsWin.show();

       

       

          if(myCaps == true){

      var myBar = new Window('palette', ' Export PDF Generating....', undefined, {closeButton:false,   maximizeButton:true,   minimizeButton:true });

      myBar.add('progressbar',undefined, 1, 100);

      myBar.children[0].preferredSize = [250,15];

      myBar.show();

      myBar.children[0].value = myBar.children[0].value+10;

      var myPDFFilePath;

      var InDJobOption = app.pdfExportPresets;

      myBar.children[0].value = myBar.children[0].value+10;

      myBar.children[0].value = myBar.children[0].value+20;

      myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split(".INDD")[0]+".pdf";

      myBar.children[0].value = myBar.children[0].value+20;

      app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName);

      myBar.children[0].value = myBar.children[0].value+100;

      myBar.close();

      $.sleep(10);

      exit(0);

      }

      }}

       

       

       

       

      thanks

      shil..

        • 1. Re: Click to cancel Export to PDF
          Adobe-InDesign CS4 Level 1

          Hi shilpa,

           

          Please use the below code... I checked in CS5.5 Version

           

          //======================= Start ============================//

           

          var myCapsWin = new Window('dialog', 'Export PDF with preflight errors');
              myCapsWin.orientation = 'row';       
              myCapsWin.minimumSize = [230, 50];
              with(myCapsWin){
                  myCapsWin.optPNL = add('panel');
                  myCapsWin.optPNL.orientation = 'row';
                  myCapsWin.btnGrp = add('group');
                  myCapsWin.btnGrp.orientation = 'row';
                  with(myCapsWin.btnGrp){
                      myCapsWin.btnGrp.btnOK = add('button', undefined, 'OK');
                      myCapsWin.btnGrp.btnCancel = add('button', undefined, 'Cancel');
                     
                  }
              };

              myCapsWin.center();
              var myCaps = myCapsWin.show();


              if(myCaps == true){
                  var myBar = new Window('palette', ' Export PDF Generating....', undefined, {closeButton:false,   maximizeButton:true,   minimizeButton:true });
                  myBar.add('progressbar',undefined, 1, 100);
                  myBar.children[0].preferredSize = [250,15];
                  myBar.show();
                  myBar.children[0].value = myBar.children[0].value+10;
                  var myPDFFilePath;
                  var InDJobOption = app.pdfExportPresets;
                  myBar.children[0].value = myBar.children[0].value+10;
                  myBar.children[0].value = myBar.children[0].value+20;
                  myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split (".INDD")[0]+".pdf";
                  myBar.children[0].value = myBar.children[0].value+20;
                  app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName);
                  myBar.children[0].value = myBar.children[0].value+100;
                  myBar.close();
                  $.sleep(10);
                  exit(0);
          }

           

          //======================== end ============================//

           

          Please let me know if you have any queries.

           

          Thanks & Regards

          T.R.Harihara SudhaN

          • 2. Re: Click to cancel Export to PDF
            shilpa25 Level 1

            HI ,

             

            i have three brace at the end because of the "else statement" before this script....

             

            that if the indesign file dosent have preflight error,,, the before statement will execute otherwise,,, the Preflight error dialog box will appear...

             

            I am sorry i should have posted the entire script....

             

            function myPrint () {

            var mydoc = app.activeDocument;

            var myParas = mydoc.stories.everyItem().paragraphs.everyItem().getElements();

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

            myPara = myParas[i];

            if (myPara.contents == "XXX")

                alert("The Job has XXX, \r Please WRITE NOTE to XXX ")

                }

             

             

            var myJobOptionName = "XXXPDF"; //Please provide a PDF job option name which is available in InDesign.

            var myOutFolderPathName = "/Users/Desktop/Out/"; //Please change your path as per requirement

            var myProfile = app.preflightProfiles.itemByName("XXX"); //Please change Preflight profile name which is available in InDesign.

            //End of custom fields

             

             

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

                      // Assume the Test preflight profile exists.

             

             

                      //Process the myDoc with the rule

                      var myProcess = app.preflightProcesses.add(myDoc, myProfile);

                      myProcess.waitForProcess();

                      var myResults = myProcess.processResults;

                var myTest = myResults.indexOf("None");

             

             

            if (myTest == 0)

            {

              var Win = new Window('dialog', 'Export PDF to Print');

                Win.orientation = 'row';       

                Win.minimumSize = [230, 50];

                with(Win){

                    Win.optPNL = add('panel');

                    Win.optPNL.orientation = 'row';

             

             

                    Win.btnGrp = add('group');

                            Win.btnGrp.orientation = 'row';

                

                          with(Win.btnGrp){

                        Win.btnGrp.btnOK = add('button', undefined, 'OK')

                        }

                        //btnOK.onClick = PreflightError ();

                          with(Win){

                         Win.btnGrp1 = add('group');

                        Win.btnGrp1.btnCancel = add('button', undefined, 'Cancel')

                        Win.btnGrp1.btnCancel.onClick = "";

                    }

                };

                Win.center();

                Win.show();   

            //Cancel.onClick = doExit();

            var myPDFFilePath;

            var InDJobOption = app.pdfExportPresets;

            myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split(".INDD")[0]+".pdf";

            app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName);

            }

            else

            {

            ...... )+ the previous post)...

             

             

            any help on this...

            thanks

            shil....

            • 3. Re: Click to cancel Export to PDF
              R-Bala-Krishnan Level 2

              myPrint () ;

              function myPrint () {
                  var mydoc = app.activeDocument;
                  var myParas = mydoc.stories.everyItem().paragraphs.everyItem().getElements();
                  for (i=0; i<myParas.length; i++) {
                      myPara = myParas[i];
                      if (myPara.contents == "XXX")
                      alert("The Job has XXX, \r Please WRITE NOTE to XXX ")
                      }
                  var myJobOptionName = "XXXPDF"; //Please provide a PDF job option name which is available in InDesign.
                  var myOutFolderPathName = "/Users/Desktop/Out/"; //Please change your path as per requirement
                  var myProfile = app.preflightProfiles.itemByName("bala"); //Please change Preflight profile name which is available in InDesign.
                  var myDoc = app.documents.item(0);
                  var myProcess = app.preflightProcesses.add(myDoc, myProfile);
                  myProcess.waitForProcess();
                  var myResults = myProcess.processResults;
                  var myTest = myResults.indexOf("None");
                  var PDFExport = false;
                  if (myTest == 0){
                      var Win = new Window('dialog', 'Export PDF to Print');
                      Win.orientation = 'row';       
                      Win.minimumSize = [230, 50];
                      with(Win){
                          Win.optPNL = add('panel');
                          Win.optPNL.orientation = 'row';
                          Win.btnGrp = add('group');
                          Win.btnGrp.orientation = 'row';
                          with(Win.btnGrp){
                              Win.btnGrp.btnOK = add('button', undefined, 'OK')
                              }
                          //btnOK.onClick = PreflightError ();
                          with(Win){
                              Win.btnGrp1 = add('group');
                              Win.btnGrp1.btnCancel = add('button', undefined, 'Cancel')
                              //Win.btnGrp1.btnCancel.onClick = "";
                               Win.hide();
                              }
                          };
                      Win.center();
                      //Cancel.onClick = doExit();
                      Win.btnGrp.btnOK.onClick = function ()  { PDFExport = true; Win.hide();} //To overcome model dialog box error
                      Win.show();   
                      if (PDFExport == true){
                          var myPDFFilePath;
                          var InDJobOption = app.pdfExportPresets;
                          myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split (".INDD")[0]+".pdf";     
                          app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName);
                          }
                      }
                  else{
                      var myCapsWin = new Window('dialog', 'Export PDF with preflight errors');
                      myCapsWin.orientation = 'row';       
                      myCapsWin.minimumSize = [230, 50];
                      with(myCapsWin){
                          myCapsWin.optPNL = add('panel');
                          myCapsWin.optPNL.orientation = 'row';
                          myCapsWin.btnGrp = add('group');
                          myCapsWin.btnGrp.orientation = 'row';
                          with(myCapsWin.btnGrp){
                          myCapsWin.btnGrp.btnOK = add('button', undefined, 'OK');
                          myCapsWin.btnGrp.btnCancel = add('button', undefined, 'Cancel');
                          }
                      };
                  myCapsWin.center();
                  var myCaps = myCapsWin.show();
                  if(myCaps == true){
                      var myBar = new Window('palette', ' Export PDF Generating....', undefined, {closeButton:false,   maximizeButton:true,   minimizeButton:true });
                      myBar.add('progressbar',undefined, 1, 100);
                      myBar.children[0].preferredSize = [250,15];
                      myBar.show();
                      myBar.children[0].value = myBar.children[0].value+10;
                      var myPDFFilePath;
                      var InDJobOption = app.pdfExportPresets;
                      myBar.children[0].value = myBar.children[0].value+10;
                      myBar.children[0].value = myBar.children[0].value+20;
                      myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split (".INDD")[0]+".pdf";
                      myBar.children[0].value = myBar.children[0].value+20;
                      app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName);
                      myBar.children[0].value = myBar.children[0].value+100;
                      myBar.close();
                      $.sleep(10);
                      exit(0);
                      }
                  }}