I have a lot of scans of documents in which spaces and indentation are important, and I am trying to find an OCR solution that would correctly process the formatting with an output of a .txt file. So far I have tried tesseract and google cloud vision (both work poorly with formatting) as well as abbyy Finereader (the best solution so far, the formatting is preserved with .docx and .rtf output but, but isn't for .txt files)

  • Are you looking for a library to create an application with this, or something end-user ready? Do you have a budget or are you looking for something available at no cost? Mar 26, 2021 at 13:49
  • All solutions are welcome. Mar 26, 2021 at 15:57
  • Welcome! Do you have an OS requirement? Mar 28, 2021 at 0:22
  • Preferably windows Mar 28, 2021 at 20:33

1 Answer 1


Disclaimer: I work for the company which creates these products.

If you're looking to develop a commercial product, the LEADTOOLS SDK can output to text with an option to insert spaces to try to retain the layout of the input page. https://www.leadtools.com/help/sdk/v21/dh/ft/textdocumentoptions.html

public static void WriteText(string inputFilename, string outputFilename)
 IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD);
 ocrEngine.Startup(null, null, null, null);

 using (IOcrDocument document = ocrEngine.DocumentManager.CreateDocument())
    IOcrPage page = document.Pages.AddPage(inputFilename, null);

    TextDocumentOptions options = ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Text) as TextDocumentOptions;
    options.Formatted = true;

    ocrEngine.DocumentWriterInstance.SetOptions(DocumentFormat.Text, options);

    document.Save(outputFilename, DocumentFormat.Text, null);


enter image description here In the above screenshot, the original TIFF laid out in columns can be seen in the background, with the exported text document displayed in notepad.

The toolkit is available for evaluation at http://www.leadtools.com

If you'd prefer something end-user ready, ePrint can also perform this conversion. https://eprintdriver.com/

  • 1
    Could you please edit your answer to add an example image (text with various indentations) and the OCR'd result?
    – Nicolas Raoul
    Apr 25, 2022 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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