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.
Quick Start
// Load a file from disk and parse it
string path = "./a74eaa5-c8e283b-sample_invoice.jpeg";
var prediction = await _mindeeClient
.LoadDocument(File.OpenRead(Path), System.IO.Path.GetFileName(Path))
.ParseAsync<InvoiceV4Prediction>();
// Print a summary of the parsed data
System.Console.WriteLine(prediction.Inference.Prediction.ToString());
Output:
----- Invoice V4 -----
Locale: fr; fr; EUR;
Invoice number: 0042004801351
Reference numbers: AD29094
Invoice date: 2020-02-17
Invoice due date: 2020-02-17
Supplier name: TURNPIKE DESIGNS CO.
Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
Supplier company registrations: 501124705; FR33501124705
Supplier payment details: FR7640254025476501124705368;
Customer name: JIRO DOI
Customer company registrations: FR00000000000; 111222333
Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
Line Items:
Code | QTY | Price | Amount | Tax (Rate) | Description
| | | 4.31 | (2.1 %) | PQ20 ETIQ ULTRA RESIS METAXXDC
| 1.0 | 65.0 | 75.0 | 10.0 | Platinum web hosting package Dow...
XXX81125600010 | 1.0 | 250.01 | 275.51 | 25.5 (10.2 %) | a long string describing the ite...
ABC456 | 200.3 | 8.101 | 1622.63 | 121.7 (7.5 %) | Liquid perfection
| | | | | CARTOUCHE L NR BROTHER TN247BK
Taxes: 97.98 20.0%
Total taxes: 97.98
Total amount excluding taxes: 489.97
Total amount including taxes: 587.95
----------------------
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 benull
if no value was extracted.Confidence
(adouble
):
The confidence score of the field prediction.Polygon
(aList<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
- Dates
- Locale and Currency
- Reference numbers
- Supplier Information
- Line items
- Taxes
- Total Amounts
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 theraw
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
andpt
. -
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
andUS
.
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
Updated 3 months ago