| 7 | from pyPdf import PdfFileWriter, PdfFileReader |
| 8 | |
| 9 | def usage (): |
| 10 | print """sjvr767\'s PDF Cropping Script. |
| 11 | Example: |
| 12 | my_pdf_crop.py -s -p 0.5 -i input.pdf -o output.pdf |
| 13 | my_pdf_crop.py --skip --percent 0.5 -input input.pdf -output output.pdf |
| 14 | \n |
| 15 | REQUIRED OPTIONS: |
| 16 | -p\t--percent |
| 17 | The factor by which to crop. Must be positive and less than or equal to 1. |
| 18 | |
| 19 | -i\t--input |
| 20 | The path to the file to be cropped. |
| 21 | \n |
| 22 | OPTIONAL: |
| 23 | -s\t--skip |
| 24 | Skip the first page. Ouptut file will not contain the first page of the input file. |
| 25 | |
| 26 | -o\t--output |
| 27 | Specify the name and path of the output file. If none specified, the script appends \'cropped\' to the file name. |
| 28 | |
| 29 | -m\t--margin |
| 30 | Specify additional absolute cropping, for fine tuning results. |
| 31 | \t-m "left top right bottom" |
| 32 | """ |
| 33 | sys.exit(0) |
| 34 | |
| 35 | def cut_length(dictionary, key, factor): |
| 36 | cut_factor = 1-factor |