HOWTO: Scanned Images to Encrypted PDF in Linux

I had scanned a bunch of images and needed to bundle them all up into PDF. It took about 20 minutes to figure out, which is way too long, so here’s the steps so I can remind myself in the future:

  1. scanimage –batch=”%d.tiff” –format=tiff –resolution 300 –bgcolor white –mode=Lineart
  2. ls -tr1 | xargs -Ixxx lp -d PDF -o fitplot -o page-top=0 -o page-bottom=0 -o page-left=0 -o page-right=0 “xxx”
  3. gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=finished.pdf `ls -tr1` OR pdftk `ls -tr1` cat output finished.pdf
  4. pdftk finished.pdf output enc.pdf user_pw <pass> allow CopyContents printing

Notes:

  • gs may be able to do step 2, but if it can’t you’ll need to install “cups-pdf” and restart cups.
  • gs may also be able to do 1-3 in 1 step.
  • Similarly, pdftk might be able to do most of this in 1 step, too. It just didn’t occur to me until after I used it for the encryption.

Comments are closed.