Rev. | 20ccb5873c473ac5169176c0abc726ac68dae325 |
---|---|
Größe | 388 Bytes |
Zeit | 2020-11-18 20:35:05 |
Autor | Lorenzo Isella |
Log Message | A script to remove only the top and bottom margins of a pdf. |
#!/bin/bash
fname="$1"
pagesize=( $(pdfinfo "$fname" | grep "Page size" | cut -d ":" -f2 | \
awk '{ print $1,$3 }') )
bounding=( $(pdfcrop --verbose "$fname" | grep "%%HiResBoundingBox" | \
cut -d":" -f2 ) )
rm "${fname//.pdf/-crop.pdf}"
lmarg="${bounding[0]}"
rmarg="$(python -c "print(${pagesize[0]} - ${bounding[2]})")"
pdfcrop --margins "$lmarg 0 $rmarg 0" "$fname" "$fname"