Command Line PDF Manipluation - Double Sided Scan - Front and Reversed Back
Merge two PDFs scanned from a double sided print, front.pdf
and
reverse.pdf
. The reverse.pdf
side is scanned in the reverse order to the
front.
Extract images from multiple PDFs. The Poppler toolset provides pdfimages
.
mkdir -p images/front
mkdir -p images/reverse
pdfimages -p -all front.pdf images/front/
pdfimages -p -all reverse.pdf images/reverse/
Rename by odd page numbers in same order.
cd images/front
i=1; for f in `ls -1 -- *.jpg | sort` ; do mv -- "$f" p-$i.jpg; i=$[$i + 2]; done
mv * ..
Rename to even page numbers, reversing.
cd images/reverse
n_files=$(ls -1 -- *.jpg | wc -l)
i=$[$n_files*2] ; for f in `ls -1 -- *.jpg | sort` ; do mv -- "$f" p-$i.jpg; i=$[$i - 2]; done
mv * ..
Create PDF from images. Using https://imagemagick.org/ or the fork http://www.graphicsmagick.org/
cd images/
convert `ls -1 p-*.jpg | sort -n -t '-' -k 2` foo.pdf
No need for tools like PDFSam…
Subscribe via RSS