3

I have a pdf file OCRed probably with Adobe Professional and some additional edits that can't be reversed. I have an original pdf without OCRed or any other edits.

I now want to incorporate the OCRed text into the original copy.

  • are there any c/c++/Python libraries to accomplish this with my own code?
  • are there any applications (preferrably in Linux, but also accept those in Windows) having this implemented ready-to-go?
  • Tim, this site is about recommending software for specific tasks. Your question rather looks like asking for a tutorial, which is off-topic here. If you want to know how to programm that yourself, this is not the place (not sure whether Stack Overflow or programmers might be fitting, but you can check their resp. /help/on-topic page). If you're looking for some piece of software to do the job, some re-phrasing is needed. See What is required for a question to contain "enough information"? for a raw guide. – Izzy Sep 17 '14 at 8:35
  • I am asking recommendations of tools (libraries or software), not for tutorials. – Tim Sep 17 '14 at 12:39
  • OK, understood. I've edited your question a little to make that clearer (and to prevent others from struggling for the same details). – Izzy Sep 17 '14 at 13:03
  • This is what hOCR is for. DigitWiki has some introduction to basic concepts and tools. – Nemo Oct 8 '15 at 16:39
2

You mentioned wanting to use a library to implment this type of recognition in your own code. I would suggest using LEADTOOLS OCR, this is a commercial SDK for Optical Character Recognition. The LEADTOOLS OCR SDK is available for both C and C++. I put together a bare bones code snippet using the C libraries that will take in a bitmap and print out the text.

       BITMAPHANDLE bitmap = { 0 };
       L_OcrEngine ocrEngine = NULL;
       L_OcrPage ocrPage = NULL;
       L_OcrDocumentManager ocrDocumentManager = NULL;
       L_OcrDocument ocrDocument = NULL;
       L_OcrEngineManager_CreateEngine(L_OcrEngineType_Advantage, &ocrEngine);
       L_OcrEngine_Startup(ocrEngine, NULL, OCR_ADVANTAGE_RUNTIME_DIR);
       L_LoadBitmap("Path to Bitmap", &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL);
       L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL);
       L_OcrPage_AutoZone(ocrPage, NULL, NULL);
       retCode = L_OcrPage_Recognize(ocrPage, NULL, NULL);
       L_WCHAR* text = NULL;
       L_UINT textLength = 0;
       L_OcrPage_GetText(ocrPage, -1, &text, &textLength);
       printf("%ls", text);

You can alternatively save the results directly to PDF or supported document format:

L_OcrDocument ocrDocument = NULL;
L_OcrDocument_Save(ocrDocument, outputPath, DOCUMENTFORMAT_PDF, NULL, NULL);

You can find more code and information on their help site.

1

I use Microsoft OneNote as OCR tool. On Right click against an image It can copy the entire text in images and It also has the capability to search text with in image. It is free and accurate and runs on windows and support almost all image formats.

You can copy the text inside and paste it into a text document.

It can search the content with in PDF's.

I am not sure if it works in Ubuntu or not through Wine, as Microsoft Office is now available for Mac OS, OneNote will work on it.

Bonus point is that it supports multiple languages :) English, French, Spanish also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.