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

Häufig gestellte Fragen

Wie integriere ich Dokumentenschutzfunktionen in meine .NET-Anwendung?

Sie können Dokumentenschutzfunktionen integrieren, indem Sie die IronSoftware.SecureDoc.Client-Bibliothek verwenden. Diese ermöglicht es Ihnen, Vorgänge wie PDF-Verschlüsselung, Schwärzen und digitale Signatur über REST-API-Aufrufe durchzuführen.

Welche Schritte sind bei der Installation des IronSecureDoc-Clients in einem C#-Projekt erforderlich?

Um den IronSecureDoc-Client in einem C#-Projekt zu installieren, können Sie entweder das IronSoftware.SecureDoc.Client-Paket von NuGet herunterladen oder den Package Manager-Befehl verwenden: Install-Package IronSoftware.SecureDoc.Client.

Kann ich mit dieser Lösung Textschwärzung in PDF-Dokumenten durchführen?

Ja, Sie können Textschwärzung in PDF-Dokumenten durchführen, indem Sie die RedactTextAsync-Methode verwenden, die es Ihnen ermöglicht, die Wörter oder Phrasen anzugeben, die Sie schwärzen möchten.

Wie kann ich sicherstellen, dass meine Dokumentvorgänge sicher und vor Ort bleiben?

Die Verwendung von IronSecureDoc hält Dokumentvorgänge sicher und vor Ort, indem es sich in die IronSecureDoc API integriert, eine Docker-gehostete Lösung, die sicherstellt, dass alle Sicherheitsprozesse lokal gehandhabt werden.

Welche Möglichkeiten bietet die IronSecureDoc API für das Dokumentenmanagement?

Die IronSecureDoc API bietet Möglichkeiten wie Dokumentverschlüsselung, Schwärzen, digitale Signatur und erleichtert die sichere Dokumentverarbeitung in selbst gehosteten Umgebungen.

Wie zertifiziere ich ein PDF-Dokument mit einer digitalen Signatur?

Um ein PDF-Dokument mit einer digitalen Signatur zu zertifizieren, verwenden Sie die CertifyAsync-Methode, und geben Sie den Pfad zu Ihrer Zertifizierungsdatei und das notwendige Passwort an.

Wie kann ich ein PDF-Dokument in meiner C#-Anwendung verschlüsseln?

Sie können ein PDF-Dokument in Ihrer C#-Anwendung mit der EncryptAsync-Methode verschlüsseln, die das Dokument mit einem festgelegten Passwort sichert.

Ist es möglich, spezifische Bereiche in einem PDF-Dokument zu schwärzen?

Ja, es ist möglich, spezifische Bereiche in einem PDF-Dokument zu schwärzen, indem Sie die RedactRegionAsync-Methode verwenden, die es erfordert, die Koordinaten des Bereichs anzugeben, den Sie schwärzen möchten.

Was sollte ich tun, wenn ich Probleme mit dem IronSecureDoc-Client habe?

Wenn Sie Probleme mit dem IronSecureDoc-Client haben, können Sie das Support-Team von IronSoftware per E-Mail unter support@ironsoftware.com kontaktieren.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Version: 2024.10 gerade veröffentlicht