@@ -644,15 +644,9 @@ AzureKeyCredential credential = new AzureKeyCredential(key);
644
644
DocumentIntelligenceClient client = new DocumentIntelligenceClient (new Uri (endpoint ), credential );
645
645
646
646
// sample invoice document
647
+ Uri uriSource = new Uri (" https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-invoice.pdf" );
647
648
648
- Uri invoiceUri = new Uri (" https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-invoice.pdf" );
649
-
650
- AnalyzeDocumentContent content = new AnalyzeDocumentContent ()
651
- {
652
- UrlSource = invoiceUri
653
- };
654
-
655
- Operation < AnalyzeResult > operation = await client .AnalyzeDocumentAsync (WaitUntil .Completed , " prebuilt-invoice" , content );
649
+ Operation < AnalyzeResult > operation = await client .AnalyzeDocumentAsync (WaitUntil .Completed , " prebuilt-invoice" , uriSource );
656
650
657
651
AnalyzeResult result = operation .Value ;
658
652
@@ -663,39 +657,39 @@ for (int i = 0; i < result.Documents.Count; i++)
663
657
AnalyzedDocument document = result .Documents [i ];
664
658
665
659
if (document .Fields .TryGetValue (" VendorName" , out DocumentField vendorNameField )
666
- && vendorNameField .Type == DocumentFieldType .String )
660
+ && vendorNameField .FieldType == DocumentFieldType .String )
667
661
{
668
662
string vendorName = vendorNameField .ValueString ;
669
663
Console .WriteLine ($" Vendor Name: '{vendorName }', with confidence {vendorNameField .Confidence }" );
670
664
}
671
665
672
666
if (document .Fields .TryGetValue (" CustomerName" , out DocumentField customerNameField )
673
- && customerNameField .Type == DocumentFieldType .String )
667
+ && customerNameField .FieldType == DocumentFieldType .String )
674
668
{
675
669
string customerName = customerNameField .ValueString ;
676
670
Console .WriteLine ($" Customer Name: '{customerName }', with confidence {customerNameField .Confidence }" );
677
671
}
678
672
679
673
if (document .Fields .TryGetValue (" Items" , out DocumentField itemsField )
680
- && itemsField .Type == DocumentFieldType .List )
674
+ && itemsField .FieldType == DocumentFieldType .List )
681
675
{
682
676
foreach (DocumentField itemField in itemsField .ValueList )
683
677
{
684
678
Console .WriteLine (" Item:" );
685
679
686
- if (itemField .Type == DocumentFieldType .Dictionary )
680
+ if (itemField .FieldType == DocumentFieldType .Dictionary )
687
681
{
688
682
IReadOnlyDictionary < string , DocumentField > itemFields = itemField .ValueDictionary ;
689
683
690
684
if (itemFields .TryGetValue (" Description" , out DocumentField itemDescriptionField )
691
- && itemDescriptionField .Type == DocumentFieldType .String )
685
+ && itemDescriptionField .FieldType == DocumentFieldType .String )
692
686
{
693
687
string itemDescription = itemDescriptionField .ValueString ;
694
688
Console .WriteLine ($" Description: '{itemDescription }', with confidence {itemDescriptionField .Confidence }" );
695
689
}
696
690
697
691
if (itemFields .TryGetValue (" Amount" , out DocumentField itemAmountField )
698
- && itemAmountField .Type == DocumentFieldType .Currency )
692
+ && itemAmountField .FieldType == DocumentFieldType .Currency )
699
693
{
700
694
CurrencyValue itemAmount = itemAmountField .ValueCurrency ;
701
695
Console .WriteLine ($" Amount: '{itemAmount .CurrencySymbol }{itemAmount .Amount }', with confidence {itemAmountField .Confidence }" );
@@ -705,27 +699,26 @@ for (int i = 0; i < result.Documents.Count; i++)
705
699
}
706
700
707
701
if (document .Fields .TryGetValue (" SubTotal" , out DocumentField subTotalField )
708
- && subTotalField .Type == DocumentFieldType .Currency )
702
+ && subTotalField .FieldType == DocumentFieldType .Currency )
709
703
{
710
704
CurrencyValue subTotal = subTotalField .ValueCurrency ;
711
705
Console .WriteLine ($" Sub Total: '{subTotal .CurrencySymbol }{subTotal .Amount }', with confidence {subTotalField .Confidence }" );
712
706
}
713
707
714
708
if (document .Fields .TryGetValue (" TotalTax" , out DocumentField totalTaxField )
715
- && totalTaxField .Type == DocumentFieldType .Currency )
709
+ && totalTaxField .FieldType == DocumentFieldType .Currency )
716
710
{
717
711
CurrencyValue totalTax = totalTaxField .ValueCurrency ;
718
712
Console .WriteLine ($" Total Tax: '{totalTax .CurrencySymbol }{totalTax .Amount }', with confidence {totalTaxField .Confidence }" );
719
713
}
720
714
721
715
if (document .Fields .TryGetValue (" InvoiceTotal" , out DocumentField invoiceTotalField )
722
- && invoiceTotalField .Type == DocumentFieldType .Currency )
716
+ && invoiceTotalField .FieldType == DocumentFieldType .Currency )
723
717
{
724
718
CurrencyValue invoiceTotal = invoiceTotalField .ValueCurrency ;
725
719
Console .WriteLine ($" Invoice Total: '{invoiceTotal .CurrencySymbol }{invoiceTotal .Amount }', with confidence {invoiceTotalField .Confidence }" );
726
720
}
727
721
}
728
-
729
722
```
730
723
731
724
** Run your application**
0 commit comments