1 Reply Latest reply on Oct 2, 2009 9:46 AM by zonoid

    Get version from illustrator files?

    zonoid

      I currently am able to open an Illustrator file created in Illustrator 10 or earlier and pull the file version with this code.

       

      public function versionCheck(file:File):void{
                  var stream:FileStream = new FileStream();
                  var version:String = null;
                 
                  stream.open(file, FileMode.READ);
                  var fileContents:String = stream.readUTFBytes(stream.bytesAvailable);
                  stream.close();
                                        
                  if(fileContents.search("%%Creator:")>0){
                      var index:int = fileContents.search("%%Creator:");
                      index += 32;
                      version = fileContents.slice(index,index + 4);             
                  }

      }

       

      I am now trying to do the same with files created in any of the Illustrator CS versions.  For some reason the stream reads about half the file then dies.  I have reconstructed a text file to make sure it only pulling partial data.  The CS files have the %%Creator string in them but for some reason my code will not read far enough into the file to determine this.   I am wondering if this is a limitation in Flex or if it is a limitation of UTF encoding since image data is stored as PGF data inside CS files.  I am working with files that range from 50KB to about 800KB.