Skip to main content
selvakkanit19061983
Known Participant
April 15, 2020
Question

AI File Version

  • April 15, 2020
  • 6 replies
  • 1956 views

Dear Sir / Madam,

 

We need to check the AI file can able to open in CC 2019.

Is it posible to identify the AI file version(CS6,CC 2020..) using SDK?

If possible, please send the function name.

 

Thanks and Regards,

T.Selvakkani

This topic has been closed for replies.

6 replies

Ten A
Community Expert
Community Expert
April 17, 2020
Ten A
Community Expert
Community Expert
April 17, 2020

Unfortunately, I don't have any snippets to use in such cases.
When handling character strings in C ++ The line feed code differs depending on the platform. If there is a difference between Windows and Mac, it is considered that there is a difference in behavior in this part. Reading in binary mode does not make this difference.
Also, if you just check the version, it will be easier to use JavaScript.

selvakkanit19061983
Known Participant
April 17, 2020

Thanks a lot for the quick reply.

I try to to read the file in binary mode. But it does not works.

Is it possible to provide sample code(how to check AI file version) in Javascript?

Ten A
Community Expert
Community Expert
April 16, 2020

I have never tried a similar workflow. Why don't you read binary stream directory?
Search below code words and fetch the next 2 bytes are major versions.

 

25 25 41 49 38 5F 43 72 65 61 74 6F 72 56 65 72 73 69 6F 6E 3A 20

selvakkanit19061983
Known Participant
April 16, 2020

Thanks for the immediate reply.

Sorry! I am not clear.

If possible, please teach us with sample code.

Ten A
Community Expert
Community Expert
April 16, 2020

The previous sample was made by Mac. There is no difference between Mac and Windows.
What version was the file created on the Mac?

Can you explore a header section start at "%!PS-Adobe-3.0"?

selvakkanit19061983
Known Participant
April 16, 2020

Thanks for the reply.

Yes. There is no difference between MAC and Windows.

But the file unable to read after 580th line and read the %%AI8_CreatorVersion code. I used the following code for read process.

Kindly guide us in this regards.

bool IsValidIllustratorFile(LPCTSTR pszPath)
{
	FILE *fRead;
	errno_t err = _tfopen_s(&fRead, pszPath, _T("r,ccs=UTF-8"));
	if (err != 0)
	{
		return 1;
	}
	CStdioFile file(fRead);
	CString strReadValue = _T("");
	CString strLinkedFile = _T("");
	bool bIsValidIllFile = true;
	int nCount = 0;
	try
	{
		while (file.ReadString(strReadValue))
		{
			++nCount;
			strReadValue.TrimLeft();
			CString strKey = _T("%%AI8_CreatorVersion");
			int nPos = strReadValue.Find(strKey);
			if (nPos != -1)
			{
				CString strTemp = strReadValue.Mid(nPos+ strKey.GetLength());
				if (strTemp.Find(_T("24")) != -1)
				{
					bIsValidIllFile = false;
					break;
				}
			}
		}
	}
	catch (...)
	{
		file.Close();
		return false;
	}
	file.Close();

	return bIsValidIllFile;
}

 

Ten A
Community Expert
Community Expert
April 15, 2020

You can read the target files binary and search "%%AI8_CreatorVersion" key. Here is an example.

...
%!PS-Adobe-3.0 
%%Creator: Adobe Illustrator(R) 24.0
%%AI8_CreatorVersion: 24.1.0
%%For: (No41) ()
%%Title: (SAMPLE.ai)
%%CreationDate: 2020/04/07 14:28
%%Canvassize: 16383
%%BoundingBox: 209 -730
...

 

selvakkanit19061983
Known Participant
April 15, 2020

Thanks for the reply. 

I understood the answer. It works for the AI file which was saved in Windows.Thanks a lot.

But the AI file which was saved in MAC OS does not have %%AI8_CreatorVersion entry.

Please teach us how to find the save version details for the MAC AI file?

Ten A
Community Expert
Community Expert
April 15, 2020

You can get creator information from XMP metadata or you can use the below tool(Mac only).

https://hackmd.io/@monokano/S1INP2N3M?type=view 

selvakkanit19061983
Known Participant
April 15, 2020

I got the reply. Thanks a lot.

Sorry! My question missed one information.

I need to find the Illustrator version of AI file in my Plugin which was developed in Windows

.