Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a 100 page PDF document that I need to print. My print shop needs to be told which pages contain color. I don't want to scan manually. Is there a program that detects pages with color and can ouput the page number?

share|improve this question
1  
Operating system? –  frabjous Jan 17 '11 at 20:43
add comment

4 Answers

On Linux (and probably mac/other Unix), the following very short BASH script seems to do the trick:

 #!/bin/bash
 file="$1"
 for page in $(identify -density 12 -format '%p ' "$file") ; do
     if convert "$file[$((page-1))]" -colorspace RGB -unique-colors txt:- | sed -e 1d | egrep -q -v ': \(\s*([0-9]*),\s*\1,\s*\1' ; then
         echo $page
     fi
 done

Name the script something like coloredpages.sh, and make it executable with chmod +x coloredpages.sh and then run ./coloredpages.sh "pdfname.pdf" and it should return a list of page numbers.

This requires ImageMagick and probably Ghostscript to be installed. And it's not the speediest thing in the world.

Sorry, I have no clue how to adapt this for Windows (without Cygwin or similar, anyway).

share|improve this answer
    
Thanks, I will give it a shot when I have a linux running. I may find a better print shop that can detect it. –  None Jan 18 '11 at 7:45
add comment

We have a tool Rapid PDF Count that can count Color and BW/Gray pages in pdf's

see: http://www.traction-software.co.uk/rapidpdfcount/index.html

share|improve this answer
3  
Care to explain what features this products has or why its any good? –  Ivo Flipse Mar 28 '12 at 12:48
add comment

Having the same task as the OP and working in Windows, I've found the following solution to work quickly and nicely: Spool File Page Counter SDK is non-free but the evaluation version still does the job. Download the zip file from the above link, unzip it and run bin/C#_ParsingTest yourfile.pdf. You'll see something like

Page   1 is [   BW]
Page   2 is [Color]
...
Page 143 is [Color]
============
Statistics: bwPageCount=99, colorPageCount=44

The Rapid PDF Count mentioned in another answer here requires installation (which for my one-time job---dissertation printing) is a disadvantage. However it also does the job and provides a GUI. After installing it, run it, drag-and-drop the PDF file into it, check Color Pages Counting in Setup/Options, then click the Page count files in list button.

Interestingly, the results for my thesis differ by 1 page (99/44 vs. 100/43). I believe, this is because some figure (I made all with Inkscape) is actually black-and-white but is described as colour in metadata. I am not sure. What I didn't find in Rapid PDF Count is a list of all colour/B&W pages, so I cannot tell the exact source of this discrepancy.

share|improve this answer
add comment

Found this over at http://root42.blogspot.de/2012/10/counting-color-pages-in-pdf-files.html

gs -o - -sDEVICE=inkcov input.pdf | grep -v "^ 0.00000  0.00000  0.00000" | grep "^ " | wc -l

Worked well for me

Total page count can be found by

pdfinfo input.pdf | grep Pages:
share|improve this answer
    
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes or disappears. –  Andrea Feb 26 at 10:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.