Smart Redaction in C#

Based on its advanced artificial intelligence (AI) and document understanding engine, GdPicture.NET Library recognizes sensitive information in a document and marks it for redaction. After you validate these marks, GdPicture.NET Library removes them from the document.

To redact sensitive information, follow these steps:

  1. Create a GdPicturePDF object.

  2. Select the source PDF file by passing its path to the LoadFromFile method of the GdPicturePDF object.

  3. Configure the redaction process by creating a GdPicturePDF.SmartRedactionOptions object in the following way:

    • Set the path to the OCR resource folder with the ResourcePath property. The default language resources are located in GdPicture.NET 14\Redist\OCR. For more information on adding language resources, see the language support guide.

    • By default, detected sensitive information is immediately removed. To only mark sensitive information for redaction without actually removing it, set the Immediate property to false.

    • Set the types of sensitive information that you want to redact by setting the following properties to true: RedactCreditCardNumbers, RedactEmailAddresses, RedactIBANs, RedactPhoneNumbers, RedactSocialSecurityNumbers, RedactURIs, RedactVatIDs, RedactVehicleIdentificationNumbers, RedactPostalAddresses.

  4. Run the redaction process by passing the GdPicturePDF.SmartRedactionOptions object to the SmartRedaction method of the GdPicturePDF object.

  5. Save the output in a PDF document with the SaveToFile method.

The example below loads a PDF document, removes sensitive information such as credit card numbers and email addresses, and then saves the redacted file in a PDF:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
// Load the source document.
// Configure the redaction process.
GdPicturePDF.SmartRedactionOptions redactionOptions = new GdPicturePDF.SmartRedactionOptions()
        ResourcePath = @"C:\GdPicture.NET 14\Redist\OCR",
        RedactCreditCardNumbers = true,
        RedactEmailAddresses = true,
        RedactIBANs = true,
        RedactPhoneNumbers = true,
        RedactSocialSecurityNumbers = true,
        RedactURIs = true,
        RedactVatIDs = true,
        RedactVehicleIdentificationNumbers = true,
        RedactPostalAddresses = true
// Run the redaction process.
// Save the output in a PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    ' Load the source document.
    ' Configure the redaction process.
    Dim redactionOptions As GdPicturePDF.SmartRedactionOptions = New GdPicturePDF.SmartRedactionOptions() With {
        .ResourcePath = "C:\GdPicture.NET 14\Redist\OCR",
        .RedactCreditCardNumbers = True,
        .RedactEmailAddresses = True,
        .RedactIBANs = True,
        .RedactPhoneNumbers = True,
        .RedactSocialSecurityNumbers = True,
        .RedactURIs = True,
        .RedactVatIDs = True,
        .RedactVehicleIdentificationNumbers = True
        .RedactPostalAddresses = True
    // Run the redaction process.
    // Save the output in a PDF document.
End Using
Used Methods and Properties

Related Topics