Class SignatureAppearance

java.lang.Object
cloud.opencode.base.pdf.signature.SignatureAppearance

public final class SignatureAppearance extends Object
Signature Appearance Builder 签名外观构建器

Configures the visual appearance of a PDF signature.

配置 PDF 签名的可视外观。

Features | 主要功能:

  • Signature image from file or bytes - 从文件或字节设置签名图像
  • Text description and font configuration - 文本描述和字体配置
  • Visibility toggles for name, date, reason, location - 名称、日期、原因、位置的可见性切换
  • Background and border styling - 背景和边框样式

Usage Examples | 使用示例:

SignatureAppearance appearance = SignatureAppearance.defaultAppearance()
    .image(Path.of("signature.png"))
    .showReason(true)
    .showLocation(true)
    .fontSize(10);

Security | 安全性:

  • Thread-safe: No — mutable builder pattern - 线程安全: 否 — 可变构建器模式
  • Null-safe: Yes — parameters are validated where critical - 空值安全: 是 — 关键参数已验证
  • Defensive copies: Image byte arrays are cloned on input and output - 防御性拷贝: 图像字节数组在输入和输出时进行克隆
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • image

      public SignatureAppearance image(Path imagePath)
      Sets signature image from file. 从文件设置签名图像。
      Parameters:
      imagePath - image file path | 图像文件路径
      Returns:
      this appearance | 当前外观
    • image

      public SignatureAppearance image(byte[] imageBytes)
      Sets signature image from bytes. 从字节设置签名图像。
      Parameters:
      imageBytes - image bytes | 图像字节
      Returns:
      this appearance | 当前外观
    • description

      public SignatureAppearance description(String description)
      Sets description text. 设置描述文本。
      Parameters:
      description - description text | 描述文本
      Returns:
      this appearance | 当前外观
    • font

      public SignatureAppearance font(PdfFont font)
      Sets font for text. 设置文本字体。
      Parameters:
      font - font to use | 使用的字体
      Returns:
      this appearance | 当前外观
    • fontSize

      public SignatureAppearance fontSize(float size)
      Sets font size. 设置字体大小。
      Parameters:
      size - font size | 字体大小
      Returns:
      this appearance | 当前外观
    • textColor

      public SignatureAppearance textColor(PdfColor color)
      Sets text color. 设置文本颜色。
      Parameters:
      color - text color | 文本颜色
      Returns:
      this appearance | 当前外观
    • backgroundColor

      public SignatureAppearance backgroundColor(PdfColor color)
      Sets background color. 设置背景颜色。
      Parameters:
      color - background color | 背景颜色
      Returns:
      this appearance | 当前外观
    • border

      public SignatureAppearance border(float width, PdfColor color)
      Sets border. 设置边框。
      Parameters:
      width - border width | 边框宽度
      color - border color | 边框颜色
      Returns:
      this appearance | 当前外观
    • showSignerName

      public SignatureAppearance showSignerName(boolean show)
      Shows signer name. 显示签名者名称。
      Parameters:
      show - whether to show | 是否显示
      Returns:
      this appearance | 当前外观
    • showDate

      public SignatureAppearance showDate(boolean show)
      Shows signing date. 显示签名日期。
      Parameters:
      show - whether to show | 是否显示
      Returns:
      this appearance | 当前外观
    • showReason

      public SignatureAppearance showReason(boolean show)
      Shows reason. 显示原因。
      Parameters:
      show - whether to show | 是否显示
      Returns:
      this appearance | 当前外观
    • showLocation

      public SignatureAppearance showLocation(boolean show)
      Shows location. 显示位置。
      Parameters:
      show - whether to show | 是否显示
      Returns:
      this appearance | 当前外观
    • getImagePath

      public Path getImagePath()
    • getImageBytes

      public byte[] getImageBytes()
    • getDescription

      public String getDescription()
    • getFont

      public PdfFont getFont()
    • getFontSize

      public float getFontSize()
    • getTextColor

      public PdfColor getTextColor()
    • getBackgroundColor

      public PdfColor getBackgroundColor()
    • getBorderWidth

      public float getBorderWidth()
    • getBorderColor

      public PdfColor getBorderColor()
    • isShowSignerName

      public boolean isShowSignerName()
    • isShowDate

      public boolean isShowDate()
    • isShowReason

      public boolean isShowReason()
    • isShowLocation

      public boolean isShowLocation()
    • defaultAppearance

      public static SignatureAppearance defaultAppearance()
      Creates default appearance. 创建默认外观。
      Returns:
      default appearance | 默认外观
    • imageOnly

      public static SignatureAppearance imageOnly(Path imagePath)
      Creates image-only appearance. 创建仅图像外观。
      Parameters:
      imagePath - image file path | 图像文件路径
      Returns:
      image appearance | 图像外观
    • textOnly

      public static SignatureAppearance textOnly()
      Creates text-only appearance. 创建仅文本外观。
      Returns:
      text appearance | 文本外观