5 Replies Latest reply on Feb 3, 2011 8:31 AM by Seth McGraw

    .ai files not cooperating

    Seth McGraw Level 1

      We have a script for InDesign CS5,4,3,2, and CS that preps, flightchecks and outputs a PDF file for customer submission. When the customer uses an ".ai" (illustrator) file or outputs an illustrator ".eps" file and uses it on the page, the script fails with an error stating that it can't determine the color space of an object. If the offending ".ai" or illustrator ".eps" file is removed the script runs smoothly.


      Any ideas what may be causing this problem?


      Let me know if more info is needed.




        • 1. Re: .ai files not cooperating
          [Jongware]-9BC6tI Level 4

          The script probably checks the property "space" (for "Color Space") of every item of type Graphic -- it should only do so on bitmapped images (TIFF, JPEG, PSD -- you know). Vector files, such as PDF, EPS, and AI cannot provide this information, because it's possible to insert different bitmaps with different color spaces together into one single 'vector' image.


          The object "Graphic" is a base class for all image subtypes -- for "Image" alone, it should check the color space.


          Contact the author of the script (if it was me, I apologize in advance ) and ask for a fix. "Best" would be to check the image type before checking its space, but "good enough" may be to wrap the color space test in a try .. catch construction.

          1 person found this helpful
          • 2. Re: .ai files not cooperating
            Seth McGraw Level 1

            We actually developed it in-house. We just couldn't figure out what to do about it.

            When you mention to wrap it in a try--catch construction, what might be the proper syntax for this (graphic vs. image)?



            • 3. Re: .ai files not cooperating
              [Jongware]-9BC6tI Level 4

              It has nothing to do with the image type an sich.


              try {
                 colorSpace = ... // whatever you use to check comes in here
              } catch (e)
                // an error happened


              -- the idea is to test the color space, but if it fails on an image type that doesn't have one, fail silently. If you are interested in which images it fails on, you can do stuff in the "an error happened" section, but if you just want the script to continue, put nothing in there.


              It's important to note that the try .. catch will continue with the line immediately after it, whether it caught the error or not. So it's up to you to make sure the script can continue at that point -- it's no use, for example, to try to set a variable inside the try .. catch block and then happily access it right after (it'll not exist if the error was caught).


              Without seeing the entire script, this is all I can offer.

              1 person found this helpful
              • 4. Re: .ai files not cooperating
                Muppet Mark-QAl63s Level 4

                As of CS (v10) your illustrator files should be of single colour mode… So you should be able to test these… Some thing like…


                var f = new File('~/Desktop/SomeFile.ai');
                function aiMode(f) {
                     var mode = null;     
                     do {
                          var line = f.readln();
                     } while (!/^%AI\d_ColorModel: [1-2]/.test(line));
                     var m = line.match(/\d$/g);     
                     m == 1 ? mode = 'RGB' : mode = 'CMYK';
                     return mode;


                This should work for Illustrator '.ai'  and maybe '.pdf' files too but that could depend on the pdf options used (I've not checked that yet)…

                • 5. Re: .ai files not cooperating
                  Seth McGraw Level 1

                  It may be a bit before I can check this out, but I'm going to go ahead and give you a "correct answer" now. I may message you later with a few more questions if its ok. I appreciate the help.