Programster's Blog

Tutorials focusing on Linux, programming, and open-source

PDF Cheatsheet

PDF

As with all of my cheatsheets, this is just a dumping ground for as things come up.

Save Unlocked PDF

If you get a PDF that requires a password to unlock, you can use this command to save a version that won't need unlocking in future.

PASSWORD="myPasswordHere"

pdftk \
  input.pdf \
  input_pw $PASSWORD \
  output output.pdf

This requires having installed pdftk with sudo apt-get install pdftk.

Create A PDF From A Series Of Images

The following command will create a PDF document where all the images are the same width.

convert -quality 100% -resize 629 \
  "path/to/image.png" -resize 629 \
  "path/to/image2.png" -resize 629 \
  output.pdf

If you want the images to not all be the same width, then remove the -resize 629. Also, all your images need to have the same DPI, otherwise it doesn't work.

References

Last updated: 18th May 2019
First published: 14th April 2019