IRONSOFTWAREHOME
USING IRONOCR

Receipt Scanning API: Extract Data from Receipts Using C# and IronOCR

Kannaopat Udonpant
Kannapat Udonpant
Updated: August 1, 2026

Receipt scanning APIs automate data extraction from receipts using OCR technology, significantly reducing manual entry errors and speeding up processing. This guide shows how to use IronOCR in C# to accurately extract vendor names, dates, items, prices, and totals from receipt images, with built-in image preprocessing and support for multiple formats.

Why Choose IronOCR for Receipt Scanning?

IronOCR is a flexible OCR library offering reliable text extraction from scanned documents, images, and PDFs. With advanced algorithms, computer vision, and machine learning models, IronOCR ensures high accuracy even in challenging scenarios. The library supports multiple languages and font styles, making it suitable for global applications. By incorporating IronOCR into your applications, you can automate data entry and text analysis, boosting productivity.

How Does IronOCR Extract Text from Receipt Images?

IronOCR retrieves text from documents, photographs, screenshots, and live camera feeds as JSON responses. Using sophisticated algorithms and machine learning, IronOCR analyzes image data, recognizes characters, and converts them into machine-readable text. The library uses Tesseract 5 technology enhanced with proprietary improvements for superior accuracy.

Why Is IronOCR Excellent for Receipt Processing?

IronOCR excels at handling low-quality scans, varying receipt formats, and different orientations. Built-in image preprocessing filters automatically improve image quality before processing, ensuring optimal results even from crumpled or faded receipts.

What Do I Need to Use IronOCR?

Before working with IronOCR, ensure these prerequisites are in place:

What Development Environments Are Supported?

  1. Development Environment: Install a suitable IDE like Visual Studio. IronOCR supports Windows, Linux, macOS, Azure, and AWS.

What Programming Skills Are Required?

  1. C# Knowledge: Basic C# understanding helps you modify code examples. IronOCR provides simple examples and API documentation.

Which Software Dependencies Are Necessary?

  1. IronOCR Installation: Install via NuGet Package Manager. Platform-specific dependencies may be required.

Is a License Key Required?

  1. License Key (Optional): Free trial available; production use requires a license.

How Do I Create a New Visual Studio Project for Receipt Scanning?

How Do I Start a New Project in Visual Studio?

Open Visual Studio and go to Files, then hover on New, and click on Project.

Visual Studio IDE with File menu expanded showing 'New > Project' option highlighted, and code editor displaying C# code for loading an Excel workbook New Project Image

Which Project Template Should I Choose?

Select Console Application and click Next. This template is ideal for learning IronOCR before implementing in web applications.

Visual Studio's 'Create a new project' dialog showing the Console Application template selected with platform options for Windows, Linux, and macOS Console Application

How Should I Name My Receipt Scanner Project?

Write your project name and location, then click Next. Choose a descriptive name like "ReceiptScannerAPI".

Visual Studio new project configuration screen for creating a Console Application named 'IronOCR' with C# selected and solution settings displayed Project Configuration

Which .NET Framework Version Should I Select?

Select .NET 5.0 or later for optimal compatibility, then click Create.

Visual Studio's 'Additional Information' dialog showing Console Application configuration with .NET 5.0 selected as the target framework and platform options for Linux, macOS, Windows, and Console Target Framework

How Do I Install IronOCR in My Project?

Two simple installation methods are available:

How Do I Use the NuGet Package Manager Method?

Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution

Visual Studio NuGet Package Manager settings dialog with package sources configuration, alongside a C# project structure in the solution explorer NuGet Package Manager

Search for IronOCR and install the package. For non-English receipts, install language-specific packages.

NuGet Package Manager in Visual Studio displaying installed IronOCR packages including the main library and language-specific OCR packages for Arabic, Hebrew, and Spanish IronOCR

How Do I Use Command Line Installation?

  1. Go to Tools > NuGet Package Manager > Package Manager Console

  2. Enter this command:

    PM > Install-Package IronOcr

    Visual Studio Package Manager Console window displaying the NuGet command 'PM> Install-Package IronOcr' being executed for a project named 'Create PDF' Package Manager Console

How Can I Quickly Extract Receipt Data with IronOCR?

Extract receipt data with just a few lines of code:

  1. 1Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. 2Copy and run this code snippet.

    using IronOcr;
    using System;
    
    var ocr = new IronTesseract();
    
    // Configure for receipt scanning
    ocr.Configuration.ReadBarCodes = true;
    ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% ";
    
    using (var input = new OcrInput(@"receipt.jpg"))
    {
        // Apply automatic image enhancement
        input.DeNoise();
        input.Deskew();
        input.EnhanceResolution(225);
        
        // Extract text from receipt
        var result = ocr.Read(input);
        
        // Display extracted text and confidence
        Console.WriteLine($"Extracted Text:\n{result.Text}");
        Console.WriteLine($"\nConfidence: {result.Confidence}%");
    }
    C#
  3. 3Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer

How Do I Extract Structured Data from Receipt Images?

IronOCR extracts line items, pricing, taxes, and totals from various document types. The library supports PDFs, multi-page TIFFs, and various image formats.

using IronOcr;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class ReceiptScanner
{
    static void Main()
    {
        var ocr = new IronTesseract();
        
        // Configure OCR for optimal receipt reading
        ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% ";
        ocr.Configuration.BlackListCharacters = "~`@#*_}{][|\\";
        ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
        
        // Load the image of the receipt
        using (var input = new OcrInput(@"r2.png"))
        {
            // Apply image enhancement filters
            input.Deskew(); // Fix image rotation
            input.EnhanceResolution(225); // Optimal DPI for receipts
            input.DeNoise(); // Remove background noise
            input.Sharpen(); // Improve text clarity
            
            // Perform OCR on the input image
            var result = ocr.Read(input);

            // Regular expression patterns to extract relevant details from the OCR result
            var descriptionPattern = @"\w+\s+(.*?)\s+(\d+\.\d+)\s+Units\s+(\d+\.\d+)\s+Tax15%\s+\$(\d+\.\d+)";
            var pricePattern = @"\$\d+(\.\d{2})?";
            var datePattern = @"\d{1,2}[/-]\d{1,2}[/-]\d{2,4}";
            
            // Variables to store extracted data
            var descriptions = new List<string>();
            var unitPrices = new List<decimal>();
            var taxes = new List<decimal>();
            var amounts = new List<decimal>();
            
            var lines = result.Text.Split('\n');
            foreach (var line in lines)
            {
                // Match each line against the description pattern
                var descriptionMatch = Regex.Match(line, descriptionPattern);
                if (descriptionMatch.Success)
                {
                    descriptions.Add(descriptionMatch.Groups[1].Value.Trim());
                    unitPrices.Add(decimal.Parse(descriptionMatch.Groups[2].Value));
                    
                    // Calculate tax and total amount for each item
                    var tax = unitPrices[unitPrices.Count - 1] * 0.15m;
                    taxes.Add(tax);
                    amounts.Add(unitPrices[unitPrices.Count - 1] + tax);
                }
                
                // Extract date if found
                var dateMatch = Regex.Match(line, datePattern);
                if (dateMatch.Success)
                {
                    Console.WriteLine($"Receipt Date: {dateMatch.Value}");
                }
            }
            
            // Output the extracted data
            for (int i = 0; i < descriptions.Count; i++)
            {
                Console.WriteLine($"Description: {descriptions[i]}");
                Console.WriteLine($"Quantity: 1.00 Units");
                Console.WriteLine($"Unit Price: ${unitPrices[i]:0.00}");
                Console.WriteLine($"Taxes: ${taxes[i]:0.00}");
                Console.WriteLine($"Amount: ${amounts[i]:0.00}");
                Console.WriteLine("-----------------------");
            }
            
            // Calculate and display totals
            var subtotal = unitPrices.Sum();
            var totalTax = taxes.Sum();
            var grandTotal = amounts.Sum();
            
            Console.WriteLine($"\nSubtotal: ${subtotal:0.00}");
            Console.WriteLine($"Total Tax: ${totalTax:0.00}");
            Console.WriteLine($"Grand Total: ${grandTotal:0.00}");
        }
    }
}

What Techniques Improve Receipt Scanning Accuracy?

Key techniques for accurate receipt scanning:

Visual Studio debug console displaying extracted invoice data from a PDF, showing items with descriptions, quantities, prices, taxes, and totals Output

How Do I Extract the Entire Receipt Content?

Extract complete receipt content with preserved formatting:

using IronOcr;
using System;
using System.Linq;

class WholeReceiptExtractor
{
    static void Main()
    {
        var ocr = new IronTesseract();
        
        // Configure for receipt scanning
        ocr.Configuration.ReadBarCodes = true; // Enable barcode detection
        ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; // Use latest engine
        ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Best accuracy
        
        using (var input = new OcrInput(@"r3.png"))
        {
            // Apply automatic image correction
            input.WithTitle("Receipt Scan");
            
            // Use computer vision to find text regions
            var textRegions = input.FindTextRegions();
            Console.WriteLine($"Found {textRegions.Count()} text regions");
            
            // Apply optimal filters for receipt processing
            input.ApplyOcrInputFilters();
            
            // Perform OCR on the entire receipt
            var result = ocr.Read(input);
            
            // Display extracted text
            Console.WriteLine("=== EXTRACTED RECEIPT TEXT ===");
            Console.WriteLine(result.Text);
            
            // Get detailed results
            Console.WriteLine($"\n=== OCR STATISTICS ===");
            Console.WriteLine($"OCR Confidence: {result.Confidence:F2}%");
            Console.WriteLine($"Pages Processed: {result.Pages.Length}");
            Console.WriteLine($"Paragraphs Found: {result.Paragraphs.Length}");
            Console.WriteLine($"Lines Detected: {result.Lines.Length}");
            Console.WriteLine($"Words Recognized: {result.Words.Length}");
            
            // Extract any barcodes found
            if (result.Barcodes.Any())
            {
                Console.WriteLine("\n=== BARCODES DETECTED ===");
                foreach(var barcode in result.Barcodes)
                {
                    Console.WriteLine($"Type: {barcode.Type}");
                    Console.WriteLine($"Value: {barcode.Value}");
                    Console.WriteLine($"Location: X={barcode.X}, Y={barcode.Y}");
                }
            }
            
            // Save as searchable PDF
            result.SaveAsSearchablePdf("receipt_searchable.pdf");
            Console.WriteLine("\nSearchable PDF saved as: receipt_searchable.pdf");
            
            // Export as hOCR for preservation
            result.SaveAsHocrFile("receipt_hocr.html");
            Console.WriteLine("hOCR file saved as: receipt_hocr.html");
        }
    }
}

Visual Studio debug console displaying extracted invoice data from a PDF, showing items with descriptions, quantities, prices, taxes, and totals Scan receipt API output

What Advanced Features Improve Receipt Scanning?

IronOCR offers several advanced features that significantly improve receipt scanning accuracy:

Which Languages Does IronOCR Support?

  1. Multi-Language Support: Process receipts in 125+ languages or multiple languages in one document.

Can IronOCR Read Barcodes on Receipts?

  1. Barcode Reading: Automatically detect and read barcodes and QR codes.

How Does Computer Vision Help Receipt Processing?

  1. Computer Vision: Use advanced text detection to locate text regions before OCR.

Can I Train Custom Models for Unique Receipt Formats?

  1. Custom Training: Train custom fonts for specialized receipt formats.

How Can I Improve Performance for Bulk Processing?

  1. Performance Optimization: Implement multithreading and async processing for bulk operations.
// Example: Async receipt processing for high-volume scenarios
using IronOcr;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO;

class BulkReceiptProcessor
{
    static async Task Main()
    {
        var ocr = new IronTesseract();
        
        // Configure for optimal performance
        ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
        ocr.Configuration.UseMultiThreading = true;
        ocr.Configuration.ProcessorCount = Environment.ProcessorCount;
        
        // Process multiple receipts asynchronously
        var receiptFiles = Directory.GetFiles(@"C:\Receipts\", "*.jpg");
        var tasks = new List<Task<OcrResult>>();
        
        foreach (var file in receiptFiles)
        {
            tasks.Add(ProcessReceiptAsync(ocr, file));
        }
        
        // Wait for all receipts to be processed
        var results = await Task.WhenAll(tasks);
        
        // Aggregate results
        decimal totalAmount = 0;
        foreach (var result in results)
        {
            // Extract total from each receipt
            var match = System.Text.RegularExpressions.Regex.Match(
                result.Text, @"Total:?\s*\$?(\d+\.\d{2})");
            
            if (match.Success && decimal.TryParse(match.Groups[1].Value, out var amount))
            {
                totalAmount += amount;
            }
        }
        
        Console.WriteLine($"Processed {results.Length} receipts");
        Console.WriteLine($"Combined total: ${totalAmount:F2}");
    }
    
    static async Task<OcrResult> ProcessReceiptAsync(IronTesseract ocr, string filePath)
    {
        using (var input = new OcrInput(filePath))
        {
            // Apply preprocessing
            input.DeNoise();
            input.Deskew();
            input.EnhanceResolution(200);
            
            // Process asynchronously
            return await ocr.ReadAsync(input);
        }
    }
}

How Do I Handle Common Receipt Scanning Challenges?

Receipt scanning presents unique challenges that IronOCR helps address:

How Do I Deal with Poor Quality Receipt Images?

  • Poor Quality Images: Use the Filter Wizard to automatically find optimal preprocessing settings.

What About Skewed or Rotated Receipts?

How Do I Process Faded or Low Contrast Receipts?

Can IronOCR Handle Crumpled or Damaged Receipts?

How Do I Manage Different Receipt Formats and Layouts?

Receipt formats vary widely between retailers. IronOCR provides flexible approaches:

using IronOcr;
using System;
using System.Collections.Generic;
using System.Linq;

class ReceiptLayoutHandler
{
    static void Main()
    {
        var ocr = new IronTesseract();
        
        // Configure for different receipt layouts
        ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
        ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
        
        using (var input = new OcrInput(@"complex_receipt.jpg"))
        {
            // Apply region-specific processing
            var cropRegion = new CropRectangle(x: 0, y: 100, width: 400, height: 800);
            input.AddImage(@"complex_receipt.jpg", cropRegion);
            
            // Process with confidence tracking
            var result = ocr.Read(input);
            
            // Parse using confidence scores
            var highConfidenceLines = result.Lines
                .Where(line => line.Confidence > 85)
                .Select(line => line.Text)
                .ToList();
            
            // Extract data with fallback strategies
            var total = ExtractTotal(highConfidenceLines) 
                        ?? ExtractTotalAlternative(result.Text);
            
            Console.WriteLine($"Receipt Total: {total}");
        }
    }
    
    static decimal? ExtractTotal(List<string> lines)
    {
        // Primary extraction method
        foreach (var line in lines)
        {
            if (line.Contains("TOTAL") && 
                System.Text.RegularExpressions.Regex.IsMatch(line, @"\d+\.\d{2}"))
            {
                var match = System.Text.RegularExpressions.Regex.Match(line, @"(\d+\.\d{2})");
                if (decimal.TryParse(match.Value, out var total))
                    return total;
            }
        }
        return null;
    }
    
    static decimal? ExtractTotalAlternative(string fullText)
    {
        // Fallback extraction method
        var pattern = @"(?:Total|TOTAL|Grand Total|Amount Due).*?(\d+\.\d{2})";
        var match = System.Text.RegularExpressions.Regex.Match(fullText, pattern);
        
        if (match.Success && decimal.TryParse(match.Groups[1].Value, out var total))
            return total;
            
        return null;
    }
}

What Key Takeaways Should I Remember About Receipt Scanning APIs?

Receipt scanning APIs like IronOCR offer reliable solutions for automating data extraction from receipts. By using advanced OCR technology, businesses can extract vendor names, purchase dates, itemized lists, prices, taxes, and totals automatically. With support for multiple languages, currencies, and barcode support, businesses can simplify receipt management, save time, and make data-driven decisions.

IronOCR provides the tools developers need for accurate and efficient text extraction, enabling task automation and improved efficiency. The library's complete feature set includes support for various document types and recent improvements like 98% memory reduction.

By meeting the prerequisites and integrating IronOCR, you can reveal automated receipt processing benefits. The library's documentation, examples, and troubleshooting guides ensure smooth implementation.

For more information, visit the licensing page or explore the C# Tesseract OCR tutorial.

Related Articles

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required