Class PdfFooter

java.lang.Object
cloud.opencode.base.pdf.document.PdfFooter

public final class PdfFooter extends Object
PDF Footer - Page footer configuration for PDF documents PDF 页脚 - PDF 文档的页脚配置

Configures the footer area that appears at the bottom of each page in a PDF document. Supports left, center, and right aligned text with page number placeholders.

配置 PDF 文档中每页底部显示的页脚区域。 支持左、中、右对齐文本,以及页码占位符。

Features | 主要功能:

  • Three-column layout (left, center, right) - 三列布局(左、中、右)
  • Page number placeholders: {page} and {total} - 页码占位符: {page} 和 {total}
  • Optional separator line above footer - 可选的页脚分隔线
  • Configurable font, size, and color - 可配置字体、字号和颜色

Usage Examples | 使用示例:

// Simple centered footer with page numbers
PdfFooter footer = PdfFooter.of("Page {page} of {total}");

// Custom footer
PdfFooter footer = PdfFooter.builder()
    .left("Confidential")
    .center("Page {page}/{total}")
    .right("2026-04-04")
    .fontSize(8f)
    .showLine(true);

Security | 安全性:

  • Thread-safe: No — mutable builder pattern - 线程安全: 否 — 可变构建器模式
  • Null-safe: text fields may be null (not rendered) - 空值安全: 文本字段可为 null(不渲染)
Since:
JDK 25, opencode-base-pdf V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      public static PdfFooter of(String centerText)
      Creates a footer with centered text 创建居中文本的页脚
      Parameters:
      centerText - center text | 居中文本
      Returns:
      PdfFooter instance | PdfFooter 实例
    • builder

      public static PdfFooter builder()
      Creates an empty footer builder 创建空的页脚构建器
      Returns:
      PdfFooter builder | PdfFooter 构建器
    • left

      public PdfFooter left(String text)
      Sets left-aligned text 设置左对齐文本
      Parameters:
      text - left text (supports {page} and {total} placeholders) | 左侧文本(支持 {page} 和 {total} 占位符)
      Returns:
      this footer | 当前页脚
    • center

      public PdfFooter center(String text)
      Sets center-aligned text 设置居中文本
      Parameters:
      text - center text (supports {page} and {total} placeholders) | 居中文本(支持 {page} 和 {total} 占位符)
      Returns:
      this footer | 当前页脚
    • right

      public PdfFooter right(String text)
      Sets right-aligned text 设置右对齐文本
      Parameters:
      text - right text (supports {page} and {total} placeholders) | 右侧文本(支持 {page} 和 {total} 占位符)
      Returns:
      this footer | 当前页脚
    • fontSize

      public PdfFooter fontSize(float size)
      Sets font size 设置字号
      Parameters:
      size - font size in points | 字号(磅)
      Returns:
      this footer | 当前页脚
      Throws:
      IllegalArgumentException - if size is not positive | 当字号不为正数时
    • color

      public PdfFooter color(PdfColor color)
      Sets text color 设置文本颜色
      Parameters:
      color - text color | 文本颜色
      Returns:
      this footer | 当前页脚
      Throws:
      NullPointerException - if color is null | 当 color 为 null 时
    • font

      public PdfFooter font(PdfFont font)
      Sets font 设置字体
      Parameters:
      font - font to use (null for default) | 使用的字体(null 表示默认)
      Returns:
      this footer | 当前页脚
    • showLine

      public PdfFooter showLine(boolean show)
      Sets whether to show separator line above footer 设置是否显示页脚上方分隔线
      Parameters:
      show - true to show line | true 表示显示分隔线
      Returns:
      this footer | 当前页脚
    • getLeft

      public String getLeft()
      Gets left-aligned text 获取左对齐文本
      Returns:
      left text | 左侧文本
    • getCenter

      public String getCenter()
      Gets center-aligned text 获取居中文本
      Returns:
      center text | 居中文本
    • getRight

      public String getRight()
      Gets right-aligned text 获取右对齐文本
      Returns:
      right text | 右侧文本
    • getFontSize

      public float getFontSize()
      Gets font size 获取字号
      Returns:
      font size in points | 字号
    • getColor

      public PdfColor getColor()
      Gets text color 获取文本颜色
      Returns:
      text color | 文本颜色
    • getFont

      public PdfFont getFont()
      Gets font 获取字体
      Returns:
      font, or null for default | 字体,null 表示默认
    • isShowLine

      public boolean isShowLine()
      Checks if separator line is shown 检查是否显示分隔线
      Returns:
      true if line is shown | 如果显示分隔线返回 true
    • toString

      public String toString()
      Overrides:
      toString in class Object