I am attempting to read the saved file version of an Adobe Illustrator file created in any version of Illustrator. My code will read files created in Illustrator 10 and earlier currently. Files created in the CS Versions of Illustrator can be read but will not read far enough into the file to find the correct string that starts where the version information is stored.
I believe this may be a limitation of a string variable in Flex but I am unsure. To locate the version my application is searching for this string in the file "%%Creator:"
. It exists in the first five lines of an AI file created in AI 10 or before. The files created in CS versions contain a very long header that contains all data for the CS versions of Illustrator. But they also contain this searchable string for legacy versions of Illustrator to read the files.
Any help is much appreciated.
My Code:
stream.open(file, FileMode.READ);
var fileContents:String = stream.readUTFBytes(file.size);
stream.close();
if(fileContents.search("%%Creator:")>0)
{
var index:int = fileContents.search("%%Creator:");
index += 32;
version = fileContents.slice(index,index + 4);
}