[Tex/LaTex] How to force xelatex to convert eps into pdf? speed issue with slow compilation of xelatex

xetex

I run a few simple tests to compare the compilation speed of pdflatex and xelatex. As most people said, I also found that xelatex is always much slower than pdflatex.

The reason for the slowness of xelatex I figured out is eps conversion process in xelatex.

I use eps image files created by Adobe Illustrator, and the average size of the eps file is 1MB. It seems that very time I compiled using xelatex, it will spend considerable time to convert the eps file. But pdflatex convert eps to pdf using "epstopdf" package only once in the first compilation. After the first compilation, pdflatex just use the converted pdf image file. The good thing is those converted pdf image file is significantly smaller than the original eps file, just around 20K.

I tried to use the pdf image file that generated by pdflatex in xelatex, it does speed up the compilation process significantly, though still not as fast as pdflatex, but made a big progress.

But "epstopdf" is not working in xelatex. Is there any other method to force xelatex to convert eps image into pdf file on the fly, so it can use pdf image file ever since the first compilation just as "epstopdf" does in pdflatex?

Best Answer

Why don't you simply call once epstopdf file.eps to convert your eps before running xelatex?

Beside this: Converting the file on the fly when it doesn't exist is not so difficult. E.g. compile this with xelatex --shell-escape:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\IfFileExists{testeps1.pdf}{}{\immediate\write18{epstopdf testeps1.eps}}
\includegraphics{testeps1}
\end{document}

But epstopdf doesn't convert only when the file doesn't exist but also compares file dates and updates the file if the eps has been changed and this is more difficult to implement in xelatex as some of the primitives used seem not to exist. So when you change the eps you must ensure that you trigger the conversion again.