Two techniques to determine if a file with a .ai file extension is an EPS file or a PDF file.
Issue
I have a mixture of Illustrator ".ai" files created by various versions of Illustrator. Some are in EPS format (Illustrator 7 and 8) and some are PDFs (Illustrator 9 and 10).
When I attempt to process a batch of files, I don't know whether to use convertPDFToRaster or to use convertPSToRaster. When the command doesn't match the file, Adobe Server generates an error. How should I handle a mixed batch of .ai files?
Applies To
Adobe Graphics Server
Adobe Document Server
Solution
One way would be by branching in your SDK code after the exception to code that uses the other command.
A faster way is to open the file within your SDK code and look at the first four bytes.
- If the .ai file is PDF based, the first four characters will be %PDF
- If not, the .ai file is EPS based. Then call the appropriate command (convertPDFToRaster or convertPSToRaster).
This is quicker than branching on an Altercast error because it eliminates the possibility of having to send the file to Adobe Server twice.