修訂 | 20ccb5873c473ac5169176c0abc726ac68dae325 (tree) |
---|---|
時間 | 2020-11-18 20:35:05 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
A script to remove only the top and bottom margins of a pdf.
@@ -0,0 +1,11 @@ | ||
1 | +#!/bin/bash | |
2 | +fname="$1" | |
3 | +pagesize=( $(pdfinfo "$fname" | grep "Page size" | cut -d ":" -f2 | \ | |
4 | + awk '{ print $1,$3 }') ) | |
5 | +bounding=( $(pdfcrop --verbose "$fname" | grep "%%HiResBoundingBox" | \ | |
6 | + cut -d":" -f2 ) ) | |
7 | +rm "${fname//.pdf/-crop.pdf}" | |
8 | +lmarg="${bounding[0]}" | |
9 | +rmarg="$(python -c "print(${pagesize[0]} - ${bounding[2]})")" | |
10 | +pdfcrop --margins "$lmarg 0 $rmarg 0" "$fname" "$fname" | |
11 | + |