This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/extraction/key-value-pairs/read-kvp-data-from-image.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Read key-value pair data from an image

Key-value pair (KVP) extraction converts document images into structured data you can process in code.

Use this workflow when you need to:

  • Extract labeled fields from forms and templates
  • Reduce manual data entry from scanned documents
  • Prepare OCR output for downstream systems

Project setup

Install:

  • The core Nutrient Native SDK package
  • GdPicture.Resources for OCR and data extraction support

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;
using System.Text.RegularExpressions;
LicenseManager licence = new LicenseManager();
licence.RegisterKEY(""); // Set your license key

Create the extraction components

Create image and OCR instances:

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

Load and analyze the image

Load the source image, bind it to OCR, and run OCR:

int imageId = imaging.CreateGdPictureImageFromFile(@"input_kvp.png");
ocr.SetImage(imageId);
string ocrResultId = ocr.RunOCR(OCRSpecialContext.None);

Extract and post-process key-value data

Get KVP output and apply text cleanup:

string result = Regex.Replace(ocr.GetKeyValuePairsData(ocrResultId), "Accuracy: \\d*%", string.Empty).Replace("\r", "").Replace(" | ", " ");
string[] lines = result.Split('\n');

This produces line-based KVP output ready for parsing into storage or API payloads.

Data extraction capabilities

The SDK supports scenarios such as:

  • Label-value pairing from forms
  • Table-like layout extraction
  • Text normalization for cleaner output
  • Confidence-oriented OCR workflows

Conclusion

This workflow runs OCR-based KVP extraction on an image and returns structured text for automation workflows.