1

I read this post about how to convert PDF to CMYK, but when I try the accepted solution

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

I does not get a pdf with CMYK color space, if my original pdf does not contain an image. If I add an image to it, I get the right result (checked with identify).

For example, if I create a svg with inskcape with one rectangle, export it to pdf, and then use the ghostscript command, it still gets a pdf in sRBG color space. But, if I add an image in my svg, it works fine.

What is the right option in gs to deal with that problem? My version is 9.19.


Edit: KenS found the problem: the report from identify is wrong. So I add my installed version number of ImageMagick: 6.9.3.

Community
  • 1
  • 1
rools
  • 1,539
  • 12
  • 21

1 Answers1

0

If you are using an up to date version of Ghostscript, then you do not need either -sColorConversionStrategyForImages (incidentally that's not a real Ghostscript control) nor -sProcessColorModel. If you are not using an up to date version of Ghostscript, then update....

Other than that, since you haven't provided an example, or told us which version of GS you are using, or on which platform, its not really possible to say anything further.

[added after file provided]

Your original PDF file contains this as the content stream for the page:

stream
q
0 0 0 rg /a0 gs
109.715 637.714 262.855 -260.57 re f
Q
endstream

So that saves the graphcis state, sets the colour to 0,0,0 RGB, sets up a particular graphics state where the alpha is 1, draws a rectangle, and fills it with the current colour then restores the graphics state.

I then used this command line:

./gs -sDEVICE=pdfwrite -sOutputFile=CMYK.pdf -sColorConversionStrategy=CMYK test.pdf

The resulting PDF file has this as the page content stream:

stream
q 0.1 0 0 0.1 0 0 cm
/R7 gs
0.722 0.675 0.671 0.882 k
1097.15 3771.44 2628.55 2605.7 re
f
Q
endstream

So that saves the graphics state, multiples the CTM by 0.1 in x and y, sets a specific graphics state, sets the colour to 0.722, 0.675, 0.671, 0.882 CMYK, creates a rectangle, fills it with the current colour and the restores the graphics state.

So the resulting PDF file has all the colours defined as CMYK values.

Perhaps your problem is with identify not Ghostscript.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • Thanks for the tip about the useless options, but it does not address my problem. I have added the version number for my ghostscript installation. – rools Mar 31 '16 at 16:07
  • And an example file to demonstrate the problem ? – KenS Mar 31 '16 at 18:20
  • This is a [pdf](https://www.docdroid.net/NzuYOjf/test.pdf.html) generated with `inkscape -A` after having created a svg with one single rectangle. – rools Mar 31 '16 at 19:03
  • Many ways. In this particular case I used MuPDF. You can also have the pdfwrite device write streams uncompressed if you set -dCOmpressPages=false -dCompressFonts=false – KenS Apr 01 '16 at 10:51
  • I tried `mutool show test.pdf` and `gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCOmpressPages=false -dCompressFonts=false -sOutputFile=uncompressed.pdf test.pdf`, but both without any success. – rools Apr 01 '16 at 12:15
  • mutool clean -d . I mis-spelled -dCompressPages with a capital O which you would have realised if you'd checked the documentation. – KenS Apr 01 '16 at 13:05
  • I checked the documentation but, like you, did not see the capital O. It works now with `gs`. Still it does not work with `mutool` but it does not matter. So, as you guessed, it seems to be a problem from `identify`. Thanks. – rools Apr 01 '16 at 13:43