I have a pdf image with transparent background that I'll include by using graphicx (\includegraphics
). Everything is fine when using pdfLaTeX to build my pdf, but when I switch to XeTeX the image will suddenly have black background instead of being transparent. I have tried to reproduce the problem, and quite strangely some pdf images do not exhibit this problem while some do.
My XeTeX version is 3.1415926-2.4-0.9998, which I believe is the newest.
And here's a sample pdf image if any one wishes to test: https://docs.google.com/file/d/0BxDcKKtrknW_MlZMV2lKOE5oMXc/edit
Minimal code:
\documentclass[10pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[h]
\centering \includegraphics[scale=0.48]{MapReduce_Pipeline.pdf}
\caption{MapReduce Pipeline.}
\label{fig:MapReduce_Pipeline}
\end{figure}
\end{document}
Best Answer
The PDF file
MapReduce_Pipeline.pdf
contains the image as JPEG image with a transparency mask.xdvipdfmx
, the PDF driver part of XeTeX seems to forget to add the the mask entry. Version 0.7.8 works under TeX Live/Linux, but fails under MiKTeX/Windows.Since JPEG is not the best format for such kind of drawings with sharp edges, it is better to preserve the vector properties of the image. Perhaps you can find a better PDF export for the drawing in the original program, where the image was generated.
Alternatively you can open the image
MapReduce_Pipeline.pdf
withevince
. There you can store (right click) the image object as PNG file (PNG has transparency feature). Then you can include the PNG image in your XeLaTeX document (the scale factor needs adjusting, or usewidth=\linewidth
or similar).