views:

44

answers:

4

Hi - Is there a library/tool which would list all colours used in a PDF document ?

I'm sure Acrobat itself would do this but I would like an alternative (ideally something that could be scripted).

So the idea is if you have a very simple PDF document with four colours in it the output might say :

RGB(100,0,0)
RGB(105,0,0)
CMYK(0,0,0,1)
CMYK(1,1,1,1)
A: 

You could explore the insides with pdfbox, but you would have to write some code to find and catalog all those colors.

bmargulies
That's great thanks - looks useful.
southof40
A: 

Most PDF tools have access to this information but no api to access it. You could take any tool and add it in

mark stephens
A: 

Disclaimer: I work at Atalasoft.

Our product, DotImage with the PDF Reader add-on, can do this. The easiest way is to rasterize the page and then just use any of our image analysis tools to get the colors.

This example shows how to do it if you want to group similar colors -- the deployed example will only work for PNG and JPEG, but if you download the code, it's trivial to include the add-on and get PDF as well (let me know if you need help)

Source here:

http://www.atalasoft.com/cs/blogs/31appsin31days/archive/2008/05/30/color-scheme-generator.aspx

Run it here:

http://www.atalasoft.com/31apps/ColorSchemeGenerator

Lou Franco
A: 

Apago PDFspy generates an XML file containing all kinds of metadata extracted from PDF files. It reports color usage including spot colors.

Dwight Kelly