Interface PdfForm


public interface PdfForm
PDF Interactive Form (AcroForm) PDF 交互表单

Represents the interactive form in a PDF document.

表示 PDF 文档中的交互表单。

Features | 主要功能:

  • Field access by name and type - 按名称和类型访问字段
  • Batch field value setting - 批量设置字段值
  • Form flattening (making non-editable) - 表单扁平化(使其不可编辑)
  • Appearance generation - 外观生成

Usage Examples | 使用示例:

PdfForm form = document.getForm();
form.setFieldValues(Map.of("name", "John", "age", "30"));
form.flatten();

Security | 安全性:

  • Thread-safe: Depends on implementation - 线程安全: 取决于实现
  • Null-safe: Depends on implementation - 空值安全: 取决于实现
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • getFieldNames

      Set<String> getFieldNames()
      Gets all field names 获取所有字段名
      Returns:
      set of field names | 字段名集合
    • getField

      FormField getField(String name)
      Gets a field by name 根据名称获取字段
      Parameters:
      name - field name | 字段名
      Returns:
      form field, or null if not found | 表单字段,如果未找到则返回 null
    • getFields

      List<FormField> getFields()
      Gets all fields 获取所有字段
      Returns:
      list of fields | 字段列表
    • getFields

      <T extends FormField> List<T> getFields(Class<T> fieldType)
      Gets fields by type 根据类型获取字段
      Type Parameters:
      T - field type | 字段类型
      Parameters:
      fieldType - field type class | 字段类型类
      Returns:
      list of matching fields | 匹配的字段列表
    • setFieldValue

      void setFieldValue(String name, String value)
      Sets field value 设置字段值
      Parameters:
      name - field name | 字段名
      value - field value | 字段值
    • setFieldValues

      void setFieldValues(Map<String,String> values)
      Sets multiple field values 设置多个字段值
      Parameters:
      values - field name to value mapping | 字段名到值的映射
    • getFieldValue

      String getFieldValue(String name)
      Gets field value 获取字段值
      Parameters:
      name - field name | 字段名
      Returns:
      field value | 字段值
    • getFieldValues

      Map<String,String> getFieldValues()
      Gets all field values 获取所有字段值
      Returns:
      field name to value mapping | 字段名到值的映射
    • flatten

      void flatten()
      Flattens the form (makes fields non-editable) 扁平化表单(使字段不可编辑)
    • flatten

      void flatten(String... fieldNames)
      Flattens specific fields 扁平化指定字段
      Parameters:
      fieldNames - fields to flatten | 要扁平化的字段
    • clearValues

      void clearValues()
      Clears all field values 清除所有字段值
    • needsAppearances

      boolean needsAppearances()
      Checks if form needs appearances 检查表单是否需要外观
      Returns:
      true if needs appearances | 如果需要外观返回 true
    • generateAppearances

      void generateAppearances()
      Generates field appearances 生成字段外观