Skip to content

PDF

wiki.ubuntuusers.de: PDF

Viewers

Formulare ausfüllen

Evince

By default, Evince has a very annoying zoom limit Fix it with:

$ gsettings get org.gnome.Evince page-cache-size
  uint32 512
$ gsettings set org.gnome.Evince page-cache-size 1024

Warning - may use a lot of RAM!

Merge/Rearrange multiple PDFs

GUI

pdfarranger Recently updated

sudo apt install pdfarranger

cli

pdfunite in-1.pdf in-2.pdf in-n.pdf out.pdf

Reduce PDF size

Usage:

ps2pdf input.pdf output.pdf

Convert images to PDF

With img2pdf

sudo apt install img2pdf

DINA4 portrait:

img2pdf --pagesize A4 --border 2cm:2.5cm a.png > a.pdf

DINA4 landscape:

img2pdf --pagesize A4^T --border 2cm:2.5cm a.png > a.pdf

Issues:

  • Can't combine multiple images into one pdf page, each image creates a new PDF page

With imagemagick

Convert and scale jpg to DINA4 pdf:

convert a.jpg -compress jpeg -resize 1240x1753 -extent 1240x1753 \
  -gravity center  -units PixelsPerInch -density 150x150 a.pdf
convert b* -compress jpeg -resize 1240x1753 -extent 1240x1753 \
  -gravity center  -units PixelsPerInch -density 150x150 b.pdf

Combine multiple images in one PDF page:

montage src* -mode concatenate -tile 1x -resize 500x \
  -page a4 -gravity center dst.pdf

Extract images from PDF

pdfimages -png document.pdf .

Convert PDF to high quality image

Convert PDF to image with high resolution

convert -verbose -density 150 -trim -quality 100 -flatten -sharpen 0x1.0 \
   image.png

PDFTK

pdftk

apt install pdftk-java

Remove password from pdf

How to remove the password from a PDF

qpdf --password=YOURPASSWORD-HERE --decrypt input.pdf output.pdf

Or: Open the protected file and use ctrl+p or use print optiont to print the file, now save the file as pdf.

PFD diff tools

Diffoscope

Best PDF diff tool so far ! Website

Install:

pamac install python-pypdf
sudo pacman -S diffoscope tinyxxd python-pdfminer

Usage:

diffoscope resume.pdf /tmp/resume.pdf

diff-pfd

diff-pdf

Can't get a useful diff at all :/

Other diff viewers

Generate PDF

Markdown to PDF

see markdown.md "Generate PDF from markdown"

HTML to PDF

Weasyprint

HTML -> PDF generator

Issues:

Various tools

Headless chromium:

chromium --headless --disable-gpu --print-to-pdf='varac.pdf' --hide-scrollbars
  --run-all-compositor-stages-before-draw  --no-sandbox --virtual-time-budget=60000 varac.html`

Other PDF generators

  • reportlab: source code only mercurial : apt install python3-reportlab
  • python-pdfkit: Wkhtmltopdf python wrapper to convert html to pdf. Only converts files/URLs to PDFs.
  • rst2pdf
  • PyPDF4: python, last commit 2020
  • pyFPDF: Python, last commit 2018
  • pdfrw: Python, last commit 2018