How to Process JSON response of Google Document AI OCR Api to proper structure?

I want to make proper structured txt file out of scanned pdf file in Google document ai ocr response, but I get a json response from the document. An ocr response which contains all text of file in one string and X,Y coordinates of pdf file image along with indexes of blocks or tokens for that string. I am not able to map that text on received coordinates to make a txt file or some other format file.

How can I save this as a txt file?

1

1 Answer

This page in the documentation shows how to handle the processing response, including extracting the raw text from the document, which can be loaded into a TXT file. It also explains the structure of the Document.json output.

EDIT: New tool/sdk available

You can also use the Document AI Toolbox SDK for more utility/post processing functions to make some of this handling easier.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like