Class SignatureAppearance
java.lang.Object
cloud.opencode.base.pdf.signature.SignatureAppearance
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 Summary
Modifier and TypeMethodDescriptionbackgroundColor(Color color) Sets background color.Sets border.static SignatureAppearanceCreates default appearance.description(String description) Sets description text.Sets font for text.fontSize(float size) Sets font size.floatgetFont()floatbyte[]image(byte[] imageBytes) Sets signature image from bytes.Sets signature image from file.static SignatureAppearanceCreates image-only appearance.booleanbooleanbooleanbooleanshowDate(boolean show) Shows signing date.showLocation(boolean show) Shows location.showReason(boolean show) Shows reason.showSignerName(boolean show) Shows signer name.Sets text color.static SignatureAppearancetextOnly()Creates text-only appearance.
-
Method Details
-
image
Sets signature image from file. 从文件设置签名图像。- Parameters:
imagePath- image file path | 图像文件路径- Returns:
- this appearance | 当前外观
-
image
Sets signature image from bytes. 从字节设置签名图像。- Parameters:
imageBytes- image bytes | 图像字节- Returns:
- this appearance | 当前外观
-
description
Sets description text. 设置描述文本。- Parameters:
description- description text | 描述文本- Returns:
- this appearance | 当前外观
-
font
Sets font for text. 设置文本字体。- Parameters:
font- font to use | 使用的字体- Returns:
- this appearance | 当前外观
-
fontSize
Sets font size. 设置字体大小。- Parameters:
size- font size | 字体大小- Returns:
- this appearance | 当前外观
-
textColor
Sets text color. 设置文本颜色。- Parameters:
color- text color | 文本颜色- Returns:
- this appearance | 当前外观
-
backgroundColor
Sets background color. 设置背景颜色。- Parameters:
color- background color | 背景颜色- Returns:
- this appearance | 当前外观
-
border
Sets border. 设置边框。- Parameters:
width- border width | 边框宽度color- border color | 边框颜色- Returns:
- this appearance | 当前外观
-
showSignerName
Shows signer name. 显示签名者名称。- Parameters:
show- whether to show | 是否显示- Returns:
- this appearance | 当前外观
-
showDate
Shows signing date. 显示签名日期。- Parameters:
show- whether to show | 是否显示- Returns:
- this appearance | 当前外观
-
showReason
Shows reason. 显示原因。- Parameters:
show- whether to show | 是否显示- Returns:
- this appearance | 当前外观
-
showLocation
Shows location. 显示位置。- Parameters:
show- whether to show | 是否显示- Returns:
- this appearance | 当前外观
-
getImagePath
-
getImageBytes
public byte[] getImageBytes() -
getDescription
-
getFont
-
getFontSize
public float getFontSize() -
getTextColor
-
getBackgroundColor
-
getBorderWidth
public float getBorderWidth() -
getBorderColor
-
isShowSignerName
public boolean isShowSignerName() -
isShowDate
public boolean isShowDate() -
isShowReason
public boolean isShowReason() -
isShowLocation
public boolean isShowLocation() -
defaultAppearance
Creates default appearance. 创建默认外观。- Returns:
- default appearance | 默认外观
-
imageOnly
Creates image-only appearance. 创建仅图像外观。- Parameters:
imagePath- image file path | 图像文件路径- Returns:
- image appearance | 图像外观
-
textOnly
Creates text-only appearance. 创建仅文本外观。- Returns:
- text appearance | 文本外观
-