LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Apply Redaction Annotation to Image and then OCR and save output as redacted searchable PDF
#1
Posted
:
Friday, November 18, 2016 2:58:20 PM(UTC)
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);
}
}
}
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Apply Redaction Annotation to Image and then OCR and save output as redacted searchable PDF
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.