Forum Bugs

CMYK() Function in SVG creates different color

I am using svgs to display imgs in my pdf.
I need to use cmyk profile because the pdfs are printed and the printer use cmyk colors.

I replaced the fill color #66c430 with cmyk(48%,0%,76%,23%) (
after the pdf is created via prince i selected to color in gimp and it is more a #7bab69

Shouldn't the color stay the same when I use this function?

(using prince 14.2)

Edited by lynxSven

Minimal example

<svg xml:space="preserve" width="1014.667" height="341.333" xmlns="">
    <rect width="100" height="100" style="fill:rgb(102,196,48);stroke:none" />
    <rect width="100" height="100" x="100" style="fill:#66c430;stroke:none" />
    <rect width="100" height="100" x="200" style="fill:cmyk(0.480,0.000,0.755,0.231);stroke:none" />

Both should have the same color but you can see a difference

  1. green_example.png1.2 kB

Edited by lynxSven

There is not a single formula for converting CMYK values to RGB values. The question is really meaningless until you specify which CMYK color space to convert from and which RGB color space to convert to. Even then, it's far from straightforward.

The website you referred is doing what is sometimes called a "naive" CMYK to RGB color conversion. It's a simple mathematical equation but the result is rather arbitrary.

When you specify a cmyk() color, two things happen:
  1. Prince will embed an ICC profile to say what color space the CMYK values are in. This is controlled by the --pdf-output-intent or --fallback-cmyk-profile options.
  2. The PDF viewer should use the ICC profile to convert CMYK values to the target color space (e.g. sRGB). A less sophisticated PDF viewer may convert CMYK values using its own fixed conversion table, or use the naive CMYK to RGB formula.
Thank you for your answer.
This doesn't seem the be a trivial Topic, I see.

We analyzed the pdf and they all have the Colorspace: "/ColorSpace /DeviceCMYK"
We gave the prince process his own icc file via the prince-wrapper (setPDFOutputIntent() and setFallbackCMYKProfile())

As far as I understand, the DeviceCMYK says: "use the CMYK Profil depending on the device"
What is to unreliable which color he displays.

I expected something there which indicates the .icc file we provided via the functions and not the deviceCMYK.

Am I mistaken here?

Does the javaprincewrapper throw errors if he doesn't find the provided icc-file in the path? Maybe he is just not using it?
EDIT: I tested it and if he doesn't find the icc the conversion failes. Like expected :) So he uses the correct .icc file

Thanks for your answers

Edited by lynxSven

If the ICC file isn't found, there will be an error message in the log but the PDF will still be produced:
prince: missing.icc: error: can't open input file: No such file or directory

The Java wrapper may silently ignore the error when a PDF is produced (I haven't checked).

You can tell Prince not to produce the PDF if the ICC file is not found by passing the --fail-safe option:
prince: missing.icc: error: can't open input file: No such file or directory
prince: error: PDF generation triggered fail-safe option

When an output intent is embedded, you will see near the top of the PDF file something like:
 0 obj
<</Type /Catalog
/Pages 2 0 R
/OutputIntents [4 0 R]>>