Page 1 of 1

Specifying pages/frames to read - converting PDF

Posted: 2013-02-21T09:49:58-07:00
by JohnT
Hi All,

interesting situation here. I have a few PDFs where random pages are inverted with white text on black background. I want to convert the entire document back to black text on white background, by specifying on the command line which pages to invert.

I found this useful blog post: http://blog.dillfrog.com/how-to-invert- ... agemagick/

It shows to specify frame/page numbers like so:

convert -density 300 -negate "in.pdf[24-28]" out.pdf

The problem is, there are pages I want to skip in the inversion process, but still have them in the final "out.pdf".

Is this possible? Can I specify only to invert pages 1 and 2 of a 10-page document, but still have a 10 page output file (with pages 3-10 untouched)?

I was thinking something such as this would be useful, using the caret to specify which pages to skip: convert -density 300 -negate "in.pdf[^0-23][24-28]" out.pdf

Re: Specifying pages/frames to read - converting PDF

Posted: 2013-02-21T10:08:51-07:00
by fmw42
I do not believe that you can do what you want. You will likely have to process it in two commands, one for the inverted pages and another for the non-inverted pages.

You can skip frames, but you only get output the frames you tell it to use.

Re: Specifying pages/frames to read - converting PDF

Posted: 2013-02-26T22:04:42-07:00
by anthony
Also as IM is using ghostscript to convert the pages to raster format it will convert ALL the pages first then extract the ones specified. It does not have a true understanding of the PDF format.

you are better off using PDF specific tools to extract the desired pages first, then use ImageMagick later.