Class PdfCell

java.lang.Object
cloud.opencode.base.pdf.content.PdfCell

public final class PdfCell extends Object
PDF Table Cell - Single cell in a PDF table PDF 表格单元格 - PDF 表格中的单个单元格

Supports text content, alignment, colspan/rowspan, and styling.

支持文本内容、对齐、跨列/跨行和样式。

Features | 主要功能:

  • Cell content and font configuration - 单元格内容和字体配置
  • Horizontal and vertical alignment - 水平和垂直对齐
  • Colspan and rowspan support - 跨列和跨行支持
  • Border and background styling - 边框和背景样式

Usage Examples | 使用示例:

PdfCell cell = PdfCell.of("Hello")
    .fontSize(14)
    .bold(true)
    .align(Alignment.CENTER)
    .backgroundColor(PdfColor.LIGHT_GRAY);

Security | 安全性:

  • Thread-safe: No — mutable builder pattern - 线程安全: 否 — 可变构建器模式
  • Null-safe: No — callers must ensure non-null values - 空值安全: 否 — 调用方需确保非空值
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      public static PdfCell of(String content)
      Creates cell with content 创建带内容的单元格
      Parameters:
      content - cell content | 单元格内容
      Returns:
      PdfCell instance | PdfCell 实例
    • empty

      public static PdfCell empty()
      Creates empty cell 创建空单元格
      Returns:
      PdfCell instance | PdfCell 实例
    • builder

      public static PdfCell builder()
      Creates a cell builder 创建单元格构建器
      Returns:
      new PdfCell instance | 新 PdfCell 实例
    • content

      public PdfCell content(String content)
      Sets cell content 设置单元格内容
      Parameters:
      content - cell content | 单元格内容
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • font

      public PdfCell font(PdfFont font)
      Sets font 设置字体
      Parameters:
      font - font to use | 使用的字体
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • fontSize

      public PdfCell fontSize(float size)
      Sets font size 设置字体大小
      Parameters:
      size - font size | 字体大小
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • textColor

      public PdfCell textColor(PdfColor color)
      Sets text color 设置文本颜色
      Parameters:
      color - text color | 文本颜色
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • backgroundColor

      public PdfCell backgroundColor(PdfColor color)
      Sets background color 设置背景颜色
      Parameters:
      color - background color | 背景颜色
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • align

      public PdfCell align(PdfCell.Alignment alignment)
      Sets horizontal alignment 设置水平对齐
      Parameters:
      alignment - horizontal alignment | 水平对齐
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • valign

      public PdfCell valign(PdfCell.VerticalAlignment alignment)
      Sets vertical alignment 设置垂直对齐
      Parameters:
      alignment - vertical alignment | 垂直对齐
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • colspan

      public PdfCell colspan(int colspan)
      Sets colspan 设置跨列数
      Parameters:
      colspan - number of columns to span | 跨越的列数
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • rowspan

      public PdfCell rowspan(int rowspan)
      Sets rowspan 设置跨行数
      Parameters:
      rowspan - number of rows to span | 跨越的行数
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • padding

      public PdfCell padding(float padding)
      Sets padding 设置内边距
      Parameters:
      padding - padding in points | 内边距(点)
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • border

      public PdfCell border(float width, PdfColor color)
      Sets border 设置边框
      Parameters:
      width - border width | 边框宽度
      color - border color | 边框颜色
      Returns:
      this cell for chaining | 当前单元格用于链式调用
    • getContent

      public String getContent()
    • getFont

      public PdfFont getFont()
    • getFontSize

      public float getFontSize()
    • getTextColor

      public PdfColor getTextColor()
    • getBackgroundColor

      public PdfColor getBackgroundColor()
    • getHorizontalAlignment

      public PdfCell.Alignment getHorizontalAlignment()
    • getVerticalAlignment

      public PdfCell.VerticalAlignment getVerticalAlignment()
    • getColspan

      public int getColspan()
    • getRowspan

      public int getRowspan()
    • getPadding

      public float getPadding()
    • getBorderWidth

      public float getBorderWidth()
    • getBorderColor

      public PdfColor getBorderColor()