Read Printed and Handwritten Text

Learn to read text from images and PDFs using OCR.

Read printed and handwritten text

Using the OCR service, we can read the visible text in an image and convert it to a character stream. There are two steps to successfully using the OCR service:

  1. Call the Read API
  2. Get the read results

Let’s see both in detail.

Call the Read API

First, we’ll call the API with the image URL. We will use the read method as follows:

read(read_image_url, language = None, pages = None, raw=True)

It will start an asynchronous process to read the image and will return an operation ID.

Other than the image URL, we can also specify the following parameters:

Name Description
language (optional): There are a lot of languages you can use. Supported languages for handwritten and print text are different. See the Language Support page of the documentation for a list of supported languages.
pages (optional): This option is only used for multi-page PDF and TIFF documents.

Accepted inputs for pages include:

  • Single pages: 1, 2 will process pages 1 and 2.
  • Finite: 2-5 will process pages from 2 to 5.
  • Open-ended ranges: 5- will process all the pages beginning from page 5. Similarly, -10 will process pages from 1 to 10.

The code for the read method is on lines 13–16 in the code below.

Get hands-on with 1200+ tech skills courses.