---
title: "Read key-value pair data from an image"
canonical_url: "https://www.nutrient.io/guides/dotnet/extraction/key-value-pairs/read-kvp-data-from-image/"
md_url: "https://www.nutrient.io/guides/dotnet/extraction/key-value-pairs/read-kvp-data-from-image.md"
last_updated: "2026-05-21T17:12:02.203Z"
description: "Extract structured key-value pair data from images using OCR in Nutrient .NET SDK."
---

# Read key-value pair data from an image

Key-value pair extraction addresses a critical challenge in modern business operations where organizations must transform unstructured document images into actionable, structured data for automated processing workflows. This capability proves essential for businesses processing high volumes of forms, invoices, surveys, applications, and other structured documents that contain paired information requiring systematic extraction and digital transformation.

Traditional manual data entry from document images creates significant operational bottlenecks, introduces human error, and prevents organizations from achieving the processing speeds required for competitive advantage. The ability to automatically identify and extract key-value relationships from document images enables businesses to transform paper-based workflows into efficient digital processes that improve accuracy, reduce costs, and accelerate document processing cycles.

From insurance companies processing claims forms to government agencies handling permit applications, healthcare organizations managing patient intake documents, and financial institutions processing loan applications, automated key-value pair extraction enables organizations to unlock the structured data contained within document images while maintaining the speed and accuracy requirements of modern business operations.

## Project Setup

This sample requires the core Nutrient Native SDK package plus the `GdPicture.Resources` package for data extraction functionality. The additional package contains specialized pattern recognition models, text analysis components necessary for key-value pair extraction operations.

## Preparing the project

The first step involves initializing the SDK by registering the license. This needs to be done only once during the application's lifetime and must occur before executing any OCR operations (see [Getting Started with.NET SDK](https://www.nutrient.io/sdk/dotnet/getting-started.md?product=gdpicture&framework=dotnet#importing-nutrient-net-sdk-to-your-application) for more details.)

```csharp

using GdPicture14;
using System.Text.RegularExpressions;

LicenseManager licence = new LicenseManager();
licence.RegisterKEY(""); // Set your license key

```

The `LicenseManager` class handles SDK authentication and enables access to the advanced key-value pair extraction functionality. Proper license registration ensures that the OCR processor can access specialized pattern recognition algorithms, intelligent data pairing capabilities, and structured output generation features required for professional document processing workflows.

## Creating the data extraction system

The extraction process begins by instantiating both the imaging system for handling document images and the OCR engine configured for intelligent data structure recognition.

```csharp

using GdPictureImaging imaging = new GdPictureImaging();
using GdPictureOCR ocr = new GdPictureOCR();

```

The `GdPictureImaging` class provides comprehensive image handling capabilities with automatic resource management through the `using` statement, while the `GdPictureOCR` class delivers sophisticated optical character recognition functionality specifically designed for structured data extraction. These components work together to manage the entire data extraction pipeline, from image preprocessing and content analysis to pattern recognition and structured output generation.

The OCR engine automatically handles complex document layouts including multi-column forms, table structures, mixed text orientations, and various formatting styles, preparing for accurate identification and extraction of key-value relationships regardless of the document's visual complexity or layout variations.

## Loading and analyzing the source document

The data extraction process requires loading the source document image and configuring the OCR engine to identify and analyze structured content patterns.

```csharp

int imageId = imaging.CreateGdPictureImageFromFile(@"input_kvp.png");

ocr.SetImage(imageId);

string ocrResultId = ocr.RunOCR(OCRSpecialContext.None);

```

The `CreateGdPictureImageFromFile` method loads the document image into memory and assigns a unique identifier for subsequent processing operations. The SDK automatically detects the image format and applies appropriate preprocessing optimizations for structured data recognition, including contrast enhancement, noise reduction, and layout analysis to maximize extraction accuracy.

The `SetImage` method associates the loaded image with the OCR engine, while the `RunOCR` method executes comprehensive document analysis including text recognition, spatial relationship analysis, pattern identification for key-value pairs, and content structure mapping. This process identifies potential data fields, labels, and their corresponding values throughout the document structure.

## Extracting and processing key-value pairs

The core extraction operation identifies key-value relationships within the document and formats the output into structured, usable data while applying intelligent filtering and formatting rules.

```csharp

string result = Regex.Replace(ocr.GetKeyValuePairsData(ocrResultId), "Accuracy: \\d*%", string.Empty).Replace("\r", "").Replace(" | ", " ");

string[] lines = result.Split('\n');

```

The `GetKeyValuePairsData` method executes sophisticated analysis algorithms that identify spatial relationships between text elements, recognize common form patterns and field structures, extract paired information using intelligent pattern matching, apply data validation and confidence scoring, and generate structured output that preserves the logical relationships between keys and their corresponding values.

The post-processing operations clean and format the extracted data by removing OCR confidence indicators, normalizing whitespace and formatting characters, and organizing the output into structured lines for further processing. This ensures that the extracted key-value pairs are ready for database insertion, API consumption, or integration with downstream business systems.

The key-value pair extraction is complete, delivering structured, actionable data that transforms unstructured document images into organized information ready for automated processing, database storage, and integration with modern business workflows.

## Data Extraction Features

The SDK provides intelligent recognition of structured data patterns:

- **Automatic Pairing**: Identifies relationships between labels and values

- **Format Recognition**: Handles various form layouts and structures

- **Text Normalization**: Cleans and standardizes extracted text

- **Multi-Language Support**: Processes documents in multiple languages

- **Field Validation**: Provides confidence scoring for extracted data

- **Layout Awareness**: Understands spatial relationships in documents

## Processing Capabilities

- **Form Field Detection**: Automatically identifies input fields and labels

- **Table Processing**: Extracts data from structured tables and grids

- **Checkbox Recognition**: Detects selected options in forms

- **Signature Areas**: Identifies signature fields and handwritten content

- **Date Processing**: Recognizes and formats date fields consistently

- **Numeric Data**: Handles currency, percentages, and numerical values

## Key Features

- **High Accuracy**: Advanced OCR technology ensures reliable data extraction

- **Structured Output**: Returns organized key-value pairs ready for database insertion

- **Batch Processing**: Process multiple documents efficiently for high-volume operations

- **Quality Control**: Confidence scoring helps identify uncertain extractions

- **Format Flexibility**: Handles various document types and layouts

## Technical Benefits

- Memory-efficient processing suitable for large document volumes

- Integration-ready JSON or structured text output

- Customizable post-processing for specific business requirements

- Error handling and validation for production workflows

- Support for various image formats and quality levels

This implementation provides the foundation for automated document processing systems, transforming manual data entry into efficient digital workflows that improve accuracy and reduce processing time.

---

## Related pages

- [Key-value pair extraction data types](/guides/dotnet/extraction/key-value-pairs/data-types.md)
- [Understand confidence scores in KVP extraction](/guides/dotnet/extraction/key-value-pairs/confidence-score.md)
- [How key-value pair extraction works](/guides/dotnet/extraction/key-value-pairs.md)
- [Key-value pair extraction methods](/guides/dotnet/extraction/key-value-pairs/data-model.md)
- [Extract key-value pairs with our .NET SDK](/guides/dotnet/extraction/key-value-pairs/kvp-overview.md)

