DocumentBuilder
概述
DocumentBuilder 是 Aspose.Words FOSS 中用于 .NET 的类。继承自:IRunAttrSource、IParaAttrSource、IRowAttrSource,以及另一个。
提供插入文本、图像和其他内容的方法,并指定字体、段落和章节的格式。
此类提供了 81 个用于在 .NET 程序中处理 DocumentBuilder 对象的方法。可用的方法包括:DeleteRow、DocumentBuilder、EndBookmark、EndColumnBookmark、EndEditableRange、EndRow、EndTable、InsertBreak、InsertCell、InsertChart、InsertCheckBox、InsertComboBox,以及另外 36 个方法。所有公共成员在安装了 Aspose.Words FOSS for .NET 包后,对任何 .NET 应用程序均可访问。属性:Bold、CellFormat、CurrentNode、CurrentParagraph、CurrentSection、CurrentStory,以及另外 12 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
Document | Document | 读写 | 获取或设置此对象所附加的 Document 对象。 |
Font | Font | 读取 | 返回一个表示当前字体格式属性的对象。 |
Bold | bool | 读写 | 如果字体被格式化为粗体,则为真。 |
Italic | bool | 读写 | 如果字体被格式化为斜体,则为 True. |
Underline | Underline | 读写 | 获取/设置当前字体的下划线类型。 |
ParagraphFormat | ParagraphFormat | 读取 | 返回一个表示当前段落格式属性的对象。 |
ListFormat | ListFormat | 读取 | 返回一个表示当前列表格式属性的对象。 |
PageSetup | PageSetup | 读取 | 返回一个对象,表示当前页面设置和章节属性。 |
RowFormat | RowFormat | 读取 | 返回一个对象,表示当前表格行的格式属性。 |
CellFormat | CellFormat | 读取 | 返回一个对象,表示当前表格单元格的格式属性。 |
IsAtStartOfParagraph | bool | 读取 | 如果光标位于当前段落的开头(光标前没有文本),则返回 true。 |
IsAtEndOfParagraph | bool | 读取 | 如果光标位于当前段落的末尾,则返回 true。 |
IsAtEndOfStructuredDocumentTag | bool | 读取 | 如果光标位于结构化文档标签的末尾,则返回 true。 |
CurrentNode | Node | 读取 | 获取当前在此 DocumentBuilder 中选中的节点。 |
CurrentParagraph | Paragraph | 读取 | 获取当前在此 DocumentBuilder 中选中的段落。 |
CurrentStructuredDocumentTag | StructuredDocumentTag | 读取 | 获取当前在此 DocumentBuilder 中选中的结构化文档标签。 |
CurrentStory | Story | 读取 | 获取当前在此 DocumentBuilder 中选中的故事。 |
CurrentSection | Section | 读取 | 获取当前在此 DocumentBuilder 中选中的部分。 |
方法
| 签名 | 描述 |
|---|---|
DocumentBuilder() | 初始化此类的一个新实例。 |
DocumentBuilder(options: DocumentBuilderOptions) | 初始化此类的一个新实例。 |
DocumentBuilder(doc: Document) | 初始化此类的一个新实例。 |
DocumentBuilder(doc: Document, options: DocumentBuilderOptions) | 初始化此类的一个新实例。 |
MoveToDocumentStart() | 将光标移动到文档的开头。 |
MoveToDocumentEnd() | 将光标移动到文档的末尾。 |
MoveToSection(sectionIndex: int) | 将光标移动到指定章节正文的开头。 |
MoveToHeaderFooter(headerFooterType: HeaderFooterType) | 将光标移动到当前章节页眉或页脚的开头。 |
MoveToMergeField(fieldName: string) | 将光标移动到指定的合并字段。 |
MoveToMergeField(fieldName: string, isAfter: bool, isDeleteField: bool) | 将合并字段移动到指定的合并字段。 |
MoveToField(field: Field, isAfter: bool) | 将光标移动到文档中的字段。 |
MoveToBookmark(bookmarkName: string) | 将光标移动到书签。 |
MoveToBookmark(bookmarkName: string, isStart: bool, isAfter: bool) | 将光标更精确地移动到书签。 |
MoveToParagraph(paragraphIndex: int, characterIndex: int) | 将光标移动到当前章节的段落。 |
MoveToStructuredDocumentTag(structuredDocumentTagIndex: int, characterIndex: int) | 将光标移动到当前章节的结构化文档标签。 |
MoveToStructuredDocumentTag(structuredDocumentTag: StructuredDocumentTag, characterIndex: int) | 将光标移动到结构化文档标签。 |
MoveToCell(tableIndex: int, rowIndex: int, columnIndex: int, characterIndex: int) | 将光标移动到当前章节中的表格单元格。 |
MoveTo(node: Node) | 将光标移动到内联节点或段落末尾。 |
DeleteRow(tableIndex: int, rowIndex: int) | 删除表格中的一行。 |
Write(text: string) | 在当前插入位置向文档插入字符串。 |
Writeln(text: string) | 向文档插入字符串并换段。 |
Writeln() | 在文档中插入段落换行。 |
InsertParagraph() | 在文档中插入段落换行。 |
InsertStructuredDocumentTag(type: SdtType) | 在文档中插入一个StructuredDocumentTag。 |
InsertStyleSeparator() | 在文档中插入样式分隔符。 |
InsertBreak(breakType: BreakType) | 在文档中插入指定类型的换行。 |
InsertTableOfContents(switches: string) | 在文档中插入 TOC(目录)字段。 |
InsertField(fieldType: FieldType, updateField: bool) | 在文档中插入 Word 字段。 |
InsertField(fieldCode: string) | 在文档中插入 Word 字段并更新字段结果。 |
InsertField(fieldCode: string, fieldValue: string) | 在文档中插入 Word 字段,但不更新字段结果。 |
InsertHyperlink(displayText: string, urlOrBookmark: string, isBookmark: bool) | 在文档中插入超链接。 |
InsertTextInput(name: string, type: TextFormFieldType, format: string, fieldValue: string, maxLength: int) | 在当前位置插入文本表单字段。 |
InsertCheckBox(name: string, checkedValue: bool, size: int) | 在当前位置插入一个复选框表单字段。 |
InsertCheckBox(name: string, defaultValue: bool, checkedValue: bool, size: int) | 在当前位置插入一个复选框表单字段。 |
InsertComboBox(name: string, items: string[], selectedIndex: int) | 在当前位置插入一个组合框表单字段。 |
InsertFootnote(footnoteType: FootnoteType, footnoteText: string) | 在文档中插入脚注或尾注。 |
InsertFootnote(footnoteType: FootnoteType, footnoteText: string, referenceMark: string) | 在文档中插入脚注或尾注。 |
InsertImage(image: Image) | 将图像插入文档。 |
InsertImage(fileName: string) | 从文件或 URL 插入图像到文档中。 |
InsertImage(stream: Stream) | 在此 DocumentBuilder 实例上调用 InsertImage(stream)。 |
InsertImage(imageBytes: byte[]) | 将字节数组中的图像插入文档。 |
InsertImage(image: Image, width: double, height: double) | 将来自 .NET ImageImageImage 对象的内联图像插入文档,并按指定尺寸进行缩放。 |
InsertImage(fileName: string, width: double, height: double) | 将来自文件或 URL 的内联图像插入文档,并按指定尺寸进行缩放。 |
InsertImage(stream: Stream, width: double, height: double) | 在此 DocumentBuilder 实例上调用 InsertImage(stream, width, height)。 |
InsertImage(imageBytes: byte[], width: double, height: double) | 将字节数组中的内联图像插入文档,并按指定大小进行缩放。 |
InsertImage(image: Image, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 在指定的位置和尺寸插入来自 .NET ImageImageImage 对象的图像。 |
InsertImage(fileName: string, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 在指定的位置和尺寸插入来自文件或 URL 的图像。 |
InsertImage(stream: Stream, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 在此 DocumentBuilder 实例上调用 InsertImage(stream, horzPos, left, vertPos, top, width, height, wrapType)。 |
InsertImage(imageBytes: byte[], horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 在指定的位置和大小处插入来自字节数组的图像。 |
InsertForms2OleControl(forms2OleControl: Forms2OleControl) | 在当前的位置插入 Forms2OleControl 对象。 |
InsertHtml(html: string) | 在文档中插入一个HTML字符串。 |
InsertHtml(html: string, useBuilderFormatting: bool) | 在文档中插入一个HTML字符串。 |
InsertHtml(html: string, options: HtmlInsertOptions) | 在文档中插入一个HTML字符串。 |
InsertGroupShape(shapes) | 将作为参数传入的形状分组为一个新的GroupShape节点,并将其插入到当前的位置。 |
InsertGroupShape(left: double, top: double, width: double, height: double, shapes) | 将作为参数传入的形状分组为指定大小的新 GroupShape 节点,并插入到指定位置。 |
InsertChart(chartType: ChartType, width: double, height: double) | 将图表对象插入文档并将其缩放到指定大小。 |
InsertChart(chartType: ChartType, width: double, height: double, chartStyle: ChartStyle) | 将图表对象插入文档并将其缩放到指定大小。 |
InsertChart(chartType: ChartType, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 将图表对象插入文档并将其缩放到指定大小。 |
InsertChart(chartType: ChartType, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType, chartStyle: ChartStyle) | 将图表对象插入文档并将其缩放到指定大小。 |
InsertOnlineVideo(videoUrl: string, width: double, height: double) | 将在线视频对象插入文档并按指定尺寸进行缩放。 |
InsertOnlineVideo(videoUrl: string, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 将在线视频对象插入文档并按指定尺寸进行缩放。 |
InsertOnlineVideo(videoUrl: string, videoEmbedCode: string, thumbnailImageBytes: byte[], width: double, height: double) | 将在线视频对象插入文档,并按指定尺寸进行缩放。 |
InsertOnlineVideo(videoUrl: string, videoEmbedCode: string, thumbnailImageBytes: byte[], horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | 将在线视频对象插入文档,并按指定尺寸进行缩放。 |
InsertHorizontalRule() | 在文档中插入水平线形状。 |
InsertCell() | 在文档中插入表格单元格。 |
StartTable() | 在文档中开始一个表格。 |
EndTable() | 在文档中结束表格。 |
EndRow() | 在文档中结束表格行。 |
StartBookmark(bookmarkName: string) | 将文档中的当前位置标记为书签起始点。 |
EndBookmark(bookmarkName: string) | 将文档中的当前位置标记为书签结束点。 |
StartColumnBookmark(bookmarkName: string) | 将文档中的当前位置标记为列书签的起始位置。 |
EndColumnBookmark(bookmarkName: string) | 将文档中的当前位置标记为列书签的结束位置。 |
StartEditableRange() | 将文档中当前位置标记为可编辑范围的开始。 |
EndEditableRange() | 将文档中当前位置标记为可编辑范围的结束。 |
EndEditableRange(start: EditableRangeStart) | 将文档中当前位置标记为可编辑范围的结束。 |
InsertDocument(srcDoc: Document, importFormatMode: ImportFormatMode) | 在光标位置插入文档。 |
InsertDocument(srcDoc: Document, importFormatMode: ImportFormatMode, importFormatOptions: ImportFormatOptions) | 在光标位置插入文档。 |
InsertDocumentInline(srcDoc: Document, importFormatMode: ImportFormatMode, importFormatOptions: ImportFormatOptions) | 在光标位置内联插入文档。 |
PushFont() | 将当前字符格式保存到堆栈上。 |
PopFont() | 检索先前保存在堆栈上的字符格式。 |
InsertNode(node: Node) | 在光标前插入节点。 |