How to use IronSecureDoc from C# in .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

Your Gateway to Enhanced Document Security

IronSoftware.SecureDoc.Client is a robust client-side library designed to interact seamlessly with the IronSecureDoc API, a comprehensive document security solution hosted in a Docker container.

This client library facilitates easy integration into your existing .NET applications, enabling you to leverage the powerful features of IronSecureDoc, including PDF encryption, redaction, and digital signing, all through simple REST API calls.

With IronSoftware.SecureDoc.Client, developers can ensure the security and integrity of documents within their applications, maintaining all operations on-site for enhanced data protection. Whether you need to redact sensitive information, certify documents with digital signatures, or enforce document encryption, IronSoftware.SecureDoc.Client provides the necessary tools to accomplish these tasks efficiently and securely.

Features

Key Features:

  • Easy integration with IronSecureDoc's REST API.
  • Support for document encryption, redaction, and digital signing.
  • Facilitates secure document processing within self-hosted environments.
  • Enhances data protection by keeping document security operations on-site.
  • Compatible with .NET applications, offering a straightforward approach to secure document management.

Installation

Let's start with installing the NuGet package from the package manager:

Option 1: Download from NuGet

The NuGet package is listed here on the official NuGet website: https://www.nuget.org/packages/IronSoftware.SecureDoc.Client

Option 2: PM Install Command

Install-Package IronSoftware.SecureDoc.Client

Code Example

using IronSecureDoc;
using System.IO;
using System.Threading.Tasks;

// Example illustrating how to use the IronSecureDocClient
class SecureDocExample
{
    static async Task Main(string[] args)
    {
        // Replace with your IRONSECUREDOC URL
        var client = new IronSecureDocClient("http://localhost:5185");

        // Replace with your PDF or CERT paths
        string PDF_PATH = "path/to/your.pdf";
        string CERT_PATH = "path/to/your.p12";

        // Attempt to connect to the IronSecureDoc API
        if (await client.TryConnectAsync())
        {
            // Redact Text
            File.WriteAllBytes(
                "redact_text_example.pdf",
                await client.RedactTextAsync(PDF_PATH, new[] { "Dummy" })
            );

            // Redact Region
            File.WriteAllBytes(
                "redact_region_example.pdf",
                await client.RedactRegionAsync(PDF_PATH, 50, 50, 200, 100)
            );

            // Certify
            File.WriteAllBytes(
                "certify_example.pdf",
                await client.CertifyAsync(PDF_PATH, CERT_PATH, "123456", CertifyPermissions.FormFillingAllowed)
            );

            // Encrypt
            File.WriteAllBytes(
                "encrypt_example.pdf",
                await client.EncryptAsync(PDF_PATH, "iron")
            );
        }
    }
}
using IronSecureDoc;
using System.IO;
using System.Threading.Tasks;

// Example illustrating how to use the IronSecureDocClient
class SecureDocExample
{
    static async Task Main(string[] args)
    {
        // Replace with your IRONSECUREDOC URL
        var client = new IronSecureDocClient("http://localhost:5185");

        // Replace with your PDF or CERT paths
        string PDF_PATH = "path/to/your.pdf";
        string CERT_PATH = "path/to/your.p12";

        // Attempt to connect to the IronSecureDoc API
        if (await client.TryConnectAsync())
        {
            // Redact Text
            File.WriteAllBytes(
                "redact_text_example.pdf",
                await client.RedactTextAsync(PDF_PATH, new[] { "Dummy" })
            );

            // Redact Region
            File.WriteAllBytes(
                "redact_region_example.pdf",
                await client.RedactRegionAsync(PDF_PATH, 50, 50, 200, 100)
            );

            // Certify
            File.WriteAllBytes(
                "certify_example.pdf",
                await client.CertifyAsync(PDF_PATH, CERT_PATH, "123456", CertifyPermissions.FormFillingAllowed)
            );

            // Encrypt
            File.WriteAllBytes(
                "encrypt_example.pdf",
                await client.EncryptAsync(PDF_PATH, "iron")
            );
        }
    }
}
Imports IronSecureDoc
Imports System.IO
Imports System.Threading.Tasks

' Example illustrating how to use the IronSecureDocClient
Friend Class SecureDocExample
	Shared Async Function Main(ByVal args() As String) As Task
		' Replace with your IRONSECUREDOC URL
		Dim client = New IronSecureDocClient("http://localhost:5185")

		' Replace with your PDF or CERT paths
		Dim PDF_PATH As String = "path/to/your.pdf"
		Dim CERT_PATH As String = "path/to/your.p12"

		' Attempt to connect to the IronSecureDoc API
		If Await client.TryConnectAsync() Then
			' Redact Text
			File.WriteAllBytes("redact_text_example.pdf", Await client.RedactTextAsync(PDF_PATH, { "Dummy" }))

			' Redact Region
			File.WriteAllBytes("redact_region_example.pdf", Await client.RedactRegionAsync(PDF_PATH, 50, 50, 200, 100))

			' Certify
			File.WriteAllBytes("certify_example.pdf", Await client.CertifyAsync(PDF_PATH, CERT_PATH, "123456", CertifyPermissions.FormFillingAllowed))

			' Encrypt
			File.WriteAllBytes("encrypt_example.pdf", Await client.EncryptAsync(PDF_PATH, "iron"))
		End If
	End Function
End Class
$vbLabelText   $csharpLabel

Explanation

  • IronSecureDocClient Initialization: Initialize the IronSecureDocClient with the URL to your IRONSECUREDOC server.
  • Connecting: Use TryConnectAsync() to verify the connection to the server.
  • Redact Text: Define sensitive words/phrases to redact using RedactTextAsync.
  • Redact Region: Redact specific regions by specifying coordinates with RedactRegionAsync.
  • Certify: Add a digital certification with CertifyAsync. Provide path to the certification file and a password.
  • Encrypt: Secure the document by encrypting it using EncryptAsync.

Support

For support please contact us: support@ironsoftware.com

常見問題解答

如何將文檔安全功能整合到我的 .NET 應用程序中?

您可以通過使用 IronSoftware.SecureDoc.Client 庫整合文檔安全功能。這樣可以通過 REST API 調用進行操作,如 PDF 加密、編輯和數字簽名。

在 C# 項目中安裝 IronSecureDoc 客戶端涉及哪些步驟?

要在 C# 項目中安裝 IronSecureDoc 客戶端,您可以從 NuGet 下載 IronSoftware.SecureDoc.Client 包或使用包管理器命令:Install-Package IronSoftware.SecureDoc.Client

我能夠使用這個解決方案進行 PDF 文檔的文本編輯嗎?

是的,您可以通過使用 RedactTextAsync 方法執行 PDF 文檔的文本編輯,該方法允許您指定要編輯的單詞或短語。

如何確保我的文檔操作保持安全並在現場?

使用 IronSecureDoc 通過集成 IronSecureDoc API 來保持文檔操作的安全性和現場進行,這是一種 Docker 托管的解決方案,確保所有安全操作均在本地處理。

IronSecureDoc API 提供什麼功能來進行文檔管理?

IronSecureDoc API 提供了文檔加密、編輯、數字簽名的功能,並促進自我託管環境內的安全文檔處理。

如何使用數字簽名認證 PDF 文件?

要使用數字簽名認證 PDF 文件,請使用 CertifyAsync 方法,提供您的認證文件的路徑和必要的密碼。

如何在我的 C# 應用程序中加密 PDF 文件?

您可以在 C# 應用程序中使用 EncryptAsync 方法加密 PDF 文件,該方法會使用指定的密碼保護文件。

是否可以在 PDF 文件中編輯特定區域?

是的,可以通過使用 RedactRegionAsync 方法在 PDF 文件中編輯特定區域,該方法需要您指定要編輯區域的座標。

如果使用 IronSecureDoc 客戶端時遇到問題,應該怎麼做?

如果您使用 IronSecureDoc 客戶端時遇到問題,您可以通過電子郵件 support@ironsoftware.com 聯繫 IronSoftware 的支持團隊以獲得幫助。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
版本: 2024.10 剛剛發布