PDF Tools

PDF tools installed on this system for viewing, annotation, signing, merging, and conversion.

Zathura (Viewer)

Minimalistic PDF/ePub/XPS viewer with vim-like keybindings. Uses mupdf backend.

# Open PDF
zathura document.pdf

# Open at specific page
zathura -P 42 document.pdf

# Open with password
zathura -w 'secretpassword' encrypted.pdf

Key Bindings

Key Action

j/k

Scroll down/up

h/l

Scroll left/right

J/K

Next/previous page

gg/G

First/last page

nG

Go to page n

+/-

Zoom in/out

=

Fit to width

a

Fit page

s

Fit width

r

Rotate

/

Search forward

n/N

Next/previous search result

Tab

Toggle index (TOC)

d

Toggle dual-page mode

F5

Toggle presentation mode

q

Quit

Config

Config file: ~/.config/zathura/zathurarc

# Example settings
set selection-clipboard clipboard
set adjust-open width
set recolor true
set recolor-lightcolor "#1a1b26"
set recolor-darkcolor "#c0caf5"

Xournal++ (Annotation/Signing)

Annotate PDFs by drawing directly with mouse, touchpad, or stylus. Best option for signing documents.

# Open PDF for annotation/signing
xournalpp ~/Downloads/document.pdf

Workflow: Sign a PDF

  1. Open document with xournalpp document.pdf

  2. Select Pen tool (P key)

  3. Draw signature directly on document

  4. File > Export as PDF

With touchscreen or drawing tablet, signatures look exactly like pen on paper. Even mouse works well for natural-looking signatures.

Key Bindings

Key Action

P

Pen tool

E

Eraser

H

Highlighter

T

Text tool

Ctrl+Z

Undo

Ctrl+Shift+E

Export as PDF

qpdf (Transformation)

Swiss army knife for PDF manipulation: merge, split, encrypt, decrypt, linearize, repair.

# Merge multiple PDFs
qpdf --empty --pages file1.pdf file2.pdf file3.pdf -- merged.pdf

# Extract pages 1-10
qpdf input.pdf --pages . 1-10 -- output.pdf

# Extract specific pages (1, 3, 5-7)
qpdf input.pdf --pages . 1,3,5-7 -- output.pdf

# Split into single-page PDFs
qpdf --split-pages input.pdf output-%d.pdf

# Rotate all pages 90 degrees
qpdf input.pdf --rotate=+90 -- output.pdf

# Rotate specific pages
qpdf input.pdf --rotate=+90:1-5 -- output.pdf

# Decrypt password-protected PDF
qpdf --decrypt --password=secret input.pdf output.pdf

# Encrypt with password
qpdf --encrypt userpass ownerpass 256 -- input.pdf output.pdf

# Linearize for web (fast web view)
qpdf --linearize input.pdf output.pdf

# Repair corrupted PDF
qpdf input.pdf --replace-input

# Check PDF for problems
qpdf --check input.pdf

# Show PDF structure
qpdf --show-object=trailer input.pdf

Page Range Syntax

Pattern Meaning

1-5

Pages 1 through 5

1,3,5

Pages 1, 3, and 5

1-5,8,10-12

Pages 1-5, 8, and 10-12

r1

Last page

r1-r3

Last 3 pages (reverse order)

1-z

All pages

.

Current file (in --pages context)

img2pdf (Image to PDF)

Lossless conversion of images to PDF. Does NOT re-encode JPEG/PNG - just wraps them.

# Single image to PDF
img2pdf image.jpg -o output.pdf

# Multiple images to single PDF
img2pdf *.jpg -o combined.pdf

# With page size
img2pdf --pagesize A4 image.jpg -o output.pdf

# Fit image to page
img2pdf --fit shrink --pagesize A4 image.jpg -o output.pdf

# From pipe (screenshot to PDF)
grim -g "$(slurp)" - | img2pdf -o screenshot.pdf

# Set PDF metadata
img2pdf --title "My Document" --author "Evan" scan.jpg -o doc.pdf

# Create PDF/A compliant output
img2pdf --pdfa scan.jpg -o archive.pdf

weasyprint (HTML/CSS to PDF)

Render HTML and CSS to PDF. Excellent for generating reports, invoices, documentation.

# HTML file to PDF
weasyprint input.html output.pdf

# URL to PDF
weasyprint https://example.com page.pdf

# With custom stylesheet
weasyprint -s style.css input.html output.pdf

# PDF/A compliant (archival)
weasyprint --pdf-variant pdf/a-3b input.html archive.pdf

# With attached files
weasyprint -a attachment.txt input.html output.pdf

# From stdin
echo '<h1>Hello</h1>' | weasyprint - output.pdf

# Optimize images in output
weasyprint --optimize-images input.html output.pdf

Example: AsciiDoc to PDF via HTML

# Convert AsciiDoc to HTML, then to PDF
asciidoctor -o - document.adoc | weasyprint - document.pdf

pandoc (Document Conversion)

Universal document converter. Can output PDF via LaTeX, weasyprint, or other engines.

# Markdown to PDF (requires LaTeX)
pandoc input.md -o output.pdf

# With custom margins
pandoc input.md -V geometry:margin=1in -o output.pdf

# Two-column layout
pandoc input.md -V classoption=twocolumn -o output.pdf

# Using weasyprint engine (no LaTeX needed)
pandoc input.md --pdf-engine=weasyprint -o output.pdf

# From multiple files
pandoc chapter1.md chapter2.md chapter3.md -o book.pdf

# With table of contents
pandoc --toc input.md -o output.pdf

# With syntax highlighting
pandoc --highlight-style=tango input.md -o output.pdf

potrace (Bitmap to Vector)

Trace bitmaps to scalable vector graphics. Can output PDF.

# PNG to PDF (vector)
potrace -b pdf input.pbm -o output.pdf

# With scaling
potrace -b pdf -W 8.5in -H 11in input.pbm -o output.pdf

# Convert PNG to PBM first (potrace needs bitmap)
convert input.png -threshold 50% input.pbm
potrace -b pdf input.pbm -o output.pdf

# Invert colors (white on black to black on white)
potrace -b pdf --invert input.pbm -o output.pdf

Quick Reference

Task Tool Command

View PDF

zathura

zathura doc.pdf

Sign PDF

xournalpp

xournalpp doc.pdf

Merge PDFs

qpdf

qpdf --empty --pages a.pdf b.pdf — out.pdf

Split PDF

qpdf

qpdf --split-pages in.pdf out-%d.pdf

Extract pages

qpdf

qpdf in.pdf --pages . 1-10 — out.pdf

Decrypt PDF

qpdf

qpdf --decrypt --password=X in.pdf out.pdf

Image to PDF

img2pdf

img2pdf *.jpg -o out.pdf

HTML to PDF

weasyprint

weasyprint in.html out.pdf

Markdown to PDF

pandoc

pandoc in.md -o out.pdf

Rotate PDF

qpdf

qpdf in.pdf --rotate=+90 — out.pdf

Not Installed (Candidates)

Tools worth considering:

  • pdftk - Alternative to qpdf, Java-based

  • pdfgrep - grep for PDFs (search text inside PDFs)

  • ocrmypdf - Add OCR text layer to scanned PDFs

  • pdfarranger - GUI for rearranging pages

  • diffpdf - Visual diff between PDFs