---
title: "Converting an image to a searchable PDF in memory | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/ocr/usage/image-to-searchable-pdf-in-memory/"
md_url: "https://www.nutrient.io/guides/dotnet/ocr/usage/image-to-searchable-pdf-in-memory.md"
last_updated: "2026-05-28T01:45:39.254Z"
description: "How to convert an image to a searchable PDF in memory using Nutrient .NET SDK."
---

# Converting an image to a searchable PDF in memory

Images often contain text that users can’t search or copy. Converting those images to searchable PDFs adds an OCR text layer while preserving the original visual content.

This guide shows how to run the full workflow in memory:

- Load an image

- Convert it to PDF in a `MemoryStream`

- Run OCR on the in-memory PDF

- Save a searchable PDF

## Project setup

Install:

- The core Nutrient Native SDK package

- `GdPicture.Resources` for OCR language and recognition resources

## Prepare the project

Register the SDK license before running conversion or OCR operations. For setup details, refer to the [getting started with.NET SDK](https://www.nutrient.io/sdk/dotnet/getting-started.md) guide.

```csharp

using GdPicture14;

LicenseManager licence = new LicenseManager();
licence.RegisterKEY("");

```

## Set up document processors

Use these two SDK components:

- `GdPictureDocumentConverter` for image-to-PDF conversion

- `GdPicturePDF` for OCR and PDF output

```csharp

using GdPicturePDF pdf = new GdPicturePDF();
using GdPictureDocumentConverter converter = new GdPictureDocumentConverter();

```

## Process the image in memory

Load the image and write the intermediate PDF to a memory stream:

```csharp

converter.LoadFromFile(@"input.png");
using MemoryStream stream = new MemoryStream();
converter.SaveAsPDF(stream);

```

## Apply OCR and save output

Load the in-memory PDF, run OCR, and save the searchable result:

```csharp

pdf.LoadFromStream(stream);
pdf.OcrPages("*", 0, "eng", "", "", 200);
pdf.SaveToFile(@"output_with_ocr.pdf");

```

`OcrPages` parameters:

- `"*"` — Process all pages

- `0` — Default OCR mode

- `"eng"` — English OCR language

- `""`, `""` — No allowlist or denylist

- `200` — Processing DPI

## Handle errors

`LoadFromFile`, `SaveAsPDF`, `LoadFromStream`, and `OcrPages` return `GdPictureStatus` values. Use these values in your error handling flow. For details, refer to the [handling errors with.NET SDK](https://www.nutrient.io/guides/dotnet/best-practices.md#error-handling) guide.

## Conclusion

This workflow converts an image to a searchable PDF using in-memory processing and OCR.
---

## Related pages

- [Applying OCR to a PDF document](/guides/dotnet/ocr/usage/apply-ocr-to-pdf.md)
- [C# barcode recognition](/guides/dotnet/ocr/usage/barcode-recognition.md)
- [Converting images to searchable PDFs](/guides/dotnet/ocr/usage/image-to-searchable-pdf.md)
- [C# OCR scanning to searchable PDFs](/guides/dotnet/ocr/usage/ocr-scan.md)
- [OCR PDF in C#](/guides/dotnet/ocr/usage/pdf-to-searchable-pdf.md)
- [Reading multilingual text from images](/guides/dotnet/ocr/usage/read-text-from-image-multi-language.md)
- [Convert images into searchable PDF/A files in C#](/guides/dotnet/ocr/usage/pdfa-archiving.md)
- [Reading text from images](/guides/dotnet/ocr/usage/read-text-from-image.md)

