Pdf manipulation on Linux
Stack pdf together
$ pdfunite in1.pdf in2.pdf in3.pdf ou.pdf
Extract all pages of a pdf
$ pdftk input.pdf burst
Remove the last page of a PDF
$ pdftk inputFile.pdf cat 1-r2 output outputFile.pdf
Rotate pdf
$ pdftk in.pdf rotate 1-endeast output out.pdf
1-endselect all pageseastis the direction of the rotation (could benorth,south,east,west,left,right,down)
Convert image to pdf
$ convert myImages*.jpg -density 150x150 -quality 50 -rotate 90 -compress jpeg output.pdf
A4 format:
$ convert image.jpg -page a4 output.pdf
Convert pdf to image
$ pdftoppm -png doc.pdf doc
Convert markdown to pdf
$ pandoc -f markdown in.md -V geometry:margin=0.2in -o out.pdf
Convert HTML to pdf
$ prince my.html -o my.pdf
This is not verry reliable, most of the time printing the page to pdf works better (with the right settings).
Wattermark pdf
watermark.pdf is a transparent pdf in the parent folder. This will add the watermark to all pdf and flattent the pdfs into images. The result will be in the final folder:
rm -rf marked final
mkdir marked
mkdir final
for f in ./*.pdf; do pdftk "$f" stamp ../watermark.pdf output "marked/$f"; done
for f in ./*.pdf; do gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite -dPreserveAnnots=false -sOutputFile="final/$f" "marked/$f" ; done