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).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signpdf_ui-0.2.0.tar.gz (174.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

signpdf_ui-0.2.0-py3-none-any.whl (101.1 kB view details)

Uploaded Python 3

File details

Details for the file signpdf_ui-0.2.0.tar.gz.

File metadata

  • Download URL: signpdf_ui-0.2.0.tar.gz
  • Upload date:
  • Size: 174.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for signpdf_ui-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ea375cae1e7c296043cf2f742172f441a0c55755114b9dcfed15103ebe89899a
MD5 52675db2ed2240ab77c740fc7b204734
BLAKE2b-256 0c8920a4e151fe485d513372c98fbd419778e5c0666d530547bd0f6d82cc386f

See more details on using hashes here.

File details

Details for the file signpdf_ui-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: signpdf_ui-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 101.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for signpdf_ui-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3599342db055082c5f78674c758b5329aecb09137512b6996fd0b59d4201020c
MD5 f3b28d70cec5624d91ede39771fc96cf
BLAKE2b-256 196d639c26be91b17e10941c140d513b6b04296fbf54a0e7f07e79ea8352f379

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page