Skip to content

janluksoft/Azure_AI_InvoiceRead

Repository files navigation

Azure Document Intelligence — Invoice Reader (.NET)

🔹 What is Azure.AI.DocumentIntelligence?

Azure Document Intelligence (formerly "Form Recognizer") is part of Microsoft's Azure AI services. It uses machine learning to:

  • Automatically extract structured data from unstructured documents.
  • Understand documents like invoices, receipts, contracts, ID cards, and more.
  • Work with both English and non-English content (e.g., Polish).
  • Use prebuilt models (like prebuilt-invoice) or custom-trained models.

It supports various input formats:

  • JPEG, PNG, PDF, TIFF, or document URLs.
  • REST API, SDKs (.NET, Python, etc.), and Azure Studio (GUI).

🔹 Document Intelligence in action

The analysis can be performed both in the Azure portal and from the .NET application side.

🔹 Project Overview

This C# program reads scanned invoice files (e.g., .jpg) and extracts key invoice data using Azure Document Intelligence.

✔️ Features

  • Uses the prebuilt-invoice model from Azure.
  • Accepts both local files and web URLs as input.
  • Extracts vendor, buyer, invoice number, dates, tax info, and line items.
  • Outputs a clean, readable invoice summary to the console.
  • Uses free-tier (F0) plan – 500 free transactions/month.

🔹 How It Works

  1. Configuration
    The program reads Azure endpoint, key, and file path from json config files (appsettings.json, aiset.json).

  2. Connecting to Azure
    It authenticates using AzureKeyCredential and creates a DocumentIntelligenceClient.

  3. Sending Invoice for Analysis
    The file is uploaded as a BinaryData stream, and analyzed with the AnalyzeDocumentAsync method.

  1. Processing Results
    Extracted fields like:

    • Invoice Number, Date, Due Date
    • Vendor and Buyer names, NIP (VAT)
    • Items (description, quantity, tax, amount)
    • Totals: Subtotal, Tax, and Total
  2. Console Output
    A formatted summary is printed in a readable, structured way.


🔹 Sample Output


===== INVOICE SUMMARY =====

Invoice Number : 001437/07/18
Invoice Date   : 2018-07-14
Due Date       : 2018-07-20
Payment Term   : Przelew 5 dni
IBAN           : 31 1522 6409 0000 0008 5552 7782

-- Seller --
Name    : Computer CORE
Company : Media Computer CORE sp. j.
Address : 26-314 Radom, ul. Mickiewicza 16
NIP     : 555-111-99-22

-- Buyer --
Name    : CD TAPE Ryszard Morowski
Company : CD TAPE Ryszard Morowski
Address : 01-574 Warszawa ul. Marszałkowska 15/17
NIP     : 555-111-44-77

-- Items --
---|----------------------|----------|-----------|--------|---------|----------|
   | Description          |UnitPrice | Quantity  |TaxRate |    Tax  |   Amount |
   |                      |    [PLN] |     unit  |  [%]   |   [PLN] |    [PLN] |
---|----------------------|----------|-----------|--------|---------|----------|
 1 | SBS Cable USB A      |    41,50 |   12 szt. |    23% |  114,54 |   612,54 |
 2 | HP-2360 Printer      |   455,00 |    4 szt. |    23% |  418,60 |  2238,60 |
 3 | Mouse Pad XDS        |    11,84 |    1 szt. |    23% |    2,72 |    14,56 |
 4 | Ink Printer 10XL     |    82,00 |    5 szt. |    23% |   94,30 |   504,30 |

-- Summary --
    Subtotal : 2739,84 PLN
    Tax      : 630,16 PLN
    Total    : 3370 PLN

About

Azure Document Intelligence - Invoice Reader (.NET)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages