---
title: "Android image to text conversion library | Nutrient"
canonical_url: "https://www.nutrient.io/guides/android/conversion/image-to-text/"
md_url: "https://www.nutrient.io/guides/android/conversion/image-to-text.md"
last_updated: "2026-06-09T10:26:34.428Z"
description: "Nutrient Android SDK supports extracting textual information from a scanned PDF. To do so, follow the steps below:."
---

# Convert images to text on Android

Nutrient Android SDK supports extracting textual information from a scanned PDF. To do so, follow the steps below:

- First, convert the image into a PDF file as described in the [image-to-PDF conversion guide](https://www.nutrient.io/guides/android/conversion/image-to-pdf.md).

- Next, perform [OCR](https://www.nutrient.io/guides/android/ocr/overview.md) on the PDF file so that the textual information is extracted out of the PDF. This process is described in detail in the [converting a scan into a searchable PDF](https://www.nutrient.io/guides/android/conversion/scan-to-searchable-pdf.md) guide.

- After performing [OCR](https://www.nutrient.io/guides/android/ocr/overview.md) on the document, retrieve the text, text blocks, words, or glyphs from the pages. [Here’s a detailed guide](https://www.nutrient.io/guides/android/features/text-extraction.md) explaining how to do that.

This entire process is explained with the sample code below:

### KOTLIN

```kotlin

// Convert the image to a PDF file.
val image: Bitmap =...
val outputFile: File =... // Writable file.
val imageSize = Size(image.width.toFloat(), image.height.toFloat())
val pageImage = PageImage(image, PagePosition.CENTER).apply { setJpegQuality(70) }
val newPage = NewPage.emptyPage(imageSize).withPageItem(pageImage).build()

val creationTask = PdfProcessorTask.newPage(newPage)
val disposable = PdfProcessor.processDocumentAsync(creationTask, outputFile).subscribe(
        { progress -> }, // onNext
        { throwable -> }, // onError
        {
            // Perform OCR on the file.
            val document = PdfDocumentLoader.openDocument(context, Uri.parse(outputFile.absolutePath))
            val ocrTask = PdfProcessorTask.fromDocument(document).performOcrOnPages((0 until document.pageCount).toSet(), OcrLanguage.ENGLISH)

            val ocrFile: File =... // Writable file.

            ocrDisposable = PdfProcessor.processDocumentAsync(ocrTask, ocrFile).subscribe(
                    { progress -> }, // onNext
                    { throwable -> }, // onError
                    {
                        // `onComplete`
                        val ocrDocument = PdfDocumentLoader.openDocument(context, Uri.parse(ocrFile.absolutePath))

                        // Retrieve text from the document.
                        val pageText = ocrDocument.getPageText(0)
                        Log.d("PSPDFKit OCR", pageText)
                    }
                )
        }
    )

```

### JAVA

```java

// Convert the image to a PDF file.
final Bitmap image =...
final File outputFile =... // Writable file.
final Size imageSize = new Size(image.getWidth(), image.getHeight());
final PageImage pageImage = new PageImage(image, PagePosition.CENTER);
pageImage.setJpegQuality(70);
final NewPage newPage = NewPage.emptyPage(imageSize).withPageItem(pageImage).build();

final PdfProcessorTask creationTask = PdfProcessorTask.newPage(newPage);
final Disposable disposable = PdfProcessor.processDocumentAsync(creationTask, outputFile).subscribe(
        progress -> { }, // onNext
        throwable -> { }, // onError
        () -> {
            // Perform OCR on the file.
            final PdfDocument document = PdfDocumentLoader.openDocument(context, Uri.parse(outputFile.getAbsolutePath()));
            final Set<Integer> pages = new HashSet();
            for (int i = 0; i < document.getPageCount(); i++) {
                pages.add(i);
            }

            final PdfProcessorTask ocrTask = PdfProcessorTask.fromDocument(document).performOcrOnPages(pages, OcrLanguage.ENGLISH);

            final File ocrFile =... // Writable file.

            ocrDisposable = PdfProcessor.processDocumentAsync(ocrTask, ocrFile).subscribe(
                    progress -> { }, // onNext
                    throwable -> { }, // onError
                    () -> {
                        // `onComplete`
                        final PdfDocument ocrDocument = PdfDocumentLoader.openDocument(context, Uri.parse(ocrFile.getAbsolutePath()));

                        // Retrieve text from the document.
                        final String pageText = ocrDocument.getPageText(0);
                        Log.d("PSPDFKit OCR", pageText);
                    }
                );
        }
    );

```
---

## Related pages

- [PDF conversion library for Android](/guides/android/conversion.md)
- [Converting HTML to PDFs on Android](/guides/android/generating-pdfs/generating-pdf-from-html.md)
- [Effortlessly convert images to PDF on Android](/guides/android/conversion/image-to-pdf.md)
- [Convert scanned documents to searchable PDFs on Android](/guides/android/conversion/scan-to-searchable-pdf.md)
- [MS Office converter for Android](/guides/android/features/office-conversion.md)
- [Convert PDFs to images on Android](/guides/android/conversion/pdf-to-image.md)

