Class Paragraph

java.lang.Object
io.leandev.appfuse.document.Paragraph

public class Paragraph extends Object

段落

封裝底層 POI 的 XWPFParagraph,提供文字、樣式、對齊、縮排,以及 run 與圖片、頁碼欄位的編輯。

Since:
4.0.0
  • Method Details

    • text

      public String text()
      取得段落文字
      Returns:
      文字
    • setText

      public void setText(String text)
      設定段落文字(清除原 run,置入單一 run)
      Parameters:
      text - 文字
    • setText

      public void setText(String text, String styleName)
      設定段落文字並套用樣板樣式
      Parameters:
      text - 文字
      styleName - 樣式名稱(樣板定義的 style ID)
    • setStyle

      public void setStyle(String styleName)
      套用樣板樣式
      Parameters:
      styleName - 樣式名稱(樣板定義的 style ID)
    • setAlignment

      public void setAlignment(Alignment alignment)
      設定水平對齊
      Parameters:
      alignment - 對齊方式
    • setIndent

      public void setIndent(Length indent)
      設定左縮排
      Parameters:
      indent - 縮排長度
    • setSpacingAfter

      public void setSpacingAfter(Length spacing)
      設定段後間距
      Parameters:
      spacing - 間距長度
    • replaceText

      public void replaceText(String target, String replacement)
      跨 run 安全的文字取代(保留首個 run 的格式)
      Parameters:
      target - 目標字串
      replacement - 取代字串
    • replaceWithHtml

      public void replaceWithHtml(String html)
      以渲染後的 HTML 子集取代此段落(占位段落 → 富文本)
      Parameters:
      html - appfuse-web RichTextEditor 輸出的 HTML 字串
    • runs

      public List<Run> runs()
      取得所有 run
      Returns:
      run 列表
    • addRun

      public Run addRun(String text)
      在段尾新增一個 run
      Parameters:
      text - 文字
      Returns:
      新 run
    • addPageNumber

      public void addPageNumber()
      插入頁碼欄位