Sending PDF for recognition

To extract a text from a scanned PDF, send a POST request to the https://api.aspose.cloud/v5.0/ocr/RecognizePdf Aspose.OCR Cloud REST API endpoint. To authorize the request, pass the access token in Authorization header (Bearer authentication).

The PDF file and recognition parameters are provided in JSON format in the request body.

{
  "image": "PDF as Base64 string",
  "settings": {
    "language": "English",
    "makeSkewCorrect": true,
    "rotate": 0,
    "makeBinarization": false,
    "makeContrastCorrection": true,
    "makeUpsampling": false,
    "makeSpellCheck": false,
    "dsrMode": "Regions",
    "dsrConfidence": "Default",
    "resultType": "Text"
  }
}

Providing an scanned PDF

The PDF file is provided in a value of image property as a Base64 encoded string.

Recognition settings

Property Type Default value Description
language string English Specify a language for recognition.
makeSkewCorrect boolean true Automatically correct page tilt (deskew) before proceeding to recognition.
Automatic deskew works for pages rotated 15 degrees or less. If the page is rotated by a larger degree or upside down, you must manually specify the rotation angle.
rotate integer 0 Rotate a page by the specified degree.
Should be used when the page is rotated at a significant angle, such as landscape or upside down.
makeBinarization boolean false Automatically convert page content to black and white before proceeding to recognition.
makeContrastCorrection boolean true Automatically increase the contrast of images on a page before proceeding to recognition.
makeUpsampling boolean false Intellectually upscale page content to improve small font recognition and detection of dense lines.
makeSpellCheck boolean false Automatically replace commonly misspelled words in recognition results with the correct ones. The dictionary is based on the selected recognition language.
dsrMode string Regions Document structure analysis algorithm.
dsrConfidence string Default Threshold for filtering content blocks detected by the selected structure analysis algorithm.
resultType string Text Recognition result format.

Return value

If successful, this method returns a string with a unique identifier (GUID) of the PDF recognition request in the queue.

Otherwise, it returns a HTTP status code corresponding to the error.

What’s next

Recognition will take a few seconds, depending on the size of the PDF document and the current Aspose.Cloud load. See the article Fetching PDF recognition result for information on how to get a recognition result from the server.

cURL example