Search code examples
bashpdfsplitextractcrop

Bash for splitting and auto cropping PDF files


I have a long PDF file made of various numerized pages. In each page there's a small ticket that I would like to extract and save in a new different file.

I assume that I have to split the long PDF file in various pages and auto crop each ones to keep the small ticket.

Is there a bash script (or other) that could help me for that ?

Regards


Solution

  • Assuming you are cropping in the same place on each page, we can use cpdf to do this:

    First, crop all the pages...

    cpdf -crop "200 300 150 200" in.pdf -o out.pdf
    

    Then, split them out...

    cpdf -split out.pdf -o file%%%.pdf