1

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?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Are you making an online processing request or a batch processing request? Can you provide a sample of your input file? You can refer to this [tutorial](https://codelabs.developers.google.com/codelabs/docai-ocr-python#8) using batch to add output to gcs bucket. – Prajna Rai T Feb 02 '23 at 13:07

1 Answers1

0

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.

https://cloud.google.com/document-ai/docs/handle-response#basic_text

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.

Holt Skinner
  • 1,692
  • 1
  • 8
  • 21