Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting (any) PDF to black (K)-only CMYK

Tags:

pdf

cmyk

This is related to:

  • Converting PDF to CMYK (with identify recognizing CMYK).
  • Script (or some other means) to convert RGB to CMYK in PDF?

... but a bit more specific here: say I have an RGB PDF, where the text color is "rich black" (R:0 G:0 B:0 gone to C:100 M:100 Y:100 K:100), and diverse images and vector graphics.

I would like to convert this to a CMYK PDF, using a free command line tool (so it is batch scriptable under Linux), which

  • has contents only in the black (K) channel:
    • Preserves vector graphics (+ text glyphs) - colors become grayscale in black (K) channel only
    • Images get converted to grayscale in black (K) channel only

Thanks in advance for any answers,
Cheers!

like image 549
sdaau Avatar asked Jun 06 '11 06:06

sdaau


People also ask

Can I convert a PDF to CMYK?

1. To convert Spot Colors and/or RGB colors in a PDF to CMYK, open your PDF in Acrobat and go to Print Production / Convert Colors… 2. For Spot colors, choose Spot Color in the Color type drop down.


1 Answers

As hinted in my comment to @Mark Storer, it turns out that forcing a gray print only on the K plate in CMYK, may not be so trivial ... I guess it depends much on what is being used as "preflight" preview device - for Linux, the only thing I can find is ghostscript with tiffsep, which is what I use for 'sanity check' regarding CMYK separations.

Anyways, I got a lot of help in this thread on comp.lang.postscript:

  • PDF to PDF (gs?): rich RGB black to plain K (CMYK) black? - comp.lang.postscript | Google Groups

... and one workflow that works for me is:

  • Convert PDF to PS using ghostscript's ps2write
  • Use ghostscript to convert this PS back to PDF, while executing replacement functions in HackRGB-cmyk-inv.ps
  • Use ghostscript's tiffsep to check actual separations

 

In respect to, say, this PDF generated by OpenOffice: blah-slide.pdf, the command lines would be:

# PDF to PS using `ps2write` device of `ghostscript`
gs \
   -dNOPAUSE \
   -dBATCH \
   -sDEVICE=ps2write \
   -sOutputFile=./blah-slide-gsps2w.ps \
    ./blah-slide.pdf 

# PS to PDF using replacement function in HackRGB-cmyk-inv.ps
gs \
   -dNOPAUSE \
   -dBATCH \
   -sDEVICE=pdfwrite \
   -sOutputFile=./blah-slide-hackRGB-cmyk-inv.pdf \
    ./HackRGB-cmyk-inv.ps \
    ./blah-slide-gsps2w.ps

# check separations
gs \
   -dNOPAUSE \
   -dBATCH \
   -dSAFER \
   -sDEVICE=tiffsep \
   -dFirstPage=1 \
   -dLastPage=1 \
   -sOutputFile=p%02d.tif \
    blah-slide-hackRGB-cmyk-inv.pdf \
\
&& eog p01.tif 2>/dev/null 

This should only work on RGB values where R=G=B (and hopefully grayscale values), and only on text colors, and it also flattens text information - but it should be possible to confirm via tiffsep that the text indeed ends up only on the K plate.

As mentioned in the newsgroup post, this is not extensively tested, but looks promising so far...
Cheers!

like image 138
sdaau Avatar answered Sep 30 '22 10:09

sdaau