17

The place I want to print my document at needs the PDF to be provided in CMYK. The document is mostly text, except for a few graphs and plots which are done in TikZ or pgfplots.

As suggested in this forum, calling \usepackage[cmyk]{xcolor} should do the trick, but I have no way of verifying that my resulting document is indeed set using CMYK. Using imageMagick, the PDF is reported as:

$ identify -verbose test.pdf | grep Colorspace
   Colorspace: Gray
   Colorspace: sRGB
   [... lots of Colorspace: sRGB lines here ...]

I tried the command provided in the accepted answer of this thread on stackoverflow:

$ gs        -o test-cmyk.pdf        -sDEVICE=pdfwrite        -sProcessColorModel=DeviceCMYK        -sColorConversionStrategy=CMYK        -sColorConversionStrategyForImages=CMYK         test.pdf 

But the result when calling identify is the same: every single colorspace is reported as Colorspace: sRGB. The same happens when I use imageMagick directly to try and convert the PDF:

$ convert in.pdf -profile "/usr/share/ghostscript/9.07/iccprofiles/default_cmyk.icc" out.pdf

I found a few discussions in this channel, in particular the two below. However, neither give me a final answer as to how to check if my PDF is indeed using the CMYK color model.

PDF colour model and LaTeX

Option cmyk for xcolor package does not produce a CMYK PDF

In particular, the latter sugests the use of the command \pdfcompresslevel=0. The problem with that is, that apparently XeLaTeX does not like that command:

! Undefined control sequence.
l.4 \pdfcompresslevel
                     =0
  • 1
    for most parts, pgfplots relies on xcolor i.e. reconfiguring xcolor should do the job. There are a couple of exceptions though: everything which uses colormap explicitly needs a color space and the special feature mesh/color input=explicit also needs an interpolation color space. In both cases, the default is RGB. And: colorbars rely on TikZ shadings which are unavailable for CMYK (could be reimplemented by means of a pgfplots shading which do support CMYK...). – Christian Feuersänger Jul 22 '13 at 18:29
  • I am indeed not using colormap or mesh/color input. I set all color definitions explicitly; e.g. color=red in an \addplot command. But the question remains: how do I verify that my PDF is actually using the CMYK color model? It seems like the only realiable method to find that out is using Adobe Pro, which is not very feasible from my side (restricted by both operating system and wallet). – mSSM Jul 22 '13 at 22:15
  • 1
    A friend's university is providing him with access to Adobe Pro, so I could ask him to check the file for me. Turns out that due to \usepackage[cmyk]{xcolor} a CMYK PDF was created indeed. I am going to leave this question open; maybe somebody knows a reliable way check for CMYK without access to Adobe products. – mSSM Jul 23 '13 at 14:53
  • 1
    Update on my comment above regarding pgfplots and colorspaces: I found that colormaps implicitly honor the global configuration of xcolor, i.e. they use the correct colorspace. I added a switch to pgfplots which does the same for mesh/color input=explicit automatically as well. Concerning my last remark regarding color bars: pgfplots automatically checks for the requested colorspace and avoids tikz shadings automatically (part of the current stable). Consequently, \usepackage[cmyk]{xcolor} is honored by pgfplots. – Christian Feuersänger Jul 28 '13 at 15:26
  • 1
    Regarding your problem with \pdfcompresslevel=0: you can use pdftk <input>.pdf cat output <output>.pdf uncompress to uncompress a pdf without losses. The uncompressed pdf allows the same analysis as done in tex.stackexchange.com/questions/13071/… – Christian Feuersänger Jul 28 '13 at 15:31
6

Here's a quick bash script to check for instances of RGB colors:

#!/bin/sh
pdftops $1.pdf -eps $1.eps
status=$(grep -o "RGB" $1.eps | wc -l)
echo "$status instance(s) of RGB colorspaces found in file $1.eps"
exit $status

And a .bat version for Windows:

@echo off
pdftops %1.pdf -eps %1.eps
type %1.eps | find "RGB" /c > __my%1.tmp
set /p status=<__my%1.tmp
del __my%1.tmp
echo %status%
exit /b %status%

TeX Live includes a copy of pdftops; MikTeX/other users will need to download and place on their paths a Windows port of pdftops. One such port is provided as a part of xpdf.

This solution is probably not perfect, but it's the best thing I've come up with that doesn't require Adobe Acrobat Pro.

Usage:

Unix/Linux{-based}:

$ sh checkcolorspace test

Windows:

> checkcolorspace.bat test

Explanation:

Converting to EPS gives a plaintext file that can be readily parsed. All color information is listed with one of /DeviceGray, /DeviceCMYK, or /DeviceRGB. By looking for RGB entries, we can determine if RGB is used anywhere in the PDF.

Test File:

\documentclass{article}
\usepackage[
  cmyk, % uncomment _one_ of these only, 
%  rgb, % for testing purposes
]{xcolor}

\begin{document}
\textcolor{red}{test}
\textcolor{green}{test}
\textcolor{blue}{test}
\textcolor{cyan}{test}
\textcolor{magenta}{test}
\textcolor{yellow}{test}
\textcolor{black}{test}
\end{document}
  • Is this possible in Windows? – skpblack Aug 16 '14 at 8:33
  • @skpblack, I'll take a look at this today. There's probably a good way to do it on Windows without Cygwin or friends. – Paul Gessler Aug 16 '14 at 13:00
  • @skpblack, Windows support is now added. :-) – Paul Gessler Aug 17 '14 at 3:13
1

Scribus can open a PDF document and list all the colors in it. As long as you're not using a ton of colors, it's easy to skim down the list and verify that everything is CMYK.

In the current version (1.4.2), clicking Edit → Colors... will show you a color list. The icons in the second column of the list tell you color model of each color: four squares means CMYK, for example, and three bars means RGB.


p.s. When I was looking for instruction on how to check color models in Scribus, I came across a nice list of techniques for various print prep tasks at Libre Graphics Production. If you do a lot of printing, you might find it useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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