PdfSecurityAgentTools Class
Provides AI agent tools for PDF document security and encryption operations. Handles encryption, decryption, and permission management.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.PDF
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class PdfSecurityAgentTools : AgentToolBase<PdfDocumentBase>
Constructors
PdfSecurityAgentTools(DocumentStorageManager)
Initializes a new instance of the PdfSecurityAgentTools class (Mode 2 � DocumentStorage).
Declaration
public PdfSecurityAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
PdfSecurityAgentTools(PdfDocumentManager)
Initializes a new instance of the PdfSecurityAgentTools class (Mode 1 � InMemory).
Declaration
public PdfSecurityAgentTools(PdfDocumentManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| PdfDocumentManager | manager | The PDF document manager. |
Methods
DecryptPdf(String, String, String)
Removes encryption from a password-protected PDF document by clearing its security passwords and permissions.
Declaration
[Tool(Name = "DecryptPdf", Description = "Removes encryption from a protected PDF file. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult DecryptPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The protection password")] string password, [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.String | password | |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result confirming the document has been decrypted. |
EncryptPdf(String, String, String, String, String)
Protects a PDF document with a user password and applies the specified encryption algorithm and key size.
Declaration
[Tool(Name = "EncryptPdf", Description = "Protect the PDF file with password. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). encryptionAlgorithm: The algorithm applied to encrypt the PDF. keySize: The bit-length of the encryption key.")]
public AgentToolResult EncryptPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The password to encrypt the document")] string password, [ToolParameter(Description = "The encryption algorithm (AES or RC4)")] string encryptionAlgorithm = "AES", [ToolParameter(Description = "The bit-length of the encryption key (40, 128, 256)")] string keySize = "256", [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.String | password | The password to encrypt the document. |
| System.String | encryptionAlgorithm | The encryption algorithm (AES or RC4). |
| System.String | keySize | The bit-length of the encryption key (40, 128, 256). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result confirming encryption with the algorithm and key size applied. |
RedactPdf(String, RedactionRequest, String)
Redacts rectangular regions from an existing PDF document by permanently removing sensitive content and filling the areas with the specified color.
Declaration
[Tool(Name = "RedactPdf", Description = "Redacts rectangular regions from an existing PDF document. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Input format example: {\"documentIdOrFilePath\":\"pdf_123456\",\"redaction\":{\"Redactions\":[{\"PageIndex\":0,\"Bounds\":{\"X\":100,\"Y\":200,\"Width\":250,\"Height\":50},\"Color\":{\"Red\":0,\"Green\":0,\"Blue\":0}}]}}")]
public AgentToolResult RedactPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode).")] string documentIdOrFilePath, [ToolParameter(Description = "Redaction instructions including page index, rectangle bounds, and optional color.")] RedactionRequest redaction, [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). |
| RedactionRequest | redaction | Redaction instructions including page index, rectangle bounds, and optional fill color. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID and the number of redactions applied. |
RemovePermissions(String, String, String)
Removes all document permissions from a PDF by resetting them to the default (unrestricted) state.
Declaration
[Tool(Name = "RemovePermissions", Description = "Removes document permissions. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult RemovePermissions([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The password to open the document if it is already encrypted (optional).")] string password = null, [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.String | password | The password to open the document if it is already encrypted (optional). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result confirming all permissions have been removed. |
SetPermissions(String, PdfSecurityAgentTools.PermissionsRequest, String, String)
Sets document permissions on a PDF such as print, copy, edit content, and more. Permissions are specified as a comma-separated string of flag names.
Declaration
[Tool(Name = "SetPermissions", Description = "Sets or restricts PDF permissions by specifying allowed actions like printing, editing, copying, annotations, and form filling.")]
public AgentToolResult SetPermissions([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode).")] string documentIdOrFilePath, [ToolParameter(Description = "Permissions object specifying allowed actions. Each field should be true (allowed) or false (restricted). Example: { AllowPrint: false, AllowEditContent: false } means read-only.")] PdfSecurityAgentTools.PermissionsRequest permissions, [ToolParameter(Description = "Optional password if the document is already encrypted.")] string password = null, [ToolParameter(Description = "Optional output file path (used only in DocumentStorage mode).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
| PdfSecurityAgentTools.PermissionsRequest | permissions | The permissions to set (comma-separated: Print, EditContent, CopyContent, etc.). |
| System.String | password | The password to open the document if it is already encrypted (optional). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result confirming the permissions were applied. |
SignPdf(String, String, String, RectangleF, Int32, String, String)
Digitally signs a PDF document using a PFX certificate and places the signature within the specified bounds. An optional appearance image can be provided for the visible signature.
Declaration
[Tool(Name = "SignPdf", Description = "Digitally signs a PDF document using a certificate and an optional appearance image. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult SignPdf([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "The path to the certificate file (.pfx)")] string certificateFilePath, [ToolParameter(Description = "The certificate password")] string certificatePassword, [ToolParameter(Description = "The signature bounds (X, Y, Width, Height)")] RectangleF bounds, [ToolParameter(Description = "The zero-based page index where the signature should be placed (0 for first page, -1 for last page). Default is 0.")] int pageIndex = 0, [ToolParameter(Description = "Optional path to signature appearance image")] string appearanceImagePath = null, [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.String | certificateFilePath | The path to the certificate file (.pfx). |
| System.String | certificatePassword | The certificate password. |
| Syncfusion.Drawing.RectangleF | bounds | The signature bounds (X, Y, Width, Height). |
| System.Int32 | pageIndex | The zero-based page index where the signature should be placed (0 for first page, -1 for last page). |
| System.String | appearanceImagePath | Optional path to signature appearance image. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the document ID, certificate used, and signature bounds. |