Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, November 18, 2016 2:58:20 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 218

Was thanked: 12 time(s) in 12 post(s)

Using LEADTOOLS v19 and the Annotations SDK alongside the OCR SDK, I have created a sample that allows the user to load and redact an image and then OCR and save out the output.

Here is some of the relevant code:

This method will burn the annotations to the image using the RenderOnImage method:

Code:

      private RasterImage BurnImage()
      {
         RasterImage image = imageViewer.Image;
         annAutomationManager.RenderingEngine.RenderOnImage(annAutomation.Container, image);
         annAutomation.Container.Children.Clear();
         return image;
      }


This method will OCR the image and save the results as a PDF with Image Over Text enabled in order to see the redaction in the output:

Code:
      private void DoOCR(RasterImage image, string fileName)
      {
         using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
         {
            ocrEngine.Startup(null, null, null, null);

            PdfDocumentOptions pdfOptions = ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
            pdfOptions.ImageOverText = true;
            ocrEngine.DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfOptions);

            using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
            {
               ocrDocument.Pages.AddPage(image, null);
               ocrDocument.Pages.Recognize(null);
               ocrDocument.Save(fileName, DocumentFormat.Pdf, null);
            }
         }
      }


File Attachment(s):
PDF Redaction OCR.zip (12kb) downloaded 149 time(s).
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.047 seconds.