coherentgraphics / cpdf-binaries

PDF Command Line Tools binaries for Linux, Mac, Windows
GNU Affero General Public License v3.0
604 stars 42 forks source link

Split on a range, merge and remove #4

Closed bcamp1973 closed 9 years ago

bcamp1973 commented 9 years ago

I have a common pattern that I need to handle, but I think I'm making it more complicated than it needs to be (I'm not very comfortable in the terminal). The requirements are:

  1. Split book into pages, each as p%%%.pdf
  2. Some single pages span multiple pages in the book, so they need to stay merged. For example: Pages 36-37 are a single page that need to stay merged as p036.pdf
  3. Blank pages should be removed

My first thought was to use 4 separate commands:

  1. Remove p38 (blank): cpdf source.pdf 1-37,39-end -o source.pdf
  2. Split pages 1-35: `cpdf source.pdf 1-35 AND -split -o p-%%%.pdf
  3. Pull out p36: cpdf source.pdf 36-37 -o p-036.pdf
  4. Split pages 38-end: cpdf source.pdf 38-end AND -split -label-startval 37 -o p-%%%.pdf

Long story short...lots of typing and not getting the results I want :(

johnwhitington commented 9 years ago

Could you upload an example PDF file somewhere, so I can play with your example command lines?

bcamp1973 commented 9 years ago

Sure, here's a file i've been playing with. Thx for looking into it!

johnwhitington commented 9 years ago

Your mistake here is that -label-startval is to do with page labels, and nothing to do with the names of split files. So your second set of split files are overwriting the first set.

If you're intending to buy a commercial license for cpdf (it looks like you're doing some commercial work), please email me directly using the contact address on the website, and we can consider adding a feature which does what you are trying to do with -label-startval 37 in your example.

bcamp1973 commented 9 years ago

Thanks for looking into it @johnwhitington, in the meantime I've composed some scripts for Automator (Mac OS) that are meeting my needs. I'll see how these work for a bit and reconsider cpdf in the future if my needs change.