Converting images to searchable PDFs
Image files can contain text that users can’t search or copy. OCR converts that text into a searchable layer while preserving the original visual content.
This guide shows how to:
- Convert an image to PDF
- Run OCR on the PDF
- Save a searchable PDF output
Project setup
Install:
- The core Nutrient Native SDK package
GdPicture.Resourcesfor 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 guide.
using GdPicture14;
LicenseManager licence = new LicenseManager();licence.RegisterKEY("");Set up document processing components
Use:
GdPictureDocumentConverterfor image-to-PDF conversionGdPicturePDFfor OCR processing
using GdPicturePDF pdf = new GdPicturePDF();using GdPictureDocumentConverter converter = new GdPictureDocumentConverter();Convert the image to PDF
Load the source image and create an intermediate PDF:
converter.LoadFromFile(@"input.png");converter.SaveAsPDF(@"output_intermediary.pdf");Apply OCR
Load the intermediate PDF and run OCR on all pages:
pdf.LoadFromFile(@"output_intermediary.pdf", true);pdf.OcrPages("*", 0, "eng", "", "", 200);OcrPages parameters:
"*"— Process all pages0— Default OCR mode"eng"— English OCR language"",""— No allowlist or denylist200— Processing DPI
Save the searchable PDF
Save the OCR result:
pdf.SaveToFile(@"output_with_ocr.pdf");The output preserves page appearance and adds searchable text.
Handle errors
Conversion and OCR methods return GdPictureStatus values. Use those values in your error handling path. For details, refer to the handling errors with .NET SDK guide.
Conclusion
This workflow converts an image into a searchable PDF by combining PDF conversion and OCR.