Mudrit
Reference

Appearance

Appearance, RenderMode, Layout, Direction, SigField, Labels, Std14, Border, FontSource, and Image — the visible-signature API, field by field

Part of mudrit-pdfsign

Appearance controls how a visible signature is drawn: which content shows (text, graphics, or both), their layout, colours, fonts, and the Acro6 validity-icon overlay. It is built fluently; sensible defaults reproduce the classic text appearance. Appearance is #[non_exhaustive] — construct it through Appearance::new() / Appearance::default() / Appearance::invisible(), then chain the builder methods below.

use mudrit_pdfsign::{Appearance, Image, Layout, RenderMode};

// logo on the left, signer text on the right, with the viewer validity icon
let ap = Appearance::new()
    .mode(RenderMode::GraphicAndText)
    .layout(Layout::GraphicLeft)
    .graphic(Image::Png(std::fs::read("logo.png")?));

Appearance fields

Prop

Type

Appearance builder methods

Prop

Type

Validation rules

Appearance::validate() (called automatically by sign_pdf) rejects:

  • more than 4 graphics
  • graphic_fraction outside 0.1..=0.9
  • watermark_opacity outside 0.0..=1.0
  • a font_size that is not finite and > 0.0
  • a line_spacing that is not finite and > 0.0
  • a border.width that is not finite and > 0.0
  • a template using a complex/RTL script (Hebrew, Arabic, the Indic block, Thai/Lao/Tibetan/Myanmar/Khmer, …) with no font set — Helvetica (WinAnsi) cannot shape those glyphs
  • RenderMode::Invisible combined with trust_icon: true or any graphics — use Appearance::invisible() instead
  • RenderMode::Watermark combined with trust_icon: true, or with zero graphics (needs exactly one background graphic)
  • RenderMode::GraphicOnly / RenderMode::GraphicAndText with zero graphics

RenderMode

Which of the text block and the graphics are drawn, and how.

Prop

Type

Layout

Where the graphic sits relative to the text block in RenderMode::GraphicAndText.

Prop

Type

Direction

Base paragraph direction for the appearance text block (Unicode bidi, UAX #9).

Prop

Type

SigField

A field shown in the signer text block, in the order listed (used with Appearance::fields). Empty values are skipped (e.g. an absent organisation).

Prop

Type

Labels

Localizable labels for the signer text block. Override any to translate — used when Appearance::fields is set.

Prop

Type

Each field also has a same-named fluent setter (Labels::default().signed_by("Hastakshar:"), …).

Std14

A PDF standard-14 (built-in, non-embedded) text font — the three Adobe base families in their four styles. Renders in every PDF viewer without embedding a font program, but covers only WinAnsi (Latin-1). For Unicode text set an embedded Appearance::font instead, which overrides this choice.

Prop

Type

Default: Std14::Helvetica (the classic signer-block font).

Border

A border stroked around the signature box (drawn inside the signed appearance, so it renders in every viewer).

Prop

Type

Prop

Type

Attach with Appearance::border(Border::solid([0.0, 0.0, 0.0], 0.75)).

FontSource

Where the Unicode appearance font comes from. Constructed via Appearance::font (bytes) or Appearance::font_path (path); not built directly.

Prop

Type

FontSource::read(&self) -> Result<Vec<u8>> resolves to the font bytes, reading the file for Path. Its Debug impl never prints the raw bytes — only the kind and length/path.

Image

A raster image to embed in a signature appearance (logo, handwritten signature, …). Image is #[non_exhaustive].

Prop

Type

Appearance::new()
    .mode(RenderMode::GraphicAndText)
    .graphic(Image::Path("logo.png".into())); // format auto-detected at sign time

Next

On this page