With using \pdfcompresslevel=0
for PDFTeX or with \pdfvariable compresslevel
for LuaTeX I'll get the pdf with no compressed streams and can see what happens inside the pdf.
With the cmyk option I get:
stream
0 0 0 1 k 0 0 0 1 K
0 g 0 G
0 0 0 1 k 0 0 0 1 K
1 1 0 0 k 1 1 0 0 K
BT
/F15 24.7871 Tf 91.925 752.955 Td [(A)]TJ
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
ET
endstream
and with the rgb option:
stream
0 0 0 rg 0 0 0 RG
0 g 0 G
0 0 0 rg 0 0 0 RG
0 0 1 rg 0 0 1 RG
BT
/F15 24.7871 Tf 91.925 752.955 Td [(A)]TJ
0 0 0 rg 0 0 0 RG
0 0 0 rg 0 0 0 RG
0 0 0 rg 0 0 0 RG
ET
endstream
which is what I would expect, a correct color setting. But printing a RGB color is not the same as printing a CMYK color ...
The problem of the OP was already solved by Stephan Lehmke in a comment. It was as simple as a typographic error, (a y
changed by a j
). I have to say that I was unable to see the error, although it was the first thing which I thought, and I inspected carefully the two strings, failing to see any difference (?).
So, trying to discover what the problem was, I read the PDF specification about color spaces and patterns, and learnt some things. Since the OP asked in a comment for clarification about these issues, I decided to write this short answer. I don't go after the 500 bounty, which I think I don't deserve :-)
In page 181 of the PDF specification, the "Uncoloured Tiling Patterns" are described. These are the kind of patterns used by TikZ, so this is the relevant part of the specification.
These kind of patterns do not include information about the color in which the pattern strokes or fills have to be drawn. They only define "how to draw" the pattern, but not "in which colour". Instead, the colours of the fills and strokes have to be specified when the pattern is used. This allows to the define the pattern once, and then apply it to different parts of the document with different colour.
To specify the color in wich the pattern has to be drawn, the operation SCN
is required, to set the color of the strokes, and/or scn
for the color of the non-strokes (fills). This operation requires two parameters, the first one being a tuple of components which specify the color (three components for a RGB model, four for a CMYK model), and the second one is the name of a "Pattern colour space", which has to be defined before.
In the code provided by the OP, the "Pattern Colour Space" is /pgfpcmyk
. However this is an internal variable which can have any name we like. This variable is defined as a Pattern Colour Space in:
/pgfpcmyk [/Pattern /DeviceCMYK]
which specifies that this particular pattern color space uses CMYK and it is an "uncoloured pattern" (because /Pattern
is defined as "Type 1" and "Paint type 2" in the code generated by TikZ).
Once this pattern colour space is defined, it can be used as argument of csn
like this, for example:
/pgfpcmyk cs 0 0 0 1 /pgfpat4 scn
This sets first the non-stroking colourspace to /pgfpcmyk
(this is done by cs
operator), which was defined above as a pattern colour space, and then the value of the non-stroking colour called /pgfpat4
(used later to paint one particular instance of the pattern) as the value 0 0 0 1
(which is black in CMYK).
If the pattern colour space would be using RGB (as TikZ does by default by inserting the definition /pgfprgb [/Pattern /DeviceRGB]
, then the above line would have to specify the color using only three numbers, for the R,G,B components.
Also note that the particular name of the variables /pgfpcmyk
or /pgfprgb
do not imply that those pattern colour spaces use CMYK or RGB, respectively. It all depends how they are defined before.
Best Answer
Here's a quick
bash
script to check for instances of RGB colors:And a
.bat
version for Windows:TeX Live includes a copy of
pdftops
; MikTeX/other users will need to download and place on their paths a Windows port ofpdftops
. One such port is provided as a part ofxpdf
.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}:
Windows:
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 forRGB
entries, we can determine if RGB is used anywhere in the PDF.Test File: