How to use IronSecureDoc from C# in .NET

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

Frequently Asked Questions

How do I integrate document security features into my .NET application?

You can integrate document security features by using the IronSoftware.SecureDoc.Client library. This allows you to perform operations like PDF encryption, redaction, and digital signing through REST API calls.

What steps are involved in installing the IronSecureDoc client in a C# project?

To install the IronSecureDoc client in a C# project, you can either download the IronSoftware.SecureDoc.Client package from NuGet or use the Package Manager command: Install-Package IronSoftware.SecureDoc.Client.

Can I perform text redaction in PDF documents with this solution?

Yes, you can perform text redaction in PDF documents by using the RedactTextAsync method, which allows you to specify the words or phrases you want to redact.

How can I ensure my document operations remain secure and on-site?

Using IronSecureDoc keeps document operations secure and on-site by integrating with the IronSecureDoc API, a Docker-hosted solution, ensuring all security processes are handled locally.

What capabilities does the IronSecureDoc API offer for document management?

The IronSecureDoc API offers capabilities like document encryption, redaction, digital signing, and it facilitates secure document processing within self-hosted environments.

How do I certify a PDF document with a digital signature?

To certify a PDF document with a digital signature, use the CertifyAsync method, providing the path to your certification file and the necessary password.

How can I encrypt a PDF document in my C# application?

You can encrypt a PDF document in your C# application using the EncryptAsync method, which secures the document with a specified password.

Is it possible to redact specific regions in a PDF document?

Yes, it is possible to redact specific regions in a PDF document by using the RedactRegionAsync method, which requires you to specify the coordinates of the area you wish to redact.

What should I do if I encounter issues using the IronSecureDoc client?

If you encounter issues using the IronSecureDoc client, you can contact IronSoftware's support team via email at support@ironsoftware.com for assistance.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?