LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Minimum OCR demo using .NET Standard
#1
Posted
:
Monday, November 20, 2017 2:34:19 PM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
This Visual Studio 2017 console project uses LEADTOOLS v20 Leadtools.Ocr.NETStandard nuget package to illustrate the minimum code required to OCR single page or multi-page files and save it as a plain text (TXT), Portable Document Format (PDF), or LEAD Temporary Document file (LTD).
The demo uses command line arguments to set the input file, output file, and output document type. Here are example argument lists:
-i "C:\Users\Public\Documents\LEADTOOLS Images\Leadtools.pdf" -o "D:\junk folder\Leadtools.pdf.txt" -f TXT
-i "C:\Users\Public\Documents\LEADTOOLS Images\OCR1.TIF" -o "C:\OCR1.pdf" -f PDF
The core OCR code can be summed up in a few lines:
Code:
codecs.Options.Load.AllPages = true;
image = codecs.Load(inputFile);
ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false);
ocrEngine.Startup(codecs, null, null, OCR_ENGINE_PATH);
ocrDocument = ocrEngine.DocumentManager.CreateDocument();
ocrDocument.Pages.AddPages(image, 1, image.PageCount, null);
foreach (Leadtools.Ocr.IOcrPage page in ocrDocument.Pages)
page.Recognize(null);
ocrDocument.Save(outputFile, format, null);
Before running this demo, please verify the DEVELOPER_LIC and DEVELOPER_KEY file paths exist and change the application arguments if desired.
Edited by moderator Friday, February 8, 2019 8:12:22 AM(UTC)
| Reason: Not specified
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Minimum OCR demo using .NET Standard
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.