4 Replies Latest reply on Jun 13, 2017 11:03 PM by spaciousmind

    need to read active files illustrator save options

    spaciousmind Level 1

      okay so when you do a save as menu command from illustrator and choose .ai..... you get a number of check boxes to choose how to save it.
      The one I'm interested in is the 'pdf compatible' one. it can affect the file size and save times dramatically and I don't really need it left on in many cases.

       

      I want to be able to turn it off with an initial save as command and then if I execute a script to export a pdf then I'd like it to first save the .ai file but stick to what I chose in the first place. The sourceDoc.save(); command I was using up until now just seems to force the default options back onto the file (turning pdfCompatible back on in the process)

       

      So I made some changes to my script so I could use the saveAs command, first for the .ai file and then for the .pdf file.
      However, I can't figure out how to read the pdfCompatible setting from the file and use that, the only way I can turn it off is if I force it in the script like this:

       

      var illustratorSaveOpts = new IllustratorSaveOptions();

      illustratorSaveOpts.pdfCompatible = false;

                      sourceDoc.saveAs( targetFileAI, illustratorSaveOpts );

                      sourceDoc.saveAs( targetFile, pdfSaveOpts );

                      sourceDoc.close();

       

      I need it to just read what's already in the file and use those options..... just like picking 'save' from the menu.

      It's probably something really basic but I've tried everything and can't figure it out. any help would be greatly appreciated!
      Cheers

        • 1. Re: need to read active files illustrator save options
          moluapple Level 4

          Hi,you mean

          just like picking 'save' from the menu.

          so instead of use sourceDoc.save(), you can use:

          app.executeMenuCommand('save');

          Then the file will be saved with the last used save options, as your expect.

           

          BTW: you can use this snippet to trun off 'pdf compatible' checkbox by default when saving all documents created after that.

          app.preferences.setBooleanPreference('aiFileFormat/PDFCompatibility', false);
          
          1 person found this helpful
          • 2. Re: need to read active files illustrator save options
            spaciousmind Level 1

            Thanks moluapple, these are both very helpful,
            I didn't even know about the app.executeMenuCommand('save'); command and I probably should have been using that one instead of sourceDoc.save(); all along!

            However, it's fine if I just want to save and close my document, but I just realised that I still need to be able to use the SaveAs command in some scripts because to export my PDF's I want to use a script with a saveAs and then save the document back as an AI file so I can continue working on the AI file after that without having to remember to choose it from a menu again. So for example I want to do something like this:

             

                            sourceDoc.saveAs( targetFilePDF1, pdfSaveOpts1 );

                            sourceDoc.saveAs( targetFilePDF2, pdfSaveOpts2 ):

                            sourceDoc.saveAs( targetFileAI, illustratorSaveOpts );

             

            so as you can see here, I can't just use the executeMenuCommand('save');at the end because it would just keep saving my working file as a .pdf. So at the start I still need to somehow be able to call up the existing IllustratorSaveOptions of the document and save them into my illustratorSaveOpts variable so I can call them up when resaving the AI file again.

             

            sorry for my long winded explanation, I hope you can get what I mean!

            • 3. Re: need to read active files illustrator save options
              moluapple Level 4

              Yes, I know, but we just can not get the save options been used.

              And, instead of resaving the AI file again, why not close the active document, and reopen the AI file to continue working on it?

              1 person found this helpful
              • 4. Re: need to read active files illustrator save options
                spaciousmind Level 1

                Oh I see. I figured it would be an easy enough thing to do.

                 

                I guess I'll just have to use a workaround and force it to stay off in all of my scripts and just create a seperate script for instances where I want to keep pdfcompatible turned on (probably not too often). seems like a clumsy solution but will do the trick


                I had indeed been closing and reopening the document back up until now but it slows down my workflow too much, particularly on larger files. just saving a .pdf and then saving an .ai is generally much much faster.

                 

                Thanks for your help moluapple!