7 Replies Latest reply on Sep 27, 2017 10:19 PM by et3d_

    Script to Set Default PDF Presets

    joep10800191

      Hi guys -

       

      I've been looking around for awhile for something that would help increase our workflow's efficiency. We have a certain setting we save all of our PDFs in [Color Press], but I can't figure out to set that as the default preset. Every time we Save As PDF, we have to change the PDF setting to [Color Press] manually. 

       

      Is there a way to do so in AI or a script that will Save an open file to a preset instead of the [Illustrator Default]? We would ideally still need the option to choose where to save the PDF, as not all of our PDFs get saved into the same folder as the AI file.

       

      Thanks in advance!

        • 1. Re: Script to Set Default PDF Presets
          Loic Aigon Level 2

          This should help :

          var main = function() {
          var doc;
          if ( !app.documents.length ) {
          return;
          }
          doc = app.activeDocument;
          
          var psts = app.PDFPresetsList;
          var n = psts.length;
          var found = false;
          var presetName = "LUDILABEL", 
          f;
          
          while ( n-- ) {
          if ( psts[n]==presetName) {
          found = true;
          break
          }
          }
          
          if ( !found ) {
          alert("Unable to find pdf preset "+presetName );
          return;
          }
          
          
          var opts = new PDFSaveOptions();
          opts.pDFPreset = presetName;
          
          f= File.saveDialog ("Where di you want to save the file ?");
          
          if ( !f ) return;
          doc.saveAs ( f, opts );
          
          }
          
          
          
          
          main()
          

           

          Loic

          Ozalto | Productivity Oriented - Loïc Aigon

          1 person found this helpful
          • 2. Re: Script to Set Default PDF Presets
            joep10800191 Level 1

            Thank you so much Loic! This seems to be what we were looking for. 2 quick questions for you -

             

            1) Is there a way to keep the filename when saving without having to retype it? When I run this script I have to rename the file (it's blank)

            2) Can the default location to save open up where the AI file is located? Right now it opens up to save in the most recently saved location.

             

            Thank you again, and sorry for the flurry of questions!

            • 3. Re: Script to Set Default PDF Presets
              Loic Aigon Level 2
              var main = function() {  
              var doc;  
              if ( !app.documents.length ) {  
              return;  
              }  
              doc = app.activeDocument;  
              
              var psts = app.PDFPresetsList;  
              var n = psts.length;  
              var found = false;  
              var presetName = "SOME_PRESET_NAME",   
              f;  
              
              while ( n-- ) {  
              if ( psts[n]==presetName) {  
              found = true;  
              break ;
              }  
              }  
              
              if ( !found ) {  
              alert("Unable to find pdf preset "+presetName );  
              return;  
              }  
                
              var opts = new PDFSaveOptions();  
              opts.pDFPreset = presetName;  
              
              
              f = File ( doc.name );
              
              f= f.saveDlg ("Where do you want to save the file ?");  
              
              if ( !f ) return;  
              doc.saveAs ( f, opts );  
                
              }  
              
              
              main();
              

               

              Here it is…

              • 4. Re: Script to Set Default PDF Presets
                joep10800191 Level 1

                Thank you again. I was actually in the middle of editing my second question as I was able to dig a little deeper and found that

                 

                f= Folder(app.activeDocument.path).saveDlg("Choose PDF output folder:");

                 

                would keep the file location the same as the original folder which is exactly what I needed for location.

                 

                Thank you for your time and wisdom! Still learning, slowly but surely.

                • 5. Re: Script to Set Default PDF Presets
                  Loic Aigon Level 2

                  In fact it's even needless. If you need to save it to the exact location of the active document and given it's saved already, you could save directly with

                  doc.saveAs ( File ( app.activeDocument.fullName.replace ( /\.ait?$/i, "")+".pdf" ) );

                  hence avoiding the need of a dialog.

                  2 people found this helpful
                  • 6. Re: Script to Set Default PDF Presets
                    joep10800191 Level 1

                    That makes sense, we do occasionally need to save it in another folder as well so it's nice to have both options.

                     

                    From what I've read, hotkeying a script to an action (Insert Menu Item) will reset every time Illustrator is restarted. There's no known workaround for this yet correct?

                     

                    Thank you again!

                    • 7. Re: Script to Set Default PDF Presets
                      et3d_ Level 1

                      Hi

                      Can you please explain me what I am missing? Thanks

                       

                      function main(){

                          var doc =app.activeDocument;

                          doc.saveAs ( File ( doc.fullName.replace ( /\.ait?$/i, "")+".pdf" ) );

                      }

                       

                      "doc.fullName.replace is not a function"