Script (or some other means) to convert RGB to CMYK in PDF?

0 votes
asked Aug 5, 2010 by davedev

Is it possible to write a script for Adobe Illustrator or some other tool that will read the contents of a number of PDF files and convert all the RGB colours to CMYK?

If so, could somebody please point out some of the steps involved, or where to find more information on this?

3 Answers

0 votes
answered Aug 6, 2010 by kurt-pfeifle

This answer is not for Illustrator, but for 'some other tool', namely Ghostscript (download gs871w32.exe or gs871w64.exe).

Ghostscript allows you to 're-distill' PDFs (without an intermediate conversion to PostScript, the dreaded 'refrying' detour). Try this command:

gswin32c.exe ^
    -o c:/path/to/output-cmyk.pdf ^
    -sDEVICE=pdfwrite ^
    -dUseCIEColor ^
    -sProcessColorModel=DeviceCMYK ^
    -sColorConversionStrategy=CMYK ^
    -sColorConversionStrategyForImages=CMYK ^
     input-rgb.pdf

And if you are able to wait for a few more weeks, Ghostscript 9.00 will be released. This new version will sport support of colormanagement (based on LCMS) with ICC profiles for the first time ever...

UPDATE: I updated above command because I missed to put in the option to also convert images.


Update 2

If color conversion does not work as desired and if you see a message like "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged" then...

  1. your Ghostscript probably is a newer release from the 9.x version series, and
  2. your source PDF likely uses an embedded ICC color profile

In this case add -dOverrideICC to the command line and see if it changes the result as desired.

0 votes
answered Aug 2, 2011 by jve

ABCpdf will recolor to CMYK or any other color space or profile you can think of. See:

http://www.websupergoo.com/helppdf7net/source/8-abcpdf6.operations/3-recoloroperation/1-methods/recolor.htm

0 votes
answered Sep 15, 2017 by charu

I have written and tested the following script in Illustrator CC 2017:

var folder = Folder.selectDialog();
if (folder) {
    var files = folder.getFiles("*.pdf")
    for (var i = 0; i < files.length; i++) {
        app.open(files[i]);
        var doc = app.activeDocument;
        app.executeMenuCommand('doc-color-cmyk');
        doc.close(SaveOptions.SAVECHANGES);
    }
}

This script will ask for a folder, so select the folder that have your PDF file in. It will convert all PDF files in the selected folder to CMYK.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...