Skip to content

Templates

The generation of arbitrary visual signatures appearances (called stamps) is provided through a Typst-based plugin system.

Parameters

The parameters given through either the config, environment or as CLI options are passed (more or less) directly to the Typst signature template. Therefore, by convention, their values should be valid Typst objects/primitives. In other words, most parameter values need to be wrapped into Typst content blocks [ ... ], e.g. name=[Some Name]. However, some values might also be handled differently, like inset=3pt. Which type a parameter expects needs to be documented by the template itself.

There exist no defaults regarding the visual impact of these parameters on the template. The only convention is that height, width, and rotation should be handled as shown in the example below.

WARNING

If the template is specified on the command line, parameters in the config are ignored.

Defaults

For some parameters default values are supplied. The following are automatically set:

  • height: The height of the selected signature box
  • width: The width of the selected signature box
  • rotation: The counter-rotation of the page containing the signature
    (i.e. the necessary rotation to counteract the page's own rotation)
  • date: The current time + date

Additionally, the following are extracted from the given signature (if available):

  • cert_name: from the certificate's subject (id: 2.5.4.3)
  • cert_country: from the certificate's subject (id: 2.5.4.6)
  • cert_org: from the certificate's subject (id: 2.5.4.10)
  • cert_surname: from the certificate's subject (id: 2.5.4.4)
  • cert_given_name: from the certificate's subject (id: 2.5.4.42)
  • cert_title: from the certificate's subject (id: 2.5.4.12)
  • cert_initials: from the certificate's subject (id: 2.5.4.43)
  • cert_pseudonym: from the certificate's subject (id: 2.5.4.65)
  • cert_email: from the certificate's subject (id: 1.2.840.113549.1.9.1)

References

To allow for some additional flexibility, parameters may contain references to others. These references are resolved before they are passed to Typst. A reference is specified by using curly braces {<name>}.

These references may very well use the default parameters.

Example:

info='[This is my custom Signature\ Date: #{date}]'

INFO

By convention, all default parameters expect to be invoked from Typst code-mode, thus to use them you need to prefix them by a hash #.

The previous example resolves to:

info='[This is my custom Signature\ Date: #[13.11.2025 10:51:34 ...]]'

The parameter precedence is as follows:

(template default) < (default) < config < environment < CLI option

Shell Commands

As another convenience, parameters may also contain shell commands. These are specified by a syntax similar to the references {shell: <cmd>}.

Example:

date='[{shell: date "+%A, %d %B %Y %H:%M"}]'

Custom stamps

To create your own stamp, you need to create a directory which contains a typst.toml as described by the Typst documentation.

Your main Typst file (referenced as entrypoint in the config) needs to contain a function called stamp. This function will be invoked during the signature creation. It may accept arbitrary named parameters. Most of these parameters need to be supplied by the user.

To ensure the stamp fits properly within the signature box, the following boilerplate is recommended:

typst
#let stamp(height: 0pt, width: 0pt, rotation: 0deg, ..args) = {
  rotate(rotation,
    box(height: height, width: width,
      /* your code here */
    ),
    reflow: true
)}

To start from an existing stamp, just copy one of the directories from the templates.

Technical Details

The specified Typst package directory is copied to the local Typst cache into the resignation namespace. This can be found at:

${XDG_CACHE_HOME:-~/.cache}/typst/packages/resignation/<name>/<version>
~/Library/Caches/typst/packages/resignation/<name>/<version>
%LOCALAPPDATA%/typst/packages/resignation/<name>/<version>

The stamp PDF is then generated by the following Typst code:

typst
#import "@resignation/<name>:<version>": stamp

#set page(width: auto, height: auto, margin: 0pt)
#stamp({args})

Where {args} is substituted by a list of all parameters passed through either the config, environment or as CLI option.