Skip to content

Split a PDF into separate files containing colour and B&W pages

The pdfcolour utility allows one to split a PDF file apart to give two separate PDFs, one containing the colour pages and the other containing the B&W pages. That way, one can easily print the B&W pages on a faster, cheaper printer and reassemble the document by hand.

Instructions:

Download the pdfcolour-1.2.tgz file.
Extract it using tar -xzf pdfcolour-1.2.tgz
Recompile if necessary using the command “make”.
Run on a PDF with splitcolour input.pdf bw.pdf colour.pdf

This program has been tested on Linux (Fedora 10) and Cygwin (Vista x64).

For our American friends, this program will split a PDF into separate color and black/white files.

15 thoughts on “Split a PDF into separate files containing colour and B&W pages”

  1. – Perl script
    – uses:
    – “pscolor” (C, “using GS DLL as a ps colorpage separator”) by Carsten Hammer
    – “joinPDF” (Java, “Command line tool to join and split PDF files”, for mac) by Gerard Briscoe
    – Has hardcoded paths in shell scripts “splitPDF” and “joinPDF”
    – Depends on flex
    – Depends on libgs-dev
    – GNU GPL 2.0

    How it works:
    split PDF into single pages in temporary location
    use pscolor to detect whether color is on the page
    reassemble pages with color and pages without color into two pdf files.

    Does not work when adjusting said hardcoded paths.

    Does not compile with
    gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)

    Sorry, not a clue about Perl so if anyone tries to get this going for Ubuntu, you’re on your own.
    Look for unstuff to extract joinPDF from its MAC installer.

    Also I’m really looking for a way to split black and color into two pdfs so I can run the stack through a laser and then inkjet the images on, so I’m out.. 🙂

  2. Chris, this tool sounds great but I haven’t been able to use it. When I run it I get the error below. Do you know how to fix it?

    Thanks a lot!

    Exception in thread “main” java.lang.NoClassDefFoundError: Split
    Caused by: java.lang.ClassNotFoundException: Split
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: Split. Program will exit.
    Exception in thread “main” java.lang.NoClassDefFoundError: Concat
    Caused by: java.lang.ClassNotFoundException: Concat
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: Concat. Program will exit.
    cp: cannot stat `/tmp/splitcolour-9dWqXOW3/colour.pdf’: No such file or directory
    Exception in thread “main” java.lang.NoClassDefFoundError: Concat
    Caused by: java.lang.ClassNotFoundException: Concat
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: Concat. Program will exit.
    cp: cannot stat `/tmp/splitcolour-9dWqXOW3/bw.pdf’: No such file or directory

  3. Hi Julien,

    Sorry, I forgot to add an instruction to the README file.

    You need to edit the path in joinPDF and splitPDF from

    joinPDF:java -cp /home/stieltjes-p/rodgers/bin/PDF.jar Concat “$@”
    splitPDF:java -cp /home/stieltjes-p/rodgers/bin/PDF.jar Split “$@”

    to refer instead to the location where you have put the PDF.jar file.

    C.

  4. Hi

    I need to scan a document containing a mixture of colour and black pages. The black pages need to be black only in the PDF, not a mixture of CMYK or when they are printed on a colour printer, they will be printed using a mixture of CMYK toner, not just black toner.

    Any ideas?

    Thanks

  5. Dear Victoria,

    My program won’t help you with this, but I’m sure you can use a similar idea by writing a program that classifies pages as “black” if they have less than some threshold amount of other colours in the scans.

    Judging by your email address, your colleagues probably know far more about this than I do!

    With best wishes,

    Chris.

  6. Thanks for the great tool. I looked through many commercial prepress solutions and could not find anything close to this functionality. BTW, if anyone needs to run this tool in a high volume/batch mode with a need to suppress the gs output, simply add the following to the list of gs arguments (in pdfcolor.c):

    gsargv[4] = “-dQUIET”;

    You then have to adjust all subsequent indexes since arg4 is injected after arg3.

  7. Thanks for a great script. Can you tell me why I get this error?
    Unrecoverable error: typecheck in .Putdeviceprops

  8. Pingback: » Linux: Split PDF into colour and black/white pages

  9. Pingback: Create plain CSV list of pages with/without figures – oraerr.com

Leave a Reply

Your email address will not be published. Required fields are marked *