🟦 HOWTO: OCR Images and PDFs using Google Docs

Image with text
lorem

OCR output
googleocroutput2

This guide, which was lost for a couple of years, has been revived and updated. provides for the optical character recognition of text on images (also from device camera) and in pdfs, using a google web app and google docs.

OCR Images and PDFs using Google Docs

8 Likes

Hello everybody,

I found this guide about OCR Images and PDFs using Google Docs very interesting, so I decided to give it a try and I set everything as per the indications.
Unfortunately, as I run App Inventor demo app, I get the following error:

ERROR with OCR: TypeError: Drive.Files.insert is not a function

The script is well addressed by AI app (I can see the file to be processed that is properly created in my Google Drive), but the creation of the second file for OCR analysis fails, returning the error above.
I browsed on Internet about such error, but I did not find any useful suggestion.

Thanks in advance to anybody for any kind of support.

Did you add the Drive API to your script project ?

I did it, following thoroughly the indications in the guide.

Are you testing with companion app or with a compiled app ?

What device and android version are you testing with ?

(This guide was written nearly five years ago, so things may have changed...)

I have just tested the example aia provided in the HOWTO, and apart from the permission request (which is out of date) the OCR process works fine for the three files in the assets. This test was on a Pixel 8, Android 13, on my Genymotion Emulator.

Compiled app, Huawei Mate 10 Pro, EMUI 12, Android 10/11.
I tried on another device (Realme GT 6, Android 14), after adjusting file permission request: same problem.
I suspect the inconvenience lies on Google App Script web app side and it is due to some settings of my script project, but I have no idea where to put my hands... The only setting to change is Drive API version, from v3 to v2... I will try and let you know.
Thanks in the meanwhile for your kind help.

Try the example aia.

Just working on aia project example.
I just tried by setting Drive API version to v2 in web app script project: it works!
Thanks a lot, TIMAI2!

1 Like

I will need to have a look at V3 and see what the differences are.

The only differences I can see from HERE are with insert, which may need to become create or update.

I have updated the guide, advising use of Version 2.