Skip to content
wanikhawarPublic

About

A fast, lightweight PDF reader and annotator for Linux, written in Rust: smooth ink, smart highlighter, ticks, text markup and vim-style navigation

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Ochre

CI Latest release

A fast, lightweight PDF reader and annotator for Linux, written in Rust (egui + pdfium).

Ochre is an earth pigment made of iron oxide (rust, more or less). Scribes and artists have marked up pages with it for centuries.

A tour of Ochre: highlighting, underlining and striking out text, pen ink, a text box, an arrow, ticks, notes, restyling a selection, page tools, tabs and search

Features

  • Freehand ink (pen and highlighter) with smoothing: a stabilizer while drawing, then fitted to Bézier curves, with anti-aliased rendering (tiny-skia).
  • Smart highlighter: a stroke that starts on text highlights the text in straight lines; anywhere else (or with Alt held) it draws freehand.
  • Text boxes, shapes and text markup (highlight, underline, strike out).
    • Shapes: tick, cross, rectangle, ellipse, line and arrow.
    • A tick or cross is placed with a single click.
    • Rectangles and ellipses can be filled, with a separate fill opacity.
    • A text box fits its text when you click to place it. Drag instead to set its size: lines wrap to the width, and the box grows taller if the text needs more room. While typing, drag the handles on its right side, bottom or corner to change the size.
  • Tool settings in a popup from the status bar's settings button: palette, custom color picker with hex input, and width, size and opacity that you can drag or type.
  • Select, move, resize, restyle and delete annotations, plus an eraser and undo/redo.
    • Drag a corner handle to resize (Shift keeps the proportions). Resizing a text box by a corner changes its font size; its side handles change its width and height.
    • Drag either end of a line or arrow.
    • Rotate with the round handle above the selection (Shift snaps to 15°). Text markup follows the page text, so it doesn't rotate.
    • Select several at once: drag a box from empty space (Shift+drag adds to the selection, and also works over text), Shift+click to add or remove one, or Ctrl+A for everything on the page. A group moves, restyles (color, width, opacity, fill) and deletes together.
    • Copy, cut and paste annotations (also between tabs and Ochre windows), duplicate them with Ctrl+D, and nudge them with the arrow keys.
    • The Select tool also selects page text: drag, or double-click a word.
    • Copy selected text with Ctrl+C, or turn it into a highlight, underline or strike-out.
  • Notes on any annotation: select it and choose "Add note", press Enter, or double-click it.
    • Annotations with a note show a badge; hover over it to read the note.
    • Notes are saved as standard /Contents comments, so Acrobat, Okular and others show them too. Notes on other apps' annotations are shown read-only.
  • Sticky notes anywhere on the page (C): click to place a comment pin and type the note. Hover over a pin to read it, click it with the tool (or double-click it with Select) to edit it, and drag it with Select to move it. They're saved as standard /Text notes that other viewers show, and they aren't printed.
  • Vim-style navigation and / search (smartcase, n / N).
  • Page tools in the left sidebar's Pages tab: thumbnails (with your annotations) to go to a page, and to rotate, delete, reorder (drag) or extract pages to a new PDF. Select several with Ctrl+click / Shift+click; the tools act on the selection, or on the page in view. Annotations, the contents and links follow their pages, and it's all undoable, even after saving.
  • Two sidebars, open together or apart. On the left (F9), the PDF's contents, with the section you're reading highlighted, and the pages. On the right (F10), a list of all annotations by page (highlighted text, notes, other apps' annotations); click one to go to it. Filter the list by color, by type (highlights, drawings, shapes…) or to those with a note.
  • Fullscreen (F11): the pages fill the screen with no toolbars or sidebars. Every shortcut still works; Esc or F11 leaves.
  • A status bar shows the active tool with a button for its settings (color, width, opacity), and the page and zoom controls, without covering the page.
  • Links inside the document work with the Select and Hand tools. Web and email links open in your browser or mail app. Alt+← or the Back button returns to where you were.
  • Tabs: every file opens in its own tab, from the Open dialog, Recent files, drag and drop (several at once), or the command line (ochre a.pdf b.pdf). Opening a file that's already open switches to its tab. Each tab keeps its own zoom, position, selection and search.
  • Remembers your place: each file reopens at the page and zoom where you left it.
  • Page colors for reading comfort, from the status bar or Ctrl+I: Sepia (aged paper and dark brown ink, like an old photo) or Dark (lightness inverted, hue kept, so colored text and highlights keep their colors). Annotations follow along. It only changes the display: the saved PDF keeps its colors.
  • Printing (Ctrl+P), with a live preview of the exact sheets in print order. Your annotations print too, saved or not.
    • Page ranges (1-3, 7, 10-), or tick pages on the Pages tab; odd or even pages only.
    • Copies with collate on or off, and reverse order (on by default, for printers that stack pages face up).
    • 1, 2, 4, 6, 9 or 16 pages per sheet, orientation, scaling and rotation.
    • Booklets: fold the printed stack in half and it reads like a book. Split thick ones into several thinner booklets, bind on the right for right-to-left text, and add a gutter at the fold.
    • Guided manual two-sided printing for printers without a duplexer, with a calibration test and a note per printer on how the stack goes back in.
    • Several documents in one job: add other open tabs or PDF files, drag them into order, and optionally start each on a new sheet.
    • Every option the printer's driver offers (quality, color or grayscale, paper, media type and the advanced ones), presets, and each printer's last settings. The preview turns gray for grayscale, and follows the driver's brightness, contrast and color balance sliders (approximately: drivers don't publish their formulas).
    • A count of the paper you'll use and how much n-up, two-sided and booklets save; double-click a sheet to see it full size; or save the result as a PDF.
  • Zoom (fit width / fit page / Ctrl+wheel), recent files, and light and dark themes that follow the system.

Highlights, notes, ink, a text box and shapes, with the contents in the sidebar:

Ochre with a highlight that has a note, an underline, pen ink, a text box, an arrow and ticks on the page, and the contents in the sidebar

Select several annotations to move or restyle them together; the sidebar lists every annotation and its note:

Three annotations selected, the style popup with palette, width, opacity and custom color picker, and the annotations list in the sidebar

Page thumbnails with your annotations, two files open in tabs, and search matches on the page:

The Pages tab with two pages selected and the page tools, two tabs, and a search for "pigment" with its matches outlined

Annotations are standard PDF annotations

Saving writes regular /Ink, /FreeText, /Square, /Circle, /Line, /Highlight, /Underline and /StrikeOut annotations, each with an appearance stream. Okular, Firefox, Chrome, Acrobat and others display them the same way.

Annotations made by other software are preserved:

  • Saving appends an incremental update: the original file bytes are kept unchanged and only the changes are added after them.
  • Other apps' annotations are never rewritten, and saving or undoing never removes them. They can be removed only by selecting one and pressing Delete, and that deletion can be undone, even after saving (the next save puts it back).
  • Ochre's annotations are tagged with a /NM starting with ochre- (older ones with inkpdf-). If another app later edits one of them, it's treated as that app's annotation and left alone.

Install

From a release (Linux x86_64)

Download the latest ochre-<version>-x86_64-linux.tar.gz from the releases page, then:

tar -xzf ochre-*-x86_64-linux.tar.gz
cd ochre-*-x86_64-linux
./install.sh          # installs to ~/.local (set PREFIX to change)

From source

git clone https://github.com/wanikhawar/ochre
cd ochre
./install.sh          # builds with cargo and downloads pdfium if needed

Printing uses CUPS (the cups package), which almost every Linux desktop already has. Ochre runs without it; only printing needs it. Print settings and presets are kept in ~/.config/ochre/print.json. If you use Print Studio, its settings are copied over the first time.

Either way you get:

  • ochre in ~/.local/bin;
  • pdfium in ~/.local/lib/ochre;
  • a launcher entry with an icon, offered under "Open with" for PDFs.

./uninstall.sh removes them again.

Run ochre file.pdf, or start it from your app launcher.

Developing

mkdir -p vendor/pdfium
curl -L https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-linux-x64.tgz | tar -xz -C vendor/pdfium
cargo run --release -- some.pdf

Ochre looks for libpdfium.so in these places, in order:

  1. $OCHRE_PDFIUM
  2. Next to the executable, in lib/ beside it, or in ../lib/ochre
  3. ~/.local/lib/ochre
  4. This project's vendor/pdfium/lib
  5. The system library path (e.g. AUR pdfium-binaries)

Shortcuts

Vim-style navigation works whenever you're not typing in a text field.

Key Action
j / k, arrow keys (hold) Scroll (arrows nudge selected annotations instead)
l / h Next / previous page
Ctrl+D / Ctrl+U Half a screen down / up
gg / G First page / end of document
/ Search (Enter to confirm, Esc to cancel). Ctrl+F reopens it with the last query selected
n / N Next / previous match (wraps around)
V / P / Shift+H / T / C / S / M / E Select / Pen / Highlighter / Text / Sticky note / Shape / Text markup / Eraser
Space + drag, middle drag Pan
Shift while drawing a shape Square / circle / 45° lines
Alt while highlighting Freehand even over text
Double-click a text box (Select tool) Edit it
Double-click an annotation, or Enter (Select tool) Add or edit its note
Ctrl+Enter, Esc Finish the note
Shift while resizing Keep proportions / 45° line ends
Drag on empty space, Shift+drag, Shift+click (Select tool) Box-select, add to selection, add/remove one
Ctrl+A (Select tool) Select every annotation on the page
Ctrl+C / Ctrl+X / Ctrl+V Copy / cut / paste annotations (Ctrl+C copies page text when text is selected)
Ctrl+D (with annotations selected) Duplicate them (otherwise half a page down)
Arrow keys, Shift+arrows (with annotations selected) Nudge 1 pt / 10 pt
Delete Delete selection
Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y Undo, redo
Ctrl+S, Ctrl+Shift+S Save, save as
Ctrl+P Print (in the print screen: print; Esc goes back, F9 hides the settings)
Ctrl+O, Ctrl+F Open, search (keeps the last query)
F9 Show or hide the left sidebar (contents, pages)
F10 Show or hide the annotations sidebar
F11 Fullscreen, with no toolbars or sidebars (Esc or F11 to leave)
Ctrl+I Page colors: normal, sepia, dark
Ctrl+Tab / Ctrl+Shift+Tab, Ctrl+PageDown / Ctrl+PageUp Next / previous tab
Ctrl+W, middle-click a tab Close the tab
Alt+←, mouse back button Back (after following a link or a contents entry)
Ctrl+wheel, Ctrl+= / Ctrl+-, Ctrl+0 Zoom, fit width
PageUp / PageDown / Home / End Scroll

Search uses smartcase: an all-lowercase query ignores case, while a query containing a capital letter matches case exactly.

Tests

cargo test

CI also checks formatting (cargo fmt --check) and runs clippy with warnings as errors. See CONTRIBUTING.md.

The tests cover:

  • geometry and stroke smoothing (including overshoot);
  • search;
  • the save round-trip, including preserving other apps' annotations and the original bytes;
  • a headless end-to-end run of every tool;
  • printing: page order for every layout, the print-ready PDFs, annotations on paper, and a check that the preview matches the printed PDF pixel for pixel.

To compare rendering with other viewers by eye:

OCHRE_SAMPLE=in.pdf OCHRE_OUT=/tmp/out cargo test visual -- --ignored
pdftoppm -png /tmp/out/annotated.pdf /tmp/out/poppler   # how Okular renders it

Known limitations

  • Password-protected or encrypted PDFs open read-only (no annotating).
  • Text boxes use the standard Helvetica font in the PDF. Characters outside Latin-1 display in Ochre but appear as ? in other viewers.

License

MIT. See LICENSE. Release archives also bundle pdfium (BSD-3-Clause and others; see licenses/ in the archive).

About

A fast, lightweight PDF reader and annotator for Linux, written in Rust: smooth ink, smart highlighter, ticks, text markup and vim-style navigation

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages