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

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.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest