2

This question is related to

however way more specific. Consider that I am not an expert in print production ;)

Situation: For printing I am only allowed to use two colors, Cyan and Black. The printery requests the final PDF to be in DeviceCMYK with only the Channels C and K used.

pdflatex automatically does that (with the xcolor package) for all fonts and drawn objects, however I have more than 100 sketches/figures in PDF format which are embedded in the manuscript. Due to an admittedly badly designed workflow (late realization that Inkscape cannot export CMYK PDFs), all these figures were created in Inkscape, and thus are RGB PDFs.

However, the only used colors within Inkscape were RGB complements of CMY(K), e.g. 100% Cyan is (0,255,255) RGB and 50% K is (127,127,127) etc.

Problem: I need to convert all these PDF figures from RGB to DeviceCMYK (or alternatively the whole PDF of the final manuscript) with a specific conversion formula.

I did a lot of google research and tried the often suggested ways of using e.g. Ghostscript or various print production tools in Adobe Acrobat, however all of the conversion techniques I found so far wanted to use ICC color profiles or used some other conversion strategy which filled the channels MY and spared some C and K, for example.

I know the exact conversion formula for the raw color numbers from our Inkscape-RGBs to the channels C and K, however I do not know or find any program or tool that allows me to manually specify conversion formulas.

Question: Is there any workflow to convert my PDFs from RGB to C(MY)K manually with my own specific conversion formula for the raw numbers with the converted PDF being in DeviceCMYK using a tool, script or Adobe product?

Due to the large number of figures I would prefer a batched solution which doesn't require too much coding from my side, but if it should be the only solution, I'd also be open minded for a workflow like "load/convert/save" within a program for every single figure or writing a small program with an easy-to-handle C++ PDF API for example.

Limitations and additional info: A different file format (like TikZ figures) is not possible any more since it does not work perfectly and the necessary adaptions to the figures would create too much overhead. A maybe helpful information: Since the figures are created in Inkscape, there are no raster images within the PDFs. I also do not want all figures to be converted to raster images during the color conversion.

Edit:

I have created an example of a RGB PDF-figure created with inkscape.
I also did a manual object-by-object color conversion to a CMYK-PDF with Illustrator, to show how the result should look like. Illustrator stores the axial shading in a DeviceN colorspace with the colors cyan and black, which is close enough^^

Community
  • 1
  • 1
Niklas
  • 21
  • 4
  • Did you see the Ghostscript **[documentation about its ICC profile](http://git.ghostscript.com/?p=ghostpdl.git;a=blob_plain;f=gs/doc/GS9_Color_Management.pdf;hb=HEAD)** (PDF doc) support? – Kurt Pfeifle Apr 29 '15 at 16:41
  • @KenS: Ping! (I don't know if this will work to raise KenS' attention, but let me try...) – Kurt Pfeifle Apr 29 '15 at 16:42
  • 1
    Can you post an example document? I'm pretty sure this can be done, though most solutions I could point you to would be commercial in nature. Would be good to see an example to experiment with before saying something stupid though :) – David van Driessche Apr 29 '15 at 22:38
  • @KurtPfeifle I took a look the document you posted, but as far as I understand I would have to specify my own icc profile for the conversion? Actually, I thought I don't need to use color profiles when I stay in the DeviceRGB/CMYK.. but as I said, I am not an expert in this... – Niklas Apr 30 '15 at 10:05
  • @DavidvanDriessche I added the requested example documents... regarding commercial solutions, I can only use products of the Adobe Family myself.. but I am thankful for any suggestion! – Niklas Apr 30 '15 at 10:11

3 Answers3

1

Here is an idea, I think it will work if your PDF files are using exclusively the colorspaces DeviceGray, DeviceRGB and DeviceCMYK:

1- Convert all your PDF files to Postscript (with pdf2ps from ghostscript for example)

2- Write a Postscript program that redefines the operators setrgbcolor, setgray and setcolor with your own implementation in the Postscript language, your implementation will internally use setcmykcolor and it will compute the values using your custom formula.

Here is an example for redefining the setgray operator:

% The operator setcmykcolor expects 4 values in the stack
% When setgray is called, we can expect to have 1 value in the stack, we will
% use it for the black component of cmyk by adding 3 zeros and rolling the
% top 4 elements of the stack 3 times

/setgray { 0 0 0 4 3 roll setcmykcolor } bind def

3- Paste your Postcript program at the begining of each resulting ps file from step 1.

4- Convert all your files back to PDF (with ps2pdf for example)

See it in action by saving this piece of code as sample.ps:

/setgray { 0 0 0 4 3 roll setcmykcolor } bind def
0.5 setgray
0 0 moveto
600 600 lineto
stroke
showpage

Convert it to PDF with ghostscript using this command line (I used version 9.14):

gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=sample.pdf sample.ps

The resulting PDF will have the following page content:

q 0.1 0 0 0.1 0 0 cm
/R7 gs
10 w
% The K operator is the PDF equivalent of setcmykcolor in postscript
0 0 0 0.5 K 
0 0 m
3000 3000 l
S
Q

As you can see, the ps-> pdf conversion will preserve the cmky colors specified in postscript with the setcmykcolor operator.

Maybe you can post your formula as a new question and someone could help you out translating it to postscript.

yms
  • 10,361
  • 3
  • 38
  • 68
0

Since you have access to Illustrator, you might want to try importing the PDF into Illustrator and using Illustrator's scripting capabilities to iterate over the elements and replace fill/stroke RGB colors with their CMYK replacement colors.

The difficulty will be with the shading patterns (Gradients) used in the PDF; if they are imported as GradientColor, then in theory it's a matter of digging into the GradientColor to find the base RGB colors and substitute their CMYK replacement.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
Patrick Gallot
  • 595
  • 3
  • 11
-1

A very similar problem was solved using the ActivePDF.dll with C++ (or C#??).

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
al.scvorets
  • 122
  • 9