Convert images to text using JavaScript
You can convert images to text with Nutrient Web SDK.
![]()
Converting images to text is available when using the Web SDK with Document Engine in server-backed operational mode.
First, make sure to open the image from Document Engine.
![]()
This feature requires the Image Documents component to be enabled in your license.
Next, detect the text in the image by running the performOcr
operation:
await instance.applyOperations([ { type: "performOcr", language: "english", pageIndexes: "all" } ]);
![]()
This feature requires the OCR component to be enabled in your license.
Then you can extract the text using the PSPDFKit.Instance#textLinesForPageIndex
method:
const textLines = await instance.textLineForPageIndex(0);
To log all text in the image on the console, you can then run:
textLines.forEach((l) => console.log(l.contents));
Other languages
You can extract text written in languages other than English using the language
parameter:
await instance.applyOperations([ { type: "performOcr", language: "spanish", pageIndexes: "all" } ]);
Nutrient Web SDK supports the following languages:
-
Croatian
-
Czech
-
Danish
-
Dutch
-
English
-
Finnish
-
French
-
German
-
Indonesian
-
Italian
-
Malay
-
Norwegian
-
Polish
-
Portuguese
-
Serbian
-
Slovak
-
Slovenian
-
Spanish
-
Swedish
-
Turkish
-
Welsh