0

How do I split colored and grayscale pages of a PDF in Linux, so I can print with less cost?

0

A quick and dirty way of separating a document's colored and black-white pages would be as follows:

input=input.pdf; color_output=color_$input; wb_output=wb_$input; pdfjam $input $(gs -o - -sDEVICE=inkcov $input | grep -v " 0.00000  0.00000  0.00000" | grep -B1 "OK" | grep "Page" | awk '{print $2","}' | sed ':a;N;$!ba;s/\n/ /g' | rev | cut -c 2- | rev | sed 's/ //g') -o $color_output && pdfjam $input $(gs -o - -sDEVICE=inkcov $input | grep -B1 " 0.00000  0.00000  0.00000" | grep "Page" | awk '{print $2","}' | sed ':a;N;$!ba;s/\n/ /g' | rev | cut -c 2- | rev | sed 's/ //g') -o $wb_output

Just change the name input.pdf to your desired one. It makes use of gs to detect colored/bw pages and pdfjam to merge split pages.

PS: It is not working perfectly. Some grayscale pages may be detected as colored (due to nature of the CMYK representation of them). However this just saves time (and money).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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