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 |
|---|---|
|
Scroll down/up |
|
Scroll left/right |
|
Next/previous page |
|
First/last page |
|
Go to page n |
|
Zoom in/out |
|
Fit to width |
|
Fit page |
|
Fit width |
|
Rotate |
|
Search forward |
|
Next/previous search result |
|
Toggle index (TOC) |
|
Toggle dual-page mode |
|
Toggle presentation mode |
|
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
-
Open document with
xournalpp document.pdf -
Select Pen tool (
Pkey) -
Draw signature directly on document
-
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 |
|---|---|
|
Pen tool |
|
Eraser |
|
Highlighter |
|
Text tool |
|
Undo |
|
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 |
|---|---|
|
Pages 1 through 5 |
|
Pages 1, 3, and 5 |
|
Pages 1-5, 8, and 10-12 |
|
Last page |
|
Last 3 pages (reverse order) |
|
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 |
|
Sign PDF |
xournalpp |
|
Merge PDFs |
qpdf |
|
Split PDF |
qpdf |
|
Extract pages |
qpdf |
|
Decrypt PDF |
qpdf |
|
Image to PDF |
img2pdf |
|
HTML to PDF |
weasyprint |
|
Markdown to PDF |
pandoc |
|
Rotate PDF |
qpdf |
|
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