5

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} 
0

1 Answer 1

4

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 with evince. 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 use width=\linewidth or similar).

2
  • Hmm, saving to PNG definitely helps, but why some PDF work while some do not is still a mystery. I've even experienced cases when no image showed up at all.
    – yongtw123
    Commented Jan 17, 2013 at 5:08
  • An other option is to print the pdf to a new pdf file and include the "printed" file. At least with ubuntu the printing does eliminate the transparent parts.
    – Ohmen
    Commented Nov 18, 2019 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .