WordImportExportAgentTools Class
Provides agent tools for content format conversion and import/export operations. Handles in-memory operations for HTML, Markdown, and text conversions.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Word
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class WordImportExportAgentTools : AgentToolBase<WordDocument>
Constructors
WordImportExportAgentTools(DocumentStorageManager)
Initializes a new instance of the WordImportExportAgentTools class (Mode 2 — DocumentStorage).
Declaration
public WordImportExportAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
WordImportExportAgentTools(WordDocumentManager)
Initializes a new instance of the WordImportExportAgentTools class (Mode 1 — InMemory).
Declaration
public WordImportExportAgentTools(WordDocumentManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| WordDocumentManager | manager | The document manager for managing Word documents. |
Methods
ConvertDocument(String, String, String)
Converts the document to the file system in the specified format (DocumentStorage mode only).
Declaration
[Tool(Name = "ConvertDocument", Description = "Converts the document to the file system in the specified format. Works only in DocumentStorage mode. documentIdOrFilePath: The input file path from storage. Supported formats: DOCX, DOC, RTF, HTML, TXT, MD.")]
public AgentToolResult ConvertDocument([ToolParameter(Description = "The input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The file path to export to")] string filePath, [ToolParameter(Description = "The format: Docx, Doc, Rtf, Html, Txt, Md. Defaults to Docx")] string formatType = "Docx")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The input file path (DocumentStorage mode). |
| System.String | filePath | The destination file path where the converted document will be saved. |
| System.String | formatType | The output format: Docx, Doc, Rtf, Html, Md or Txt. Default is Docx. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the document was converted successfully. |
ExportAsImage(String, String, Nullable<Int32>, Nullable<Int32>, String)
Updates (rebuilds) the Table of Contents in a Word document.
Declaration
[Tool(Name = "ExportAsImage", Description = "Exports Word document pages as images (PNG or JPEG) to the output directory. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Optionally specify a page range using startPageIndex and endPageIndex (1-based). Returns the file paths of the exported images.")]
public AgentToolResult ExportAsImage([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The image format: Png or Jpeg. Defaults to Png")] string imageFormat = "Png", [ToolParameter(Description = "The 1-based start page index. If null, starts from the first page")] Nullable<int> startPageIndex = null, [ToolParameter(Description = "The 1-based end page index. If null, converts up to the last page")] Nullable<int> endPageIndex = null, [ToolParameter(Description = "Output directory for saving the images. Defaults to current directory.")] string outputDirectory = ".")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | imageFormat | The image format: Png or Jpeg. Defaults to Png. |
| System.Nullable<System.Int32> | startPageIndex | The 1-based start page index. If null, starts from the first page. |
| System.Nullable<System.Int32> | endPageIndex | The 1-based end page index. If null, converts up to the last page. |
| System.String | outputDirectory | Output directory for saving the images. Defaults to current directory. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the list of exported image file paths. |
GetHtml(String)
Gets the Word document content as HTML.
Declaration
[Tool(Name = "GetHtml", Description = "Gets the Word document content as HTML using the given documentId or filePath. Returns the HTML string of a Word document.")]
public AgentToolResult GetHtml([ToolParameter(Description = "The ID of the document or file path")] string documentIdOrFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the HTML content string or an error message. |
GetMarkdown(String)
Gets the Word document content as Markdown.
Declaration
[Tool(Name = "GetMarkdown", Description = "Gets the Word document content as Markdown using the given documentId or filePath. Returns the Markdown content string of a Word document.")]
public AgentToolResult GetMarkdown([ToolParameter(Description = "The ID of the document or file path")] string documentIdOrFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the Markdown content string or an error message. |
GetText(String)
Gets the Word document content as plain text.
Declaration
[Tool(Name = "GetText", Description = "Gets the Word document content as text using the given documentId or filePath. Returns the text of a Word document.")]
public AgentToolResult GetText([ToolParameter(Description = "The ID of the document or file path")] string documentIdOrFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the text content string or an error message. |
ImportHtml(String, String, String)
Imports HTML content into a Word document.
Declaration
[Tool(Name = "ImportHtml", Description = "Imports/Merge HTML content into a Word document. htmlContent / filePath: The HTML content as a string or the file path to an HTML file. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ImportHtml([ToolParameter(Description = "The HTML content as a string or the file path to an HTML file")] string htmlContentOrFilePath, [ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document")] string documentIdOrFilePath = null, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlContentOrFilePath | The HTML content as a string or the file path to an HTML file. |
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |
ImportMarkdown(String, String, String)
Imports Markdown content into a Word document.
Declaration
[Tool(Name = "ImportMarkdown", Description = "Imports markdown content into a Word document. markdownContent / filePath: The markdown content as a string or the file path to a markdown file. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ImportMarkdown([ToolParameter(Description = "The markdown content as a string or the file path to a markdown file")] string markdownContentOrFilePath, [ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document")] string documentIdOrFilePath = null, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | markdownContentOrFilePath | The markdown content as a string or the file path to a markdown file. |
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |