stet-viewer 0.1.1

Interactive egui desktop viewer for PostScript, EPS, and PDF files
Documentation

stet-viewer

crates.io docs.rs

Interactive desktop viewer (egui / winit) for PostScript, EPS, and PDF files, backed by the stet rendering pipeline.

The viewer accepts display lists from either the stet PostScript interpreter or stet-pdf-reader — both produce the same DisplayList type — so a single window handles PS, EPS, and PDF input with no mode switch and no separate PDF viewer. Zoom, pan, and page navigation run off the stored display list; pages are never re-interpreted when the user zooms or moves.

What the viewer does

  • Supports PS, EPS, and PDF. Drag-and-drop any of the three formats onto the window; the viewer auto-detects and routes the input to the appropriate interpreter / parser.
  • On-demand viewport rendering via stet-render — any rectangular region at any zoom level, with no re-interpretation.
  • Multi-threaded banded rendering with cancellation, so zoom/pan feels responsive even at extreme zoom levels or on large pages.
  • Minimap overlay when zoomed past the window size; click or drag to jump.
  • Full-page background pre-rendering so scrolling a zoomed page stays smooth.
  • Per-page CMYK buffer tracking when the source declares a DeviceCMYK page group — blend-mode math then runs in the spec-correct colour space.

See the Viewer Guide for keyboard / mouse controls, DPI presets, and minimap behaviour.

Typical use: the stet CLI

Most users don't touch this crate directly — they use the viewer via the stet-cli binary:

cargo install stet-cli

stet document.ps          # PostScript / EPS
stet document.pdf         # PDF
stet                      # no args → REPL, viewer opens on first showpage
stet a.ps b.pdf c.eps     # batch — Space/Enter advances between files

Library API

The viewer runs on the main thread; the interpreter (or PDF reader) runs on a background thread and streams display lists into the viewer over channels. The public API reflects that split:

Item Role
run_viewer Enter the viewer event loop. Blocks until the window closes.
create_channels Build the matched (InterpreterEnd, ViewerEnd) pair that wires the two threads together.
ViewerMsg Interpreter → viewer messages (Page, NewJob, JobDone).
PageReady A single page's display list + pixel dimensions + reference DPI, ready for display.

For a worked example of driving the viewer directly, see stet-cli's run_viewer_mode — it wires up both the PS interpreter thread and the PDF-rendering thread to a single viewer.

License

Apache-2.0 OR MIT