Invoice OCR .NET

The .NET OCR SDK supports the invoice API for extracting data from invoices.

Using this sample invoice below, we are going to illustrate how to extract the data that we want, using the OCR SDK.
sample invoice

Quick Start

using Mindee;
using Mindee.Input;
using Mindee.Product.Invoice;

string apiKey = "my-api-key";
string filePath = "/path/to/the/file.ext";

// Construct a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);

// Load an input source as a path string
// Other input types can be used, as mentioned in the docs
var inputSource = new LocalInputSource(filePath);

// Call the API and parse the input
var response = await mindeeClient
    .ParseAsync<InvoiceV4>(inputSource);

// Print a summary of all the predictions
// System.Console.WriteLine(response.Document.ToString());

// Print only the document-level predictions
System.Console.WriteLine(response.Document.Inference.Prediction.ToString());

Output:

:Locale: en; en; CAD;
:Document type: INVOICE
:Invoice number: 14
:Reference numbers: AD29094
:Invoice date: 2018-09-25
:Invoice due date: 2018-09-25
:Supplier name: TURNPIKE DESIGNS CO.
:Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
:Supplier company registrations:
:Supplier payment details:
:Customer name: JIRO DOI
:Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
:Customer company registrations:
:Taxes:
  +---------------+--------+----------+---------------+
  | Base          | Code   | Rate (%) | Amount        |
  +===============+========+==========+===============+
  |               |        | 8.00     | 193.20        |
  +---------------+--------+----------+---------------+
:Total net:
:Total tax: 193.20
:Total amount: 2608.20
:Line Items:
  +----------------------+---------+---------+----------+------------------+--------------------------------------+
  | Code                 | QTY     | Price   | Amount   | Tax (Rate)       | Description                          |
  +======================+=========+=========+==========+==================+======================================+
  |                      | 1.00    | 65.00   | 65.00    |                  | Platinum web hosting package Down... |
  +----------------------+---------+---------+----------+------------------+--------------------------------------+
  |                      | 3.00    | 2100.00 | 2100.00  |                  | 2 page website design Includes ba... |
  +----------------------+---------+---------+----------+------------------+--------------------------------------+
  |                      | 1.00    | 250.00  | 250.00   |                  | Mobile designs Includes responsiv... |
  +----------------------+---------+---------+----------+------------------+--------------------------------------+

Properties

Each properties of the object contains at a minimum the following attributes:

  • Value (string or double depending on the field type):
    Corresponds to the field value. Can be null if no value was extracted.
  • Confidence (a double):
    The confidence score of the field prediction.
  • Polygon (a List<List<double>>):
    Contains the relative vertices coordinates (points) of a polygon containing the field in the image.

Extracted Fields

Attributes that will be extracted from the document and available in the Invoice object:

Customer Information

  • CustomerName (StringField): Customer's name

  • CustomerAddress (StringField): Customer's postal address

  • CustomerCompanyRegistrations (List): Customer's company registration

Dates

Date fields:

  • contain the raw attribute, which is the textual representation found on the document.
  • have a value attribute which is the ISO 8601 representation of the date, regardless of the raw contents.

The following date fields are available:

  • Date: Date the invoice was issued

  • DueDate: Payment due date of the invoice.

Locale

Locale (Locale): Locale information.

  • Locale.Language (string): Language code in ISO 639-1 format as seen on the document.
    The following language codes are supported: ca, de, en, es, fr, it, nl and pt.

  • Locale.Currency (string): Currency code in ISO 4217 format as seen on the document.
    The following country codes are supported: CAD, CHF, GBP, EUR, USD.

  • Locale.Country (string): Country code in ISO 3166-1 alpha-2 format as seen on the document.
    The following country codes are supported: CA, CH, DE, ES, FR, GB, IT, NL, PT and US.

Reference numbers

  • ReferenceNumbers (List) : Represents a list of Reference numbers including PO number.

Supplier Information

SupplierCompanyRegistrations (List): List of detected supplier's company registration numbers. Each object in the list contains an extra attribute:

  • Type (string): Type of company registration number among: VAT NUMBER, SIRET, SIREN, NIF, CF, UID, STNR, HRA/HRB, TIN (includes EIN, FEIN, SSN, ATIN, PTIN, ITIN), RFC, BTW, ABN, UEN, CVR, ORGNR, INN, DPH, GSTIN, COMPANY REGISTRATION NUMBER (UK), KVK, DIC

  • Value (string): Value of the company identifier

  • SupplierName: Supplier name as written in the invoice (logo or supplier Info).

  • SupplierAddress: Supplier address as written in the invoice.

  • SupplierPaymentDetails (List): List of invoice's supplier payment details. Each object in the list contains extra attributes:

  • Iban (string)

  • Swift (string)

  • RoutingNumber (string)

  • AccountNumber (string)

Line items

LineItems (List): Line items details. Each object in the list contains :

  • ProductCode (string)
  • Description (string)
  • Quantity (double)
  • UnitPrice (double)
  • TotalAmount (double)
  • TaxRate (double)
  • TaxAmount (double)
  • Confidence (double)
  • PageId (double)
  • Polygon (List<List>)

Taxes

Taxes (List): Contains tax fields as seen on the receipt.

  • Value (double): The tax amount.
  • Code (string): The tax code (HST, GST... for Canadian; City Tax, State tax for US, etc..).
  • Rate (double): The tax rate.

Total Amounts

  • TotalAmount (AmountField): Total amount including taxes.

  • TotalNet (AmountField): Total amount excluding taxes.

 

Questions?

Join our Slack