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.

I have an SVG file, which I have made/edited with Inkscape. I want to include this image in my thesis. The svg file is here: http://brussense.be/temp/theSVG.svg (because Inkscape uses a non-standard feature it does not render correctly in most browsers)

I exported it with Inkscape to get this PDF (v1.5): http://brussense.be/temp/PDFed.pdf (this file looks fine in Acrobat Pro X)

Here's an MWE for the inclusion of the PDF in a LaTeX document:

\documentclass[a4paper]{report}

\usepackage[xetex,hiresbb]{graphicx}

\begin{document}

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{PDFed.pdf}
\caption{Some caption}
\end{figure}

\end{document}

My problem is that when I compile this with XeLaTeX (with the xdvipdfmx driver) the colors of the image have visibly changed in the resulting pdf: http://brussense.be/temp/XeTeXed.pdf

I also tried exporting to a v1.4 PDF from Inkscape but the result is the same.

I know a very similar question was asked here: \includegraphics PDF, color problem

But there are two differences:

  • as far as I know my svg file does not contain transparent objects, nor alpha blending (all colors have the alpha channel at 255), nor any blurring or other filters

  • the question was specific to pdftex and the suggested solution causes a compilation error in XeLaTeX

Does anyone know how I can fix this? I see various possible ways to tackle the problem, but so far I haven't been succesful:

  • some setting change in Inkscape
  • some (non-visible) change in the svg file
  • some postprocessing on the PDF file (I already played with ICC profiles and such but I totaly new to this)
  • some changes in my LaTeX code
  • some parameter for XeLaTeX or xdvipdfmx
  • something else?
share|improve this question
1  
I can't see any difference between the SVG and the XeLaTeX output. –  FUZxxl Sep 26 '11 at 6:38
    
Really? Weird, it is quite clear on my screen. And do you see a color difference between the stand-alone pdf and the xetexed document? –  Matthias Sep 26 '11 at 11:04
    
I've uploaded a comparison. –  FUZxxl Sep 26 '11 at 11:20
1  
Hmm, then I guess the PDF viewer also has an influence (I'm using Acrobat Pro) –  Matthias Sep 26 '11 at 11:22

4 Answers 4

up vote 12 down vote accepted

Looking into the PDF I see a PageGroup (Object 19), so \includegraphics PDF, color problem might indeed apply. Try exporting as PDF 1.3 - there should be no PageGroup then.

share|improve this answer
1  
Inkscape itself can only export as PDF 1.4 or 1.5. So I used Acrobat Pro to save the PDF 1.5 file as a PDF 1.3 file: brussense.be/temp/PDFed13.pdf You were right, the problem is fixed! The colors no longer change! I first commented that they did but I had mixed up my files so I was still using the 1.5 one (removed that command). Thanks! –  Matthias Sep 26 '11 at 11:21

For pdflatex use:

\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>}

For XeLaTeX with dvipdfm(x) try:

\makeatletter%
\special{pdf: put @thispage <</Group << /S /Transparency /I true /CS /DeviceRGB>> >>}%
\makeatother%

Code should be inserted a the top of the page. I use XeLaTeX with Beamer and insert code after \begin{frame}.

The solution for all pages (not for single page) may be exists.

share|improve this answer
    
For all pages in XeLaTeX, add to preamble the following code. –  Vladimir S. Jan 1 at 13:25

The problem is that Inkscape exports to pdf in RGB colors, no matter what you specified as color. You can check the colors of your pdf with Acrobat Pro. The are some Inkscape bug reports on Launchpad and in the pdftex bug tracker. pdftex and I assume also xelatex use CMYK on export. Now when there is a RGB image on a CMYK page you will get the reported color problems. There are two solutions: Use a svg to pdf converter that exports CMYK colors, for example Scribus or Acrobat Pro, or put a PageGroup around your image, separating the RGB areas from the CMYK areas.

And yes, the viewer does make a difference, as described in the pdftex bug report.

share|improve this answer
    
Are you sure Acrobat Pro can confert svg's to pdf? I have Acrobat Pro X (v10.1.1) but I can't find that feature. –  Matthias Nov 4 '11 at 15:55
    
I am not sure anymore, it was some time ago. If you right click on the file you can choose 'convert to pdf', maybe that was how I did it, or maybe I exported to eps from Inkscape and converted the eps with Acrobat. Alternatively you can try the Apache Batik Rasterizer, which can convert svg to various formats, including pdf, using the following (or similar) command batik-rasterizer.jar -m application/pdf samples/anne.svg –  matth Nov 7 '11 at 9:04

I had the same problem and this is what in the end helped me.

Assuming your LaTeX file is called presentation.tex you run the following commands:

xelatex presentation.tex
pdftk presentation.pdf output uncompressed.pdf uncompress
sed -i 's/^\/Type \/Page$/\/Type \/Page\n\/Group\n\\>\n/' uncompressed.pdf
pdftk uncompressed.pdf output presentation.pdf compress

The sed script actually inserts the postscript selitsky suggested directly into the PDF on all pages. The compress step is pretty slow but it works for me.

share|improve this answer

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.