Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Finding version (compatibility) of current .ai document

New Here ,
Nov 10, 2010 Nov 10, 2010

Is there a way in Javascript to retrieve an information showing in which Adobe Illustrator format was the currently open document saved?

Thanks

franK

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
Nov 10, 2010 Nov 10, 2010

You can read this info from the filehead without opening the file… Should that be your wish…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 10, 2010 Nov 10, 2010

I'm not sure what you mean by "filehead".

I'm on Windoze XP and when I move a mouse pointer over the file, it tells me that the file is Type: Adobe Illustrator Artwork 14.0, but I know for a fact that it's not in CS4 format. When I open this file in CS4 and resave, it asks me if I really want to save in a legacy format. So, I guess, the info about the type only means that the file type is associated with Illustrator 14.

So, my question is if there is a way in JS to retrieve this kind of info about the file's compatibility mode.

Thanks

franK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2010 Nov 10, 2010

you can select the file in Bridge and look at the Application property in the Metadata panel

metadata.PNG

and taken from majorLaser's on this post http://forums.adobe.com/message/2036802#2036802

#target illustrator

//To use the XMP objects, you must load the XMP library as an ExtendScript ExternalObject. To avoid

//loading multiple instances of the library, use code like the following:

// load the library

if (ExternalObject.AdobeXMPScript == undefined) {

ExternalObject.AdobeXMPScript = new

ExternalObject("lib:AdobeXMPScript");

}

//Create an XMPMeta object from the active documents XMPString:

var myXmp = new XMPMeta(app.activeDocument.XMPString);

// retrieve property

prop = myXmp.getProperty(XMPConst.NS_XMP, "CreatorTool");

alert("Document Created in " + prop);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2010 Nov 11, 2010

another way using Bridge

#target bridge

// get the file
var f = new File(File.openDialog("chose file"));

// create a Thumbnail object
var t = new Thumbnail( f );

// get the metadate
var m = t.metadata;

// add namespace
m.namespace = "http://ns.adobe.com/xap/1.0/";

// get CreatorTool property
alert("Document Created in " + m.CreatorTool);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2010 Nov 11, 2010

Carlos;

I opened a new document and saved it as CS2 format. Then I ran the code you sent and it happily reported that the file was created in Adobe Illustrator CS4. That's correct but I'm trying to find out a way to see that the file is actually in a CS2 format. Is there a property with this information?

Thanks

franK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2010 Nov 11, 2010

The metadata in the Bridge also shows the creator info and not the actual file format

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 11, 2010 Nov 11, 2010

You could give this a try…

var f = new File('~/Desktop/Untitled-V3.ai'); savedasVersion(f); function savedasVersion(f)      {      f.open();      var line = '';      do {           line = f.readln();      } while (/^%%Creator:/.test(line) == false);           var v = line.substring(11,line.length);           f.close();           return v;      }

I only have CS2 so I can't say if this is true for how newer ones save the info…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2010 Nov 11, 2010

that'll do Mark, the file I made from CS5 to CS2 reads

%%Creator: Adobe Illustrator(R) 12.0
%%AI8_CreatorVersion: 15.0.1

I added an alert to see what's going on

alert(savedasVersion(f));
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 12, 2010 Nov 12, 2010

The function itself does NOT test that you are passing it an Illustrator .ai file. You should do that test yourself before passing the file. Otherwise the loop is going to spin forever when it can't find its expected string match. It does work for me on file versions 3 thru 12. You could have also looked for the string '%AI5_FileFormat' as that also contains the versioning but would require an additional switch. Carlos thanks its good to know that this stuff isn't going to be broken when we eventually upgrade…

The %% are commented lines in postscript (I think?)… But there are a couple of lines of useful info in there… Help you decide which files to open before passing to the app.open()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 12, 2010 Nov 12, 2010

Yeah, a single % at the start of a line signifies a comment. Adobe habitually prepends a double %, probably to make it clear it's sort of a 'system' comment rather than a human one.

Adding support for 'any' file is easy -- just check for an end-of-file. If so, this little rewrite returns null. Otherwise, the version string is returned.

var f = new File('~/Desktop/Untitled-V3.ai');

alert (savedasVersion(f));

function savedasVersion(f)
{
if (f.open() == false) return null;
var line = '';
while (!f.eof)
{
  line = f.readln();
  if (/^%%Creator:/.test(line))
  {
   f.close();
   return line.substring(11);
  }
}
f.close();
return null;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 12, 2010 Nov 12, 2010
LATEST

Jong that is better… Im liking that adjustment… I tinkered a couple of times and thats bang on what I had in mind…

line.substring(11)

Hum, no second parameter does to eos (end of string) will check…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines