ByteScout Sensitive Data Suite - C# - Remove Sensitive Data From Scanned Document - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Sensitive Data Suite – C# – Remove Sensitive Data From Scanned Document

  • Home
  • /
  • Articles
  • /
  • ByteScout Sensitive Data Suite – C# – Remove Sensitive Data From Scanned Document

How to remove sensitive data from scanned document in C# and ByteScout Sensitive Data Suite

Learning is essential in computer world and the tutorial below will demonstrate how to remove sensitive data from scanned document in C#

These sample source codes on this page below are displaying how to remove sensitive data from scanned document in C#. ByteScout Sensitive Data Suite is the set that includes SDK tools from ByteScout for working with sensitive and personal data. With these tools you may analyze, redact, remove, blackout sensitive data in documents and pdf. It can be applied to remove sensitive data from scanned document using C#.

These C# code samples for C# guide developers to speed up coding of the application when using ByteScout Sensitive Data Suite. Just copy and paste the code into your C# application’s code and follow the instructions. Enjoy writing a code with ready-to-use sample C# codes.

You can download free trial version of ByteScout Sensitive Data Suite from our website to see and try many others source code samples for C#.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.Drawing; using System.IO; using Bytescout.PDFExtractor; namespace RemoveSensitiveDataFromScannedDocument { class Program { static void Main(string[] args) { MemoryStream searchablePDFStream = new MemoryStream(); // STEP-1: Make Searchable PDF // STEP-2: Get search text result from that searchable PDF // STEP-3: Remove sensitive data // Create Bytescout.PDFExtractor.SearchablePDFMaker instance using (var searchablePDFMaker = new SearchablePDFMaker("demo","demo")) { // Load sample PDF document searchablePDFMaker.LoadDocumentFromFile("sampleScannedPDF_EmailAddress.pdf"); // Set the location of language data files searchablePDFMaker.OCRLanguageDataFolder = @"c:\Program Files\Bytescout PDF Extractor SDK\ocrdata\"; // Set OCR language searchablePDFMaker.OCRLanguage = "eng"; // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish etc - according to files in "ocrdata" folder // Set PDF document rendering resolution searchablePDFMaker.OCRResolution = 300; // Save extracted text to file searchablePDFMaker.MakePDFSearchable(searchablePDFStream); // Prepare TextExtractor using (TextExtractor textExtractor = new TextExtractor("demo", "demo")) { // Load stream into TextExtractor textExtractor.LoadDocumentFromStream(searchablePDFStream); // Search email Addresses // See the complete regular expressions reference at https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx string regexPattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b"; // Enable RegexSearch textExtractor.RegexSearch = true; // Set word matching options textExtractor.WordMatchingMode = WordMatchingMode.None; ISearchResult[] searchResults = textExtractor.FindAll(0, regexPattern, caseSensitive: false); // Create Bytescout.PDFExtractor.Remover instance using (var remover = new Remover2("demo","demo")) { // Load sample PDF document remover.LoadDocumentFromStream(searchablePDFStream); // Mask removed text remover.MaskRemovedText = true; // Make output file unsearchable remover.MakePDFUnsearchable = true; // Provide text to remove remover.AddTextToRemove(searchResults); // Remove text objects find by SearchResults. remover.PerformRemoval("result1.pdf"); } } } // Open output file in default application System.Diagnostics.Process.Start("result1.pdf"); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Sensitive Data Suite Home Page

Explore ByteScout Sensitive Data Suite Documentation

Explore Samples

Sign Up for ByteScout Sensitive Data Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Sensitive Data Suite Home Page

Explore ByteScout Sensitive Data Suite Documentation

Explore Samples

Sign Up for ByteScout Sensitive Data Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

prev
next