Skip to content

Instantly share code, notes, and snippets.

@flobeck
Created July 30, 2015 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flobeck/d6d36abb6859c7221f9c to your computer and use it in GitHub Desktop.
Save flobeck/d6d36abb6859c7221f9c to your computer and use it in GitHub Desktop.
# cropping multiple .pdfs with pdfcrop
# place this script in the directory with the pdfs you want to crop
# usage: python pdfcrop.py <left> <top> <right> <bottom>
import sys, os, subprocess
pdfcrop = 'pdfcrop --margin \'-%s -%s -%s -%s\' %s %s'
pdfs = [f for f in os.listdir('.') if f.endswith('.pdf')]
for pdf in pdfs:
cmd = pdfcrop % (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], pdf, 'cropped'+pdf)
subprocess.call(cmd, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment