Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate CMYK coverage on PDF

I don't suppose is there any free or open source libraries out there that able to calculate the CMYK coverage on a pdf file. I tried looking around I don't seem to able to find any. If there isn't any out there if anyone could point me in the right direction of what do I need to do in order to calculate the CYMK coverage on a pdf. Oh also the development environment I'd be working in is .net framework 4.0

Cheers

like image 812
madness800 Avatar asked Jun 22 '10 10:06

madness800


1 Answers

You can use Ghostscript. Run it with the tiffsep or tiffsep1 device at 72dpi resolution. This will create separate TIFF files for each CMYK colorant which you can then further use to 'count' the coverage for each color:

gswin32c.exe ^
    -sDEVICE=tiffsep ^
    -r72x72 ^
    -o "c:/path/to/output/dir/page_%03d.tif" ^
    c:/path/to/input.pdf

This device creates multiple output files. It creates:

  1. one 32bit composite CMYK file (tiff32nc format, which is 32bit CMYK [8bits/component]), plus
  2. multiple tiffgray files -- a tiffgray (which is 8bit gray, LZW compressed) for each color separation.

The tiffgray files are LZW compressed. The -sOutputFile=...-specified filename will be the CMYK file. Names of separation 'tiffgray' files for CMYK colorants will have appended '.Cyan.tif', '.Magenta.tif' '.Yellow.tif' and '.Black.tif' to that name. tiffsep also recognizes spot colors automatically and creates additional tiffgray separations for them; the names of these have a number appended. (You can also pre-determine the names by passing -sSeparationColorNames on the commandline -- but you better read up the details in Ghostscript's documentation, file Devices.htm).

If you use the tiffsep1 output device, the result will be similar -- the difference is that you will get only the gray separations (no 32bit composite CMYK), but these will be TIFF G4 files (G4 compression scheme).

You can change the compression scheme by adding -sCompression=lzw (or one of none | crle | g3 | g4 | pack). Be aware that using =none for compression will create files of equal sizes for each separation colorant.

like image 164
Kurt Pfeifle Avatar answered Oct 24 '22 09:10

Kurt Pfeifle