Table of Contents

Class OdfParagraph

Namespace
OdfKit.Text
Assembly
OdfKit.dll

Represents a paragraph in a text document. 表示文字文件中的段落。

public class OdfParagraph
Inheritance
OdfParagraph
Derived
Inherited Members

Fields

Doc

The owning text document. 取得所屬的文字文件。

protected readonly TextDocument Doc

Field Value

TextDocument

Properties

FontName

Gets or sets the paragraph's Western font name. 取得或設定段落的西文字型名稱。

public string? FontName { get; set; }

Property Value

string

FontNameAsian

Gets or sets the paragraph's East Asian (CJK) font name. 取得或設定段落的東亞(中日韓)字型名稱。

public string? FontNameAsian { get; set; }

Property Value

string

FontNameComplex

Gets or sets the paragraph's complex script font name. 取得或設定段落的複雜文字字型名稱。

public string? FontNameComplex { get; set; }

Property Value

string

FontSize

Gets or sets the paragraph's Western font size. 取得或設定段落的西文字型大小。

public string? FontSize { get; set; }

Property Value

string

FontSizeAsian

Gets or sets the paragraph's East Asian (CJK) font size. 取得或設定段落的東亞(中日韓)字型大小。

public string? FontSizeAsian { get; set; }

Property Value

string

FontSizeComplex

Gets or sets the paragraph's complex script font size. 取得或設定段落的複雜文字字型大小。

public string? FontSizeComplex { get; set; }

Property Value

string

HorizontalAlignment

Gets or sets the paragraph's horizontal alignment. 取得或設定段落的水平對齊方式。

public string? HorizontalAlignment { get; set; }

Property Value

string

Runs

Gets all text runs of this paragraph. Accessing it automatically wraps direct child text nodes in span nodes. 取得此段落的所有文字片段(Runs)。存取時會自動將直屬的文字節點分裂包裝為 span 節點。

public IEnumerable<OdfTextRun> Runs { get; }

Property Value

IEnumerable<OdfTextRun>

Style

Gets the high-level style configuration proxy facade for this paragraph. 取得此段落的高階樣式設定代理 Facade。

public OdfParagraphStyleProxy Style { get; }

Property Value

OdfParagraphStyleProxy

StyleName

Gets or sets the paragraph's style name. 取得或設定段落的樣式名稱。

public string? StyleName { get; set; }

Property Value

string

TextContent

Gets or sets the paragraph's text content. 取得或設定段落的文字內容。

public string TextContent { get; set; }

Property Value

string

TextIndent

Gets or sets the paragraph's first-line indent (maps to the fo:text-indent attribute). 取得或設定段落首行縮排(對應 fo:text-indent 屬性)。

public string? TextIndent { get; set; }

Property Value

string

WritingMode

Gets or sets the paragraph's writing mode. 取得或設定段落的書寫模式。

public OdfWritingMode WritingMode { get; set; }

Property Value

OdfWritingMode

Methods

AddAlphabeticalIndexMark(string)

Short overload of AddAlphabeticalIndexMark that accepts stringValue; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stringValue;其餘可選參數使用預設值並轉呼叫最長 AddAlphabeticalIndexMark 多載。

public OdfAlphabeticalIndexMark AddAlphabeticalIndexMark(string stringValue)

Parameters

stringValue string

Returns

OdfAlphabeticalIndexMark

AddAlphabeticalIndexMark(string, string?)

Short overload of AddAlphabeticalIndexMark that accepts stringValue and key1; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stringValue 與 key1;其餘可選參數使用預設值並轉呼叫最長 AddAlphabeticalIndexMark 多載。

public OdfAlphabeticalIndexMark AddAlphabeticalIndexMark(string stringValue, string? key1)

Parameters

stringValue string
key1 string

Returns

OdfAlphabeticalIndexMark

AddAlphabeticalIndexMark(string, string?, string?)

Adds an alphabetical index mark in the paragraph. 在段落中新增字母索引標記。

public OdfAlphabeticalIndexMark AddAlphabeticalIndexMark(string stringValue, string? key1, string? key2)

Parameters

stringValue string

The index string value. / 索引字串值。

key1 string

The primary key. / 主要鍵值。

key2 string

The secondary key. / 次要鍵值。

Returns

OdfAlphabeticalIndexMark

AddAuthorField()

Adds an author name field in the paragraph. 在段落中新增作者名稱欄位。

public void AddAuthorField()

AddBibliographyMark(string, string, string, string, string)

Adds a bibliography mark in the paragraph. 在段落中新增文獻標記。

public OdfBibliographyMark AddBibliographyMark(string identifier, string bibliographyType, string author, string title, string year)

Parameters

identifier string

The bibliography mark identifier. / 文獻標記識別碼。

bibliographyType string

The bibliography type. / 文獻類型。

author string

The bibliography author. / 文獻作者。

title string

The bibliography title. / 文獻標題。

year string

The publication year. / 出版年份。

Returns

OdfBibliographyMark

AddBookmark(string)

Adds a bookmark in the paragraph. 在段落中新增書籤。

public void AddBookmark(string name)

Parameters

name string

The bookmark name. / 書籤名稱。

AddBookmarkReferenceField(string)

Short overload of AddBookmarkReferenceField that accepts bookmarkName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 bookmarkName;其餘可選參數使用預設值並轉呼叫最長 AddBookmarkReferenceField 多載。

public void AddBookmarkReferenceField(string bookmarkName)

Parameters

bookmarkName string

AddBookmarkReferenceField(string, string)

Adds a bookmark reference field in the paragraph. 在段落中新增書籤參照欄位。

public void AddBookmarkReferenceField(string bookmarkName, string referenceFormat)

Parameters

bookmarkName string

The bookmark name. / 書籤名稱。

referenceFormat string

The reference format; defaults to "text". / 參照格式,預設為 "text"。

AddChapterField()

Adds a chapter field in the paragraph. 在段落中新增章節欄位。

public void AddChapterField()

AddComment(OdfComment)

Adds a comment in the paragraph. 在段落中新增批注。

public void AddComment(OdfComment comment)

Parameters

comment OdfComment

The comment object. / 批注物件。

AddDatabaseDisplayField(string, string)

Short overload of AddDatabaseDisplayField that accepts tableName and columnName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 tableName 與 columnName;其餘可選參數使用預設值並轉呼叫最長 AddDatabaseDisplayField 多載。

public void AddDatabaseDisplayField(string tableName, string columnName)

Parameters

tableName string
columnName string

AddDatabaseDisplayField(string, string, string?)

Short overload of AddDatabaseDisplayField that accepts tableName, columnName, and tableType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 tableName、columnName 與 tableType;其餘可選參數使用預設值並轉呼叫最長 AddDatabaseDisplayField 多載。

public void AddDatabaseDisplayField(string tableName, string columnName, string? tableType)

Parameters

tableName string
columnName string
tableType string

AddDatabaseDisplayField(string, string, string?, string?)

Adds a database field display field (text:database-display) in the paragraph, used for mail merge or report content bound to a table column. 在段落中新增資料庫欄位顯示欄位(text:database-display),用於合併列印或報表內容綁定資料表欄位。

public void AddDatabaseDisplayField(string tableName, string columnName, string? tableType, string? databaseName)

Parameters

tableName string

The table, query, or command name. / 資料表、查詢或指令名稱。

columnName string

The column name to display. / 要顯示的欄位名稱。

tableType string

The data source type, either "table", "query", or "command". / 資料來源類型,可為 "table"、"query" 或 "command"。

databaseName string

The database connection name. / 資料庫連線名稱。

AddDatabaseNextField(string)

Short overload of AddDatabaseNextField that accepts tableName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 tableName;其餘可選參數使用預設值並轉呼叫最長 AddDatabaseNextField 多載。

public void AddDatabaseNextField(string tableName)

Parameters

tableName string

AddDatabaseNextField(string, string?)

Short overload of AddDatabaseNextField that accepts tableName and tableType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 tableName 與 tableType;其餘可選參數使用預設值並轉呼叫最長 AddDatabaseNextField 多載。

public void AddDatabaseNextField(string tableName, string? tableType)

Parameters

tableName string
tableType string

AddDatabaseNextField(string, string?, string?)

Short overload of AddDatabaseNextField that accepts tableName, tableType, and databaseName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 tableName、tableType 與 databaseName;其餘可選參數使用預設值並轉呼叫最長 AddDatabaseNextField 多載。

public void AddDatabaseNextField(string tableName, string? tableType, string? databaseName)

Parameters

tableName string
tableType string
databaseName string

AddDatabaseNextField(string, string?, string?, string?)

Adds a database next record field (text:database-next) in the paragraph, used for advancing records in mail merge or reports. 在段落中新增資料庫下一筆記錄欄位(text:database-next),用於合併列印或報表的逐筆換行。

public void AddDatabaseNextField(string tableName, string? tableType, string? databaseName, string? condition)

Parameters

tableName string

The table, query, or command name. / 資料表、查詢或指令名稱。

tableType string

The data source type, either "table", "query", or "command". / 資料來源類型,可為 "table"、"query" 或 "command"。

databaseName string

The database connection name. / 資料庫連線名稱。

condition string

The condition expression evaluated before advancing. / 換行前的判斷條件式。

AddDateField()

Adds a date field in the paragraph. 在段落中新增日期欄位。

public void AddDateField()

AddEndnote(string, string)

Inserts an endnote in the paragraph. 在段落中插入尾注。

public void AddEndnote(string citation, string bodyText)

Parameters

citation string

The endnote citation marker. / 尾注引用標記。

bodyText string

The endnote body content. / 尾注本文內容。

AddFloatingTextBox(OdfLength, OdfLength, OdfLength, OdfLength)

Short overload of AddFloatingTextBox that accepts x, y, width, and height; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 x、y、width 與 height;其餘可選參數使用預設值並轉呼叫最長 AddFloatingTextBox 多載。

public OdfFloatingTextBox AddFloatingTextBox(OdfLength x, OdfLength y, OdfLength width, OdfLength height)

Parameters

x OdfLength
y OdfLength
width OdfLength
height OdfLength

Returns

OdfFloatingTextBox

AddFloatingTextBox(OdfLength, OdfLength, OdfLength, OdfLength, OdfAnchorType)

Short overload of AddFloatingTextBox that accepts x, y, width, height, and anchorType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 x、y、width、height 與 anchorType;其餘可選參數使用預設值並轉呼叫最長 AddFloatingTextBox 多載。

public OdfFloatingTextBox AddFloatingTextBox(OdfLength x, OdfLength y, OdfLength width, OdfLength height, OdfAnchorType anchorType)

Parameters

x OdfLength
y OdfLength
width OdfLength
height OdfLength
anchorType OdfAnchorType

Returns

OdfFloatingTextBox

AddFloatingTextBox(OdfLength, OdfLength, OdfLength, OdfLength, OdfAnchorType, OdfTextWrap)

Adds a floating text box in the paragraph. 在段落中新增浮動文字框。

public OdfFloatingTextBox AddFloatingTextBox(OdfLength x, OdfLength y, OdfLength width, OdfLength height, OdfAnchorType anchorType, OdfTextWrap wrap)

Parameters

x OdfLength

The X-axis position. / X 軸座標位置。

y OdfLength

The Y-axis position. / Y 軸座標位置。

width OdfLength

The text box width. / 文字框寬度。

height OdfLength

The text box height. / 文字框高度。

anchorType OdfAnchorType

The anchor type. / 錨定類型。

wrap OdfTextWrap

The text wrap mode. / 文字環繞方式。

Returns

OdfFloatingTextBox

The newly created floating text box. / 新建立的浮動文字框。

AddFootnote(string, string)

Inserts a footnote in the paragraph. 在段落中插入腳注。

public void AddFootnote(string citation, string bodyText)

Parameters

citation string

The footnote citation marker. / 腳注引用標記。

bodyText string

The footnote body content. / 腳注本文內容。

AddFormula(string)

Adds a formula object (MathML) in the paragraph. 在段落中新增公式物件(MathML)。

public void AddFormula(string mathMlXmlString)

Parameters

mathMlXmlString string

The MathML XML string. / MathML XML 字串。

AddHtmlFragment(string)

Parses and adds an HTML fragment in the paragraph. 在段落中解析並新增 HTML 片段。

public void AddHtmlFragment(string html)

Parameters

html string

The HTML fragment string. / HTML 字串片段。

Adds a hyperlink in the paragraph. 在段落中新增超連結。

public void AddHyperlink(string url, string text)

Parameters

url string

The target URL. / 目標 URL。

text string

The display text. / 顯示文字。

AddImage(string, OdfLength, OdfLength)

Short overload of AddImage that accepts packagePath, width, and height; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 packagePath、width 與 height;其餘可選參數使用預設值並轉呼叫最長 AddImage 多載。

public OdfImage AddImage(string packagePath, OdfLength width, OdfLength height)

Parameters

packagePath string
width OdfLength
height OdfLength

Returns

OdfImage

AddImage(string, OdfLength, OdfLength, string?)

Adds an image in the paragraph. 在段落中新增圖片。

public OdfImage AddImage(string packagePath, OdfLength width, OdfLength height, string? name)

Parameters

packagePath string

The image's path within the package. / 圖片在封裝包內的路徑。

width OdfLength

The image width. / 圖片寬度。

height OdfLength

The image height. / 圖片高度。

name string

The image name. / 圖片名稱。

Returns

OdfImage

AddLineBreak()

Adds a line break in the paragraph. 在段落中新增換行符號。

public void AddLineBreak()

AddPageCountField()

Adds a page count field in the paragraph. 在段落中新增總頁數欄位。

public void AddPageCountField()

AddPageNumberField()

Adds a page number field in the paragraph. 在段落中新增頁碼欄位。

public void AddPageNumberField()

AddReferenceField(string)

Adds a reference entry field in the paragraph. 在段落中新增參考專案欄位。

public void AddReferenceField(string refName)

Parameters

refName string

The reference entry name. / 參考專案名稱。

AddReferenceMark(string)

Adds a reference mark in the paragraph. 在段落中新增參考標記。

public void AddReferenceMark(string name)

Parameters

name string

The reference mark name. / 參考標記名稱。

AddRuby(string, string)

Adds a ruby (phonetic) annotation in the paragraph. 在段落中新增旁註標記(注音)。

public OdfRuby AddRuby(string baseText, string rubyText)

Parameters

baseText string

The base text. / 基礎文字。

rubyText string

The ruby (phonetic) text. / 注音文字。

Returns

OdfRuby

AddSequenceField(string)

Short overload of AddSequenceField that accepts name; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name;其餘可選參數使用預設值並轉呼叫最長 AddSequenceField 多載。

public void AddSequenceField(string name)

Parameters

name string

AddSequenceField(string, string)

Adds a sequence number field in the paragraph. 在段落中新增序號欄位。

public void AddSequenceField(string name, string numFormat)

Parameters

name string

The sequence field name. / 序號欄位名稱。

numFormat string

The number format. / 編號格式。

AddSequenceRefField(string)

Short overload of AddSequenceRefField that accepts sequenceName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sequenceName;其餘可選參數使用預設值並轉呼叫最長 AddSequenceRefField 多載。

public void AddSequenceRefField(string sequenceName)

Parameters

sequenceName string

AddSequenceRefField(string, string)

Adds a sequence cross-reference field in the paragraph. 在段落中新增序號交互參照欄位。

public void AddSequenceRefField(string sequenceName, string referenceFormat)

Parameters

sequenceName string

The sequence field name. / 序號欄位名稱。

referenceFormat string

The reference format; defaults to "value". / 參照格式,預設為 "value"。

AddSoftPageBreak()

Adds a soft page break in the paragraph. 在段落中新增軟分頁符號。

public void AddSoftPageBreak()

AddSpace()

Short overload of AddSpace that uses default values for all optional parameters and forwards to the full overload. 便利多載:AddSpace 的所有可選參數使用預設值並轉呼叫最長多載。

public void AddSpace()

AddSpace(int)

Adds the specified number of space entries in the paragraph. 在段落中新增指定數量的空格專案。

public void AddSpace(int count)

Parameters

count int

The number of spaces. / 空格數量。

AddTab()

Adds a tab character in the paragraph. 在段落中新增定位點(Tab)字元。

public void AddTab()

AddText(string, OdfTextFontFallbackOptions)

Adds text using the specified font fallback options. 使用指定的字型遞補選項新增文字。

public IReadOnlyList<OdfTextRun> AddText(string text, OdfTextFontFallbackOptions options)

Parameters

text string

The text content to add. / 要新增的文字內容。

options OdfTextFontFallbackOptions

The font fallback options. / 字型遞補選項。

Returns

IReadOnlyList<OdfTextRun>

The collection of added text runs. / 新增的文字片段集合。

AddTextRun(string)

Adds a text run at the end of the paragraph. 在段落結尾新增一個文字片段。

public OdfTextRun AddTextRun(string text)

Parameters

text string

The text content to add. / 要新增的文字內容。

Returns

OdfTextRun

The created text run object. / 建立的文字片段物件。

AddTimeField()

Adds a time field in the paragraph. 在段落中新增時間欄位。

public void AddTimeField()

AddVariableGetField(string)

Gets a variable field value in the paragraph. 在段落中取得變數欄位值。

public void AddVariableGetField(string name)

Parameters

name string

The variable name. / 變數名稱。

AddVariableSetField(string, string)

Sets a variable field value in the paragraph. 在段落中設定變數欄位值。

public void AddVariableSetField(string name, string value)

Parameters

name string

The variable name. / 變數名稱。

value string

The variable value. / 變數值。

AppendHtml(string)

Parses and appends an inline HTML rich-text fragment at the end of the paragraph. 在段落結尾解析並追加 HTML 行內富文字片段。

public OdfParagraph AppendHtml(string html)

Parameters

html string

The inline HTML fragment to parse. / 要解析的 HTML 行內片段。

Returns

OdfParagraph

The current paragraph, for chained calls. / 目前段落,方便鏈式呼叫。

AppendList()

Short overload of AppendList that uses default values for all optional parameters and forwards to the full overload. 便利多載:AppendList 的所有可選參數使用預設值並轉呼叫最長多載。

public OdfListBuilder AppendList()

Returns

OdfListBuilder

AppendList(string?)

Appends a list builder within the paragraph. 在段落內追加一個清單建構器。

public OdfListBuilder AppendList(string? styleName)

Parameters

styleName string

The optional list style name. / 選用的清單樣式名稱。

Returns

OdfListBuilder

The list builder. / 清單建構器。

AppendMarkdown(string)

Parses and appends an inline Markdown rich-text fragment at the end of the paragraph. 在段落結尾解析並追加 Markdown 行內富文字片段。

public OdfParagraph AppendMarkdown(string markdown)

Parameters

markdown string

The inline Markdown text to parse. / 要解析的 Markdown 行內文字。

Returns

OdfParagraph

The current paragraph, for chained calls. / 目前段落,方便鏈式呼叫。

AppendText()

Gets the paragraph's inline rich-text builder, supporting chained style configuration. 取得段落的行內富文本建構器,支援鏈式樣式設定。

public InlineTextBuilder AppendText()

Returns

InlineTextBuilder

The inline rich-text builder. / 行內富文本建構器。

BreakPageBefore()

Short overload of BreakPageBefore that uses default values for all optional parameters and forwards to the full overload. 便利多載:BreakPageBefore 的所有可選參數使用預設值並轉呼叫最長多載。

public void BreakPageBefore()

BreakPageBefore(string?)

Short overload of BreakPageBefore that accepts masterPageName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 masterPageName;其餘可選參數使用預設值並轉呼叫最長 BreakPageBefore 多載。

public void BreakPageBefore(string? masterPageName)

Parameters

masterPageName string

BreakPageBefore(string?, int?)

Inserts a page break before this paragraph, optionally switching the page style. 在此段落前插入分頁符號,並可選擇性地切換頁面樣式。

public void BreakPageBefore(string? masterPageName, int? pageNumber)

Parameters

masterPageName string

The master page style name to switch to; null means only inserting the page break. / 要切換的主頁面樣式名稱;null 表示只插入分頁。

pageNumber int?

The new starting page number; null means continuing. / 新頁碼起始值;null 表示繼續。

ClearRuns()

Removes all text runs within this paragraph (removes all span nodes). 清除此段落內的所有文字片段(移除所有的 span 節點)。

public void ClearRuns()

Delete()

Deletes this paragraph. 刪除此段落。

public void Delete()

EnableAutoNumbering(string)

Enables automatic numbering style for this outline paragraph. 啟用此大綱段落的自動編號樣式。

public OdfParagraph EnableAutoNumbering(string styleName)

Parameters

styleName string

The list style name to use or create. / 要使用或建立的清單樣式名稱。

Returns

OdfParagraph

The current paragraph, for chained calls. / 目前段落,供鏈式呼叫使用。

ReplaceText(string, string)

Searches this paragraph for the specified text and replaces it with new text, while preserving the original style structure of unmatched segments. 在此段落內搜尋指定文字並替換為新文字,同時保留未命中區段的原始樣式結構。

public void ReplaceText(string search, string replacement)

Parameters

search string

The keyword to search for. / 要搜尋的關鍵字。

replacement string

The replacement text. / 要替換的新文字。

SetFont(string)

Short overload of SetFont that accepts westernFont; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 westernFont;其餘可選參數使用預設值並轉呼叫最長 SetFont 多載。

public void SetFont(string westernFont)

Parameters

westernFont string

SetFont(string, string?)

Short overload of SetFont that accepts westernFont and asianFont; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 westernFont 與 asianFont;其餘可選參數使用預設值並轉呼叫最長 SetFont 多載。

public void SetFont(string westernFont, string? asianFont)

Parameters

westernFont string
asianFont string

SetFont(string, string?, string?)

Sets the paragraph's font names. 設定段落的字型名稱。

public void SetFont(string westernFont, string? asianFont, string? complexFont)

Parameters

westernFont string

The Western font name. / 西文字型名稱。

asianFont string

The East Asian (CJK) font name. / 東亞(中日韓)字型名稱。

complexFont string

The complex script font name. / 複雜文字字型名稱。

SetFontSize(string)

Short overload of SetFontSize that accepts westernSize; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 westernSize;其餘可選參數使用預設值並轉呼叫最長 SetFontSize 多載。

public void SetFontSize(string westernSize)

Parameters

westernSize string

SetFontSize(string, string?)

Short overload of SetFontSize that accepts westernSize and asianSize; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 westernSize 與 asianSize;其餘可選參數使用預設值並轉呼叫最長 SetFontSize 多載。

public void SetFontSize(string westernSize, string? asianSize)

Parameters

westernSize string
asianSize string

SetFontSize(string, string?, string?)

Sets the paragraph's font sizes. 設定段落的字型大小。

public void SetFontSize(string westernSize, string? asianSize, string? complexSize)

Parameters

westernSize string

The Western font size. / 西文字型大小。

asianSize string

The East Asian font size. / 東亞字型大小。

complexSize string

The complex script font size. / 複雜文字字型大小。

SetOutlineLevel(int)

Sets this paragraph to the specified outline level. 將此段落設定為指定的大綱階層。

public OdfParagraph SetOutlineLevel(int outlineLevel)

Parameters

outlineLevel int

The outline level, with a minimum value of 1. / 大綱階層,最小值為 1。

Returns

OdfParagraph

The current paragraph, for chained calls. / 目前段落,供鏈式呼叫使用。