English 中文(简体)
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

问题回答

OK, there is a new option now (since a few days ago) with Ghostscript for all those who are willing to compile it from the source. It is still bleeding edge , and not recommended for productive use. The rest of you will have to wait for the next official release.

The new option comes in the shape of a new device called inkcov. This works similar to the bbox device which spits out the BoundingBox values for each page: the inkcov device spits out the C, M, Y and K values of ink coverage used for each page (a value of 1 corresponds to 100%). Be aware that the total sum of ink may be higher than 100% (like: mixing 100% of Yellow with 100% of Magenta gives the optical impression of 100% Red ).

Try this command with a Ghostcript compiled from current Git source:

gs -o - -sDEVICE=inkcov /path/to/your.pdf

This will spit out an output similar to this one:

Page 1
 0.20898  0.20905  0.41320  0.55001 CMYK OK
Page 2
 0.33561  0.02026  0.21677  0.16750 CMYK OK
Page 3
 0.00000  0.00000  0.00000  1.00000 CMYK OK
[....]

This little utility has been created by Sebastian Kapfer from the University of Erlangen and contributed to the Ghostscript source code. (Of course, it s still awaiting some heavy testing and verification, comparing its results to other similar tools.)

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.





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签