I have a couple of sRGB PDF figures which I'm trying to convert to CMYK EPS for an accepted paper. Since I saw no posts explaining the entire procedure in one step, I decided to first do sRGB PDF -> CMYK PDF and then CMYK PDF -> CMYK EPS. This second step is where I get stuck, but I will include the entire procedure for completeness.
I illustrate my questions using the following figures, where the first one if the input. The three figures are in the zip file https://www.dropbox.com/s/7wr84bqhp3rzagg/figs.zip?dl=0
- 'figure.pdf', the sRGB PDF input file
- 'figure_cmyk.pdf', the CMYK PDF intermediate file
- 'figure_cmyk.eps', the final EPS file which should be CMYK but isn't.
I will use these numbers for convenience for the rest of the question. After a couple of hours I was finally able to convert sRGB PDF (1) to CMYK PDF (2) by combining answers from Converting PDF to CMYK (with identify recognizing CMYK) . The hardest part was to let 'identify' detect that the new PDF was actually CMYK. I used Chris Hecker's hacky trick to get this conversion step to work. I then call identify with the command:
identify -format '%[colorspace]' figure_1_cmyk.pdf
and it says CMYK, so far so good. The next step should be easy I thought, just convert the CMYK PDF to CMYK EPS. But this is where I really get stuck. I am using the following bash script 'pdf2eps.sh' on (2) to get (3).
#!/bin/bash
gs \
-dNOPAUSE \
-dNOCACHE \
-dBATCH \
-dNOSUBSTDEVICECOLORS \
-sDEVICE=eps2write \
-sOutputFile="${1%%.pdf}.eps" \
"$1"
Both with and without the '-dNOSUBSTDEVICECOLORS' flag the resulting .eps file (3) somehow reverts back to sRGB as detected by 'identify'. You can check so yourself using the provided figures. I really have no idea left of what I can try, but I'm also very new to ghostscript. I would be very grateful if someone with more knowledge than me could show me how to get (3) to be CMYK.
Could it be that identify is just buggy? I don't know of other ways using linux tools to check if (3) is actually CMYK. If there are easier ways to get sRGB PDF to CMYK EPS with high quality I would be interested as well of course. The command line tool 'convert' doesn't give good results to me.
sincerely, Bram
--------------------
P.S. Since requested in one of the answers, the code I use for the first step (RGB PDF -> CMYK PDF) is the following:
bash script
#!/bin/bash
gs \
-dPDFX \
-dBATCH \
-dNOPAUSE \
-dNOOUTERSAVE \
-dPDFSETTINGS=/prepress \
-dCompatibilityLevel=1.5 \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK \
-sProcessColorModel=DeviceCMYK \
-dHaveTransparency=false \
-sOutputFile="${1%%.pdf}_cmyk.pdf" \
PDFX_def_fogra39_trickcmyk.ps \
"$1"
with added file 'PDFX_def_fogra39_trickcmyk.ps'
%!
% $Id$
% This is a sample prefix file for creating a PDF/X-3 document.
% Feel free to modify entries marked with "Customize".
% This assumes an ICC profile to reside in the file (ISO Coated sb.icc),
% unless the user modifies the corresponding line below.
systemdict /ProcessColorModel known {
systemdict /ProcessColorModel get dup /DeviceGray ne exch /DeviceCMYK ne and
} {
true
} ifelse
{ (ERROR: ProcessColorModel must be /DeviceGray or DeviceCMYK.)=
/ProcessColorModel cvx /rangecheck signalerror
} if
% Define entries to the document Info dictionary :
% /ICCProfile (/usr/share/color/icc/ISOcoated_v2_300_eci.icc) def % Customize or remove.
[ /GTS_PDFXVersion (PDF/X-3:2002) % Must be so (the standard requires).
/Title (Title) % Customize.
/Trapped /False % Must be so (Ghostscript doesn't provide other).
/DOCINFO pdfmark
% Define an ICC profile :
currentdict /ICCProfile known {
[/_objdef {icc_PDFX} /type /stream /OBJ pdfmark
[{icc_PDFX} <</N systemdict /ProcessColorModel get /DeviceGray eq {1} {4} ifelse >> /PUT pdfmark
[{icc_PDFX} ICCProfile (r) file /PUT pdfmark
} if
% Define the output intent dictionary :
[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark
[{OutputIntent_PDFX} <<
/Type /OutputIntent % Must be so (the standard requires).
/S /GTS_PDFX % Must be so (the standard requires).
/OutputCondition (Commercial and specialty printing) % Customize
/Info (none) % Customize
/OutputConditionIdentifier (FOGRA39) % Customize
/RegistryName (http://www.color.org) % Must be so (the standard requires).
currentdict /ICCProfile known {
/DestOutputProfile {icc_PDFX} % Must be so (see above).
} if
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFX} ]>> /PUT pdfmark
[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark
[{OutputIntent_PDFX} <<
/ColorSpace /DeviceCMYK % convince ImageMagick's identify that it's CMYK
/Type /OutputIntent % Must be so (the standard requires).
/S /GTS_PDFX % Must be so (the standard requires).
/OutputCondition (Commercial and specialty printing) % Customize
/Info (none) % Customize
/OutputConditionIdentifier (CGATS TR 003) % Customize
/RegistryName (http://www.color.org) % Must be so (the standard requires).
currentdict /ICCProfile known {
/DestOutputProfile {icc_PDFX} % Must be so (see above).
} if
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFX} ]>> /PUT pdfmark