5 Replies Latest reply on Sep 22, 2015 12:03 AM by Korgpolly

    script to save .pdf with different presets generates wildly different lo-res file size to interactive operation

    Korgpolly Level 1

      The script below is adapted in part from the one given with Illustrator and other bits and pieces I've picked up from the forum.  When I run it on a 15.3Mg .ai file it produces

      .pfs the same size as it would if I created them manually for HQ print and Default; but the low-res option comes out at 9Mg as opposed to the 439K it "should" be.

       

      Please would some kind person advise me how I can amend the script to work as I wish it to: I'd been relying on my custom preset doing the job for me.  Thanks in anticipation.

       

         var jiName=app.activeDocument.name
      
         var pos = jiName.indexOf(".ai"); 
            if (pos > 0){
                jiName=jiName.substr(0,(pos))  
            }
          var pos = jiName.indexOf(".pdf"); 
            if (pos > 0){
               jiName=jiName.substr(0,(pos)) 
            }
          
          var saveProof = new Window ("dialog", "Save Proof");
              saveProof.orientation="column"
              saveProof.alignChildren = "center";
              
        var sPGroup1 = saveProof.add ("group");
              sPGroup1.orientation="column"
              sPGroup1.add ("statictext", undefined, "File Name");
                  
        var save_pdf = sPGroup1.add ('edittext {text:"", characters: 30, justify: "center", active: true}');
              save_pdf.text=jiName+".pdf"
              
        var sPdQButtonGroup = saveProof.add ("group");
              sPdQButtonGroup.alignment = "center"; 
              sPdQButtonGroup.alignChildren="row"
              sPdQButtonGroup.add ("statictext", undefined,"File Quality");
        var HQ=sPdQButtonGroup.add ("radiobutton", undefined, "  HI-RES  ");
        var IDefault=sPdQButtonGroup.add ("radiobutton", undefined, "  Standard  ");
        var lowres=sPdQButtonGroup.add ("radiobutton", undefined, "  low-res  ");
              sPdQButtonGroup.children[1].value = false;
              sPdQButtonGroup.children[3].value = false;
              sPdQButtonGroup.children[2].value = true;
              sPdQButtonGroup.active=true;
              sPdQButtonGroup.visible=true;
              
        var sPButtonGroup = saveProof.add ("group");
              sPButtonGroup.alignment = "center"; 
              sPButtonGroup.alignChildren="row"      
                  
        var sPok=sPButtonGroup.add ("button", undefined, "Save Proof");
        var sPcancel=sPButtonGroup.add ("button", undefined, "Exit");
              sPButtonGroup.active = true;
                 
              sPcancel.onClick = function() {
                 //sP_ok=false;
                 saveProof.close();
                             }
              sPok.onClick = function() {
                  
                    app.executeMenuCommand('save'); // save existing Illustrator file
                    
                    var my_pdf= new File("users/Les/Desktop/PROOFS/"+save_pdf.text); //Full File Path 
                    
                    saveFileToPDF(my_pdf);
                                
                    function saveFileToPDF(myFile){  
                    //Setup Save Options for PDF  
                    var saveOpts = new PDFSaveOptions();  
                    saveOpts.compatibility = PDFCompatibility.ACROBAT6;
                    saveOpts.generateThumbnails = true;  
                    saveOpts.preserveEditability = true;
                    saveOpts.requirePermissionPassword = true;  
                    saveOpts.permissionPassword = "*-*-*-*-*-*";
                    saveOpts.compressArt = true; //default
                   saveOpts.embedICCProfile = true;
                   saveOpts.enablePlainText = true;
                   saveOpts.generateThumbnails = true; // default
                   saveOpts.optimization = true;
                   saveOpts.pageInformation = true;
                    
                    if (HQ.value==true){
                      saveOpts.pDFPreset = '[High Quality Print]';
                    }
                
                    if (IDefault.value==true){
                      saveOpts.pDFPreset = '[Illustrator Default]';
                    }
                
                    if (lowres.value==true){
                      saveOpts.compatibility = PDFCompatibility.ACROBAT4;
                      saveOpts.pDFPreset = 'Smallest File Size v4';
                    }
                
                    //  
                    var originalInteractionLevel = userInteractionLevel;        //save the current user interaction level  
                    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;      //Set user interaction level to suppress alerts  
                    app.activeDocument.saveAs(myFile,saveOpts);        //Save File  
                    userInteractionLevel = originalInteractionLevel;        //Set user interaction level back to original settings 
                                  }
                              
                    saveProof.close();
                    
              }
                  
        saveProof.active=true
        saveProof.show()