Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

A while ago I asked how to Include Adobe Illustrator files (ai) with XeTeX. However, the PDF version of the Illustrator files is 1.5 and I compile my XeLateX documents to version 1.4 so the newer illustrator files can't be included without conversion.

I've now found that ps2pdf14 can take the illustrator ai file as an input and easily output a pdf 1.4 compatible version.

I've tried working the with DeclareGraphicsRule based on Convert gif image to png on the fly however, I can't seem to figure out a rule that works to run ps2pdf14?

I've tried these:

\DeclareGraphicsRule{.ai}{pdf}{.pdf}{`ps2pdf #1}
\DeclareGraphicsRule{.ai}{pdf}{.ai.pdf}{`ps2pdf #1}
\DeclareGraphicsRule{.ai}{pdf}{.pdf}{`ps2pdf14 #1 `dirname #1`/`basename #1 .ai`-ai-converted-to.pdf}
\DeclareGraphicsRule{.ai}{pdf}{.pdf}{ps2pdf14 \SourceFile.\SourceExt \OutputFile}

Here is an .ai file from the latest illustrator version (CS5) if anyone wants to play around: http://dl.dropbox.com/u/3730003/example.ai

It would be ideal if the conversion was only done if the illustrator document has been modified after the converted pdf file or if the converted pdf file doesn't exist.

Maybe a make file or script of some kind would be a better solution.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I guess you can adapt this answer to your need:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.ai}{pdf}{.pdf}{ps2pdf14 #1 \OutputFile}

\begin{document}
\includegraphics{example.ai}
\end{document}

This will do the conversion only if example.ai file is newer than the converted file example-ai-converted-to.pdf (or this one does not exist).

It's necessary to call pdflatex with the command line option -shell-escape at least when the converted file does not exist.

share|improve this answer
    
Is there a way to use epstopdf with XeLaTeX? –  s0rce Mar 11 '12 at 20:50
    
Sorry, no. :( I really don't know why. –  egreg Mar 11 '12 at 20:56
    
One problem is that XeTeX lacks a command to get the modification date of a file. –  egreg Mar 11 '12 at 22:09
add comment

For now I made a simple batch script that does what I need but I would love a latex solution!

for /r %%x in (*.ai) do ps2pdf14 "%%x" converted\%%~nx.pdf
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.