New Tool Radar

AI PDF

How to OCR a Scanned PDF with Google Cloud Vision

OCR a scanned PDF with Google Cloud Vision document text detection and read the structured result.

Schematic illustration of Google Vision OCR: upload the PDF to Cloud Storage, request document text detection, and read the JSON output.

Google Cloud Vision reads PDF and TIFF files with DOCUMENT_TEXT_DETECTION, a mode built for dense document text and handwriting. PDF detection runs as an asynchronous job: the file must sit in Cloud Storage and the result is written back there as JSON. This guide runs it on one scanned PDF and checks the result.

Prerequisites

A Google Cloud project with the Vision API enabled, a service account with storage access, and a scanned PDF in a Cloud Storage bucket. Keep credentials out of shared files.

Steps

1. Upload the scanned PDF to Cloud Storage

Upload the PDF to a bucket the service account can read. Expected result: the file is listed in the bucket.

2. Request document text detection

Send a files:asyncBatchAnnotate request with DOCUMENT_TEXT_DETECTION and an output bucket. Expected result: an operation name is returned.

3. Wait for the operation and read the JSON output

Poll the operation until it is done, then open the output JSON file. Expected result: the JSON holds the full text with pages, blocks, paragraphs and words.

4. Check a known word in the output

Search the JSON for the word harvest. Expected result: the word appears on page 1 with its bounding box.

Practice check: fictional two-page scan of a letter, word harvest on page 1

The table below is fictional practice material. It lists the four checks for the Vision API result.

Check Expected result
File in bucket PDF listed in bucket
Operation returned Operation name present
JSON output written Output file in bucket
Word found harvest on page 1

Expected result. the PDF is uploaded, the operation completes, the JSON output is written, and the word harvest is found on page 1 with its bounding box.

Limits

  • Vision PDF detection only accepts files up to 2000 pages and only from Cloud Storage, so a local file must be uploaded first; the document also leaves your machine.
  • UNTESTED – no OCR tool or AI tool was run; all results above are expected results. The practice file is fictional.

Sources

See all