WordOperationsAgentTools Class
Provides agent tools for document manipulation and comparison operations. Handles merging, splitting, and comparing Word documents.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Word
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class WordOperationsAgentTools : AgentToolBase<WordDocument>
Constructors
WordOperationsAgentTools(DocumentStorageManager)
Initializes a new instance of the WordOperationsAgentTools class (Mode 2 — DocumentStorage).
Declaration
public WordOperationsAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
WordOperationsAgentTools(WordDocumentManager)
Initializes a new instance of the WordOperationsAgentTools class (Mode 1 — InMemory).
Declaration
public WordOperationsAgentTools(WordDocumentManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| WordDocumentManager | manager | The document manager for managing Word documents. |
Methods
CloneDocument(String, String)
Creates a deep copy (clone) of a Word document and stores it in memory.
Declaration
[Tool(Name = "CloneDocument", Description = "Creates a deep copy (clone) of an existing Word document. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Returns the new document ID of the cloned document. Use this to duplicate a template before making changes, so the original is preserved.")]
public AgentToolResult CloneDocument([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the source document to clone")] string documentIdOrFilePath, [ToolParameter(Description = "Output file path for saving the cloned document (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the source document to clone. |
| System.String | outputFilePath | Output file path for saving the cloned document (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the new document ID of the cloned document. |
CompareDocuments(String, String, String, DateTime, String)
Compares two documents and marks differences as tracked changes.
Declaration
[Tool(Name = "CompareDocuments", Description = "Compares the original document with the revised document and marks differences as tracked changes in the original document. originalDocumentIdOrFilePath and revisedDocumentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult CompareDocuments([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the original document")] string originalDocumentIdOrFilePath, [ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the revised document")] string revisedDocumentIdOrFilePath, [ToolParameter(Description = "The revision author name")] string author = "Author", [ToolParameter(Description = "The date and time to associate with the revisions")] DateTime dateTime = null, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | originalDocumentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the original document. |
| System.String | revisedDocumentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the revised document. |
| System.String | author | The author name associated with the tracked revisions. |
| System.DateTime | dateTime | The date and time associated with the tracked revisions. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the document comparison was completed successfully. |
MergeDocuments(String, String[], String, String)
Merges multiple Word documents into a single destination document.
Declaration
[Tool(Name = "MergeDocuments", Description = "Merges multiple Word documents into a single destination document. destinationDocumentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination WordDocument. documentIds/filePaths: A collection of document IDs or file paths to merge into the destination document.")]
public AgentToolResult MergeDocuments([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination WordDocument")] string destinationDocumentIdOrFilePath, [ToolParameter(Description = "A collection of document IDs or file paths to merge")] string[] documentIdsOrFilePaths, [ToolParameter(Description = "Import option to control formatting when merging. Accepted values: 'UseDestinationStyles' (default) - applies destination document styles; 'KeepSourceFormatting' - applies default Normal style and preserves all other formatting as direct formatting; 'KeepTextOnly' - imports only plain text without any formatting; 'ListContinueNumbering' - imports content and continues existing list numbering; 'ListRestartNumbering' - imports content and restarts list numbering; 'MergeFormatting' - applies the formatting of surrounding content in the destination document.")] string pasteOption = "UseDestinationStyles", [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | destinationDocumentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the destination WordDocument. |
| System.String[] | documentIdsOrFilePaths | A collection of document IDs or file paths to merge into the destination document. |
| System.String | pasteOption | Specifies how formatting is handled during merge, such as using destination styles or keeping source formatting. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |
SplitDocument(String, String, String, String)
Splits a Word document into multiple documents based on split rules.
Declaration
[Tool(Name = "SplitDocument", Description = "Splits a single Word document into multiple documents based on the specified splitRules. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Returns the IDs of the documents generated after splitting. Accepted values for splitRules: 'SplitBySection' (default) - splits into one document per section; 'SplitByHeading' - splits at each Heading 1 paragraph; 'SplitByBookmark' - splits by extracting each bookmark's content; 'SplitByPlaceholderText' - splits by extracting content between paired placeholder markers (e.g. <<start>> ... <<end>>); 'SplitByPageBreak' - splits at each explicit page break or paragraph with PageBreakBefore formatting.")]
public AgentToolResult SplitDocument([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the main document to split")] string documentIdOrFilePath, [ToolParameter(Description = "Defines how the document is split. Accepted values: 'SplitBySection' (default) - splits the document at each section break; 'SplitByHeading' - splits the document at each Heading 1 paragraph; 'SplitByBookmark' - splits the document by extracting content within each bookmark; 'SplitByPlaceholderText' - splits the document by extracting content between paired placeholder markers; 'SplitByPageBreak' - splits the document at each explicit page break (Break entity with BreakType.PageBreak) or paragraph formatted with PageBreakBefore.")] string splitRules = "SplitBySection", [ToolParameter(Description = "The regex pattern used to find placeholder markers when splitRules is 'SplitByPlaceholderText'. Defaults to '<<(.*)>>' which matches paired markers like <<SectionStart>> and <<SectionEnd>>.")] string placeholderText = "<<(.*)>>", [ToolParameter(Description = "Output file path prefix for saving the split results.")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the main document to split. |
| System.String | splitRules | Defines how the document is split — by sections, headings, bookmarks, or placeholder text. |
| System.String | placeholderText | The regex pattern used to identify placeholder markers when splitRules is 'SplitByPlaceholderText'. Defaults to "<<(.*)>>". |
| System.String | outputFilePath | Output file path prefix for saving the split results. If empty, generated file names are used. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the IDs of generated documents. |
UnlinkDocumentFields(String, String)
Unlinks all fields in a Word document, replacing each field with its most recent result text.
Declaration
[Tool(Name = "UnlinkDocumentFields", Description = "Unlinks all fields in a Word document by replacing each field with its current result as static text or a graphic. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). After unlinking, field values can no longer be updated automatically. XE (Index Entry) fields are skipped as they cannot be unlinked.")]
public AgentToolResult UnlinkDocumentFields([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document whose fields should be unlinked")] string documentIdOrFilePath, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document whose fields should be unlinked. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success with the count of fields unlinked. |
UpdateDocumentFields(String, Boolean, String)
Updates all fields (DATE, TIME, DOCVARIABLE, IF, SEQ, etc.) present in a Word document.
Declaration
[Tool(Name = "UpdateDocumentFields", Description = "Updates all fields in a Word document — DATE, TIME, DOCVARIABLE, DOCPROPERTY, IF, SEQ, NUMPAGES, Cross-Reference, CreateDate, and more. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Pass updatePageFields=true to also update Page and NumPages fields (requires additional PDF layout assemblies).")]
public AgentToolResult UpdateDocumentFields([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document whose fields should be updated")] string documentIdOrFilePath, [ToolParameter(Description = "When true, also updates page-related fields such as Page and NumPages. Defaults to false.")] bool updatePageFields = false, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document whose fields should be updated. |
| System.Boolean | updatePageFields | When true, also updates page-related fields such as Page and NumPages (requires Word-to-PDF layout engine). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |
UpdateTableOfContents(String, String)
Updates (rebuilds) the Table of Contents in a Word document.
Declaration
[Tool(Name = "UpdateTableOfContents", Description = "Updates (rebuilds) the Table of Contents (TOC) in a Word document based on the current heading styles and page layout. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Call this after modifying document content to reflect the latest headings and page numbers in the TOC.")]
public AgentToolResult UpdateTableOfContents([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document whose Table of Contents should be updated")] string documentIdOrFilePath, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the document containing the TOC to update. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |