Skip to main content

Code style: black

signpdf-ui

An interactive terminal UI (TUI) that wraps pyhanko so you can sign PDFs on Linux without memorizing flags.

Advantages over Okular (which can also sign PDFs):

  • Easier setup (e.g. no Thunderbird needed)
  • Better customization of visual representation (text and watermark image)

Install

pip install signpdf-ui

After installing, run the one-time setup once:

signpdf-ui --init

This copies the bundled configuration templates (signpdf-ui.yml, pyhanko.yml, watermark.png) into your user config directory — typically ~/.config/signpdf-ui/ on Linux. Use --init --force to overwrite existing files.

Getting started

Run

signpdf-ui --demo

to copy bundled demo PDFs to /tmp/pdfsign-ui-demo-<timestamp>/ and print usage instructions. You can play around with those files and the bundled p12-certificate (password: KXzolC-test-pw-s9Ckp7oZ) — created for this demonstration purpose only.

Customization

To make signpdf-ui actually useful you have to customize it:

    1. signpdf-ui → button "Edit config for user interface" → insert the path for your p12 certificate at default_cert: ....
    1. signpdf-ui → button "Edit config for backend (pyhanko)" → adapt the stamp text to your needs.
    1. (optional) Adapt the png watermark image at $HOME/.config/signpdf-ui/watermark.png or set a different one. This has great impact on the visual appearance of your signature.

Test your setup with the demo PDF-files.

Usage

Interactive UI

Three ways to launch the wizard:

Command When to use
signpdf-ui Files are in the working directory — pick them inside the wizard.
signpdf-ui FILE.pdf You already know the file — opens directly at step 2 (mode selection).
signpdf-ui "docs/*.pdf" Multiple files matching a glob — opens at step 2 with all matches pre-loaded.

When started with a file or pattern, press Alt+← at any point to go back to step 1 (file path pre-filled).

screenshot: signpdf-ui main menu

Main menu entries:

  • Sign PDF(s) — four-step wizard: file/pattern → mode (existing signature field or custom area) → field/rect → certificate → confirm & sign. The confirmation screen shows the exact pyhanko sign addsig ... command(s) inline, with a Copy to clipboard button.
  • Edit config for user interface / Edit config for backend (pyhanko) — opens the respective YAML file in $VISUAL / $EDITOR (or xdg-open).
  • Send feedback — opens a dialog to send a short message (and optional e-mail address) to the developer.
  • Quit (Ctrl+q) — exits (also available from any screen).

Defining the signature area visually with Okular

When you choose "Place the signature in a custom area", the UI automatically extracts any existing rect annotations from the file and lists them for you to pick. If none are present (or you want a new one):

  1. Click "Open copy in Okular to draw rect". A temporary copy of the PDF opens in Okular — the original file is never touched.
  2. In Okular, select the Rectangle annotation tool (1. Activate annotation toolbar from Tools menu or press (F6); 2. Select Rectangle (hidden inside the Arrow-dropdown) or press Alt + 0).
  3. Draw a rectangle over the desired signature area, save with Ctrl+S, then close Okular. The UI reads the temp file automatically and imports the new rectangle.
  4. Adjust the page number (before the / character) if needed, then proceed.

Note: Save with Ctrl+S in Okular (not the sidecar .okular format). Draw exactly one rectangle — the UI will complain otherwise.

Non-interactive CLI

For (batch) signing without the UI, use pyhanko sign addsig directly — the confirmation screen in the UI shows the exact invocation, which you can copy to the clipboard as a starting point.

Configuration

signpdf-ui.yml lives next to pyhanko.yml in the user config dir. Keys:

Key Purpose
default_cert Path to a .p12 file used as the default in the cert picker.
pyhanko_config Path to the pyhanko style YAML. Relative paths resolve against the directory of signpdf-ui.yml.
style_name Stamp style name (must exist in pyhanko.yml).
editor Optional editor command override for the "Edit config" buttons.

The bundled pyhanko.yml defines a single stamp style my-signature with a watermark background. To change name, layout, watermark, etc., edit pyhanko.yml directly (see pyhanko's stamp documentation).

Development

pip install -e .
python -m pytest

Test layout:

  • tests/test_core.py — unit tests for command building and the two parsers (field-list parser, rect extractor). These are the things most likely to break under future pyhanko or PDF format changes, so they get explicit coverage.
  • tests/test_e2e.py — invokes the real pyhanko sign addsig against the bundled demo PDFs and the test certificate. Skipped if pyhanko is not on PATH.
  • tests/test_tui.py — headless Textual pilot tests for visual layout and wizard navigation (uses IsolatedAsyncioTestCase + Textual's run_test).
  • tests/fixtures/ — demo PDFs + a self-signed test certificate (password KXzolC-test-pw-s9Ckp7oZ, not used anywhere else).

Metadata

Release files for signpdf-ui 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for signpdf-ui 0.2.0
File Size Uploaded
signpdf_ui-0.2.0.tar.gz 174.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for signpdf-ui 0.2.0
File Interpreter ABI Platform
signpdf_ui-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 275.6 kB

Release files / signpdf_ui-0.2.0.tar.gz

Download URL signpdf_ui-0.2.0.tar.gz
Size 174.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ea375cae1e7c296043cf2f742172f441a0c55755114b9dcfed15103ebe89899a
BLAKE2b-256 checksum
How to use checksums
0c8920a4e151fe485d513372c98fbd419778e5c0666d530547bd0f6d82cc386f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release files / signpdf_ui-0.2.0-py3-none-any.whl

Download URL signpdf_ui-0.2.0-py3-none-any.whl
Size 101.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3599342db055082c5f78674c758b5329aecb09137512b6996fd0b59d4201020c
BLAKE2b-256 checksum
How to use checksums
196d639c26be91b17e10941c140d513b6b04296fbf54a0e7f07e79ea8352f379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page