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

Questions Fréquemment Posées

Comment puis-je intégrer des fonctionnalités de sécurité des documents dans mon application .NET ?

Vous pouvez intégrer des fonctionnalités de sécurité des documents en utilisant la bibliothèque IronSoftware.SecureDoc.Client. Cela vous permet d'effectuer des opérations comme le cryptage PDF, la suppression de texte et la signature numérique via des appels API REST.

Quelles sont les étapes pour installer le client IronSecureDoc dans un projet C# ?

Pour installer le client IronSecureDoc dans un projet C#, vous pouvez soit télécharger le package IronSoftware.SecureDoc.Client de NuGet, soit utiliser la commande du gestionnaire de packages : Install-Package IronSoftware.SecureDoc.Client.

Puis-je supprimer le texte dans les documents PDF avec cette solution ?

Oui, vous pouvez supprimer le texte dans les documents PDF en utilisant la méthode RedactTextAsync, qui vous permet de spécifier les mots ou les phrases que vous souhaitez masquer.

Comment puis-je m'assurer que mes opérations sur les documents restent sécurisées et sur site ?

En utilisant IronSecureDoc, vous gardez les opérations sur les documents sécurisées et sur site en intégrant à l'API IronSecureDoc, une solution hébergée sur Docker, garantissant que tous les processus de sécurité sont gérés localement.

Quelles capacités l'API IronSecureDoc offre-t-elle pour la gestion des documents ?

L'API IronSecureDoc offre des capacités telles que le cryptage des documents, la suppression de texte, la signature numérique et elle facilite le traitement sécurisé des documents dans des environnements auto-hébergés.

Comment puis-je certifier un document PDF avec une signature numérique ?

Pour certifier un document PDF avec une signature numérique, utilisez la méthode CertifyAsync, en fournissant le chemin vers votre fichier de certification et le mot de passe nécessaire.

Comment puis-je crypter un document PDF dans mon application C# ?

Vous pouvez crypter un document PDF dans votre application C# en utilisant la méthode EncryptAsync, qui sécurise le document avec un mot de passe spécifié.

Est-il possible de masquer des régions spécifiques dans un document PDF ?

Oui, il est possible de masquer des régions spécifiques dans un document PDF en utilisant la méthode RedactRegionAsync, qui nécessite de spécifier les coordonnées de la zone que vous souhaitez masquer.

Que dois-je faire si je rencontre des problèmes en utilisant le client IronSecureDoc ?

Si vous rencontrez des problèmes en utilisant le client IronSecureDoc, vous pouvez contacter l'équipe de support d'IronSoftware par email à support@ironsoftware.com pour obtenir de l'aide.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Version : 2024.10 vient de sortir