Reading text from images
This guide demonstrates how to extract text from an image using OCR.
Use this workflow when you need to:
- Convert image-based text into editable text output
- Index scanned content for search
- Feed OCR output into validation or automation pipelines
Project setup
Install:
- The core Nutrient Native SDK package
GdPicture.Resourcesfor OCR language resources
Prepare the project
Register the SDK license before running OCR operations. For setup details, refer to the getting started with .NET SDK guide.
using GdPicture14;
LicenseManager licence = new LicenseManager();licence.RegisterKEY(""); // Set your license keyLoad and prepare the image
Create imaging and OCR instances, load the source image, and set it for OCR:
using GdPictureImaging imaging = new GdPictureImaging();using GdPictureOCR ocr = new GdPictureOCR();
// Load the image containing text to be extractedint imageId = imaging.CreateGdPictureImageFromFile(@"input.png");
// Apply the image to the OCR engine for processingocr.SetImage(imageId);Run text recognition
Execute OCR and read the recognized text result:
// Run OCR analysis to identify and extract textstring ocrResultId = ocr.RunOCR(OCRSpecialContext.None);
// Retrieve the recognized text contentstring result = ocr.GetOCRResultText(ocrResultId);Save extracted text
Write OCR output to a text file:
// Save the extracted text to a fileFile.WriteAllText(@"output.txt", result);Additional OCR options
Extend this workflow with:
- Language-specific OCR configuration for targeted recognition
- Confidence-based review logic
- Region-based OCR for specific image areas
- Layout-aware post-processing for structured documents
Conclusion
This workflow extracts text from an image and saves it as plain text for downstream processing.