PdfOperationsAgentTools Class
Provides AI agent tools for PDF document manipulation operations. Handles merging, splitting, and compression of PDF documents.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.PDF
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class PdfOperationsAgentTools : AgentToolBase<PdfDocumentBase>
Constructors
PdfOperationsAgentTools(DocumentStorageManager)
Initializes a new instance of the PdfOperationsAgentTools class (Mode 2 � DocumentStorage).
Declaration
public PdfOperationsAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
PdfOperationsAgentTools(PdfDocumentManager)
Initializes a new instance of the PdfOperationsAgentTools class (Mode 1 � InMemory).
Declaration
public PdfOperationsAgentTools(PdfDocumentManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| PdfDocumentManager | manager | The PDF document manager. |
Methods
CompressPdf(String, Boolean, Int32, Boolean, Boolean, Boolean, String)
Compresses a PDF document by optimizing images, fonts, page contents, and removing metadata using either documentId or filePath.
Declaration
[Tool(Name = "CompressPdf", Description = "Compresses an existing PDF document. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Uses image compression, font optimization, page content optimization, and metadata removal.")]
public AgentToolResult CompressPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "Whether to compress images")] bool compressImages = true, [ToolParameter(Description = "Image quality (10�100)")] int imageQuality = 50, [ToolParameter(Description = "Whether to optimize embedded fonts")] bool optimizeFont = true, [ToolParameter(Description = "Whether to optimize page contents")] bool optimizePageContents = true, [ToolParameter(Description = "Whether to remove document metadata")] bool removeMetadata = true, [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). |
| System.Boolean | compressImages | Whether to compress images. |
| System.Int32 | imageQuality | Image quality (10–100). |
| System.Boolean | optimizeFont | Whether to optimize embedded fonts. |
| System.Boolean | optimizePageContents | Whether to optimize page contents. |
| System.Boolean | removeMetadata | Whether to remove document metadata. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID and compression options applied. |
MergePdfs(List<PdfFileInput>, Boolean, String)
Merges multiple PDF files into a single PDF document and returns the new document ID. Each input may include an optional password for encrypted PDFs.
Declaration
[Tool(Name = "MergePdfs", Description = "Merges multiple PDF files into a single PDF document and returns the document ID. FilePath accepts a local file path (InMemory mode) or a storage key (DocumentStorage mode). outputFilePath: Output file path for saving the result (DocumentStorage mode only). Input format example: {\"pdfFiles\":[{\"FilePath\":\"invoice.pdf\",\"Password\":null},{\"FilePath\":\"image-pdf.pdf\",\"Password\":null}],\"mergeAccessibilityTags\":true}")]
public AgentToolResult MergePdfs([ToolParameter(Description = "List of PDF files to merge. Each item must contain a FilePath (local file path in InMemory mode, or storage key in DocumentStorage mode) and an optional Password. Example: [{ \"FilePath\": \"invoice.pdf\", \"Password\": null }]")] List<PdfFileInput> pdfFiles, [ToolParameter(Description = "Whether to merge accessibility tags from source PDFs")] bool mergeAccessibilityTags = false, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<PdfFileInput> | pdfFiles | List of PDF files to merge. Each item must contain a FilePath and an optional Password. |
| System.Boolean | mergeAccessibilityTags | Whether to merge accessibility tags from source PDFs. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the merged document ID and file count. |
ReorderPdfPages(String, Int32[], String)
Reorders the pages of an existing PDF document using a specified page index sequence.
Declaration
[Tool(Name = "ReorderPdfPages", Description = "Rearranges PDF pages using a zero-based page index sequence. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Get the PDF page count first and ensure the index array length matches it.")]
public AgentToolResult ReorderPdfPages([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "Zero-based page indexes defining the new order. Get the PDF page count first; the array length must equal the page count. Values must be in range and not repeated.")] int[] orderIndexes, [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). |
| System.Int32[] | orderIndexes | Zero-based page indexes defining the new order. Length must equal the page count. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID, page count, and new page order. |
SplitPdf(String, Int32[][], String, String)
Splits a PDF document into multiple files by individual pages or by specified page ranges.
If pageRanges is null, the document is split into individual pages.
Declaration
[Tool(Name = "SplitPdf", Description = "Splits a loaded PDF document. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). If pageRanges is null, the document is split into individual pages. If pageRanges is provided, each range must be [startPage, endPage] (zero-based).")]
public AgentToolResult SplitPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "Optional page ranges [[start,end]]. Null = split all pages")] int[][] pageRanges = null, [ToolParameter(Description = "Output file name pattern (default: Output{0}.pdf)")] string outputFilePattern = "Output{0}.pdf", [ToolParameter(Description = "Output folder path for saving the result (DocumentStorage mode only).")] string outputFolderPath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.Int32[][] | pageRanges | Optional page ranges [[start, end]] (zero-based). Null splits all pages individually. |
| System.String | outputFilePattern | Output file name pattern (default: Output{0}.pdf). |
| System.String | outputFolderPath | Output folder path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID, split mode, and output folder path. |