I have a pile of printed out source code and need to convert it into ascii-files. I believe, I should be able to do this with OCR, however, as far as I can see, they don't preserve neither amount of spaces nor indentation. What are my options?

  • What OCR applications have you tried so far? And what specifically went wrong when you tried it? Such as multi-spaces became one space or of a variable length, or indents were not indented?
    – user3169
    Nov 20 '18 at 22:26
  • I have tried cuneiform, tesseract and ocrad. All failed to recognize the leading spaces. ocrad tried to parse the source code as though it consisted of two columns. tesseract was even too "clever" in that it tried to correct what it believed were misspellings. Nov 21 '18 at 6:05
  • How much are you willing to spend, or are you looking for a no-cost solution? Text recognition is one thing, formatting seems to be in the realm of more advanced (and costly) solutions. ABBYY Finereader does have a 30 day trial you might look into.
    – user3169
    Nov 21 '18 at 7:18
  • I tried to download the trial, but the website said that currenty, they're not offering it. Nov 21 '18 at 15:31
  • If you're open to creating your own program, our LEADTOOLS SDK has a free evaluation edition. I did a quick test on some monospace source code image using one of our OCR demo and saved the result as "formatted text" and it got most of the spaces right. Also, tech support is free, so if you run your own test and it doesn't give you satisfactory results, send some sample images to our support team and we will try to find a way to improve results. Nov 22 '18 at 18:20

Your Answer

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

Browse other questions tagged or ask your own question.