public final class FormRecognizerAsyncClient extends Object
Instantiating an asynchronous Form Recognizer Client
FormRecognizerAsyncClientformRecognizerAsyncClient = newFormRecognizerClientBuilder() .credential(newAzureKeyCredential("{key}")) .endpoint("{endpoint}") .buildAsyncClient();
FormRecognizerClientBuilder| Modifier and Type | Method and Description |
|---|---|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeBusinessCards(Flux<ByteBuffer> businessCard,
long length)
Recognizes business card data using optical character recognition (OCR) and a prebuilt business card
trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeBusinessCards(Flux<ByteBuffer> businessCard,
long length,
RecognizeBusinessCardsOptions recognizeBusinessCardsOptions)
Recognizes business card data from documents using optical character recognition (OCR)
and a prebuilt business card trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeBusinessCardsFromUrl(String businessCardUrl)
Recognizes business card data using optical character recognition (OCR) and a prebuilt business card trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeBusinessCardsFromUrl(String businessCardUrl,
RecognizeBusinessCardsOptions recognizeBusinessCardsOptions)
Recognizes business card data using optical character recognition (OCR) and a prebuilt business card trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> |
beginRecognizeContent(Flux<ByteBuffer> form,
long length)
Recognizes content/layout data using optical character recognition (OCR).
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> |
beginRecognizeContent(Flux<ByteBuffer> form,
long length,
RecognizeContentOptions recognizeContentOptions)
Recognizes content/layout data using optical character recognition (OCR).
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> |
beginRecognizeContentFromUrl(String formUrl)
Recognizes content/layout data from documents using optical character recognition (OCR).
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> |
beginRecognizeContentFromUrl(String formUrl,
RecognizeContentOptions recognizeContentOptions)
Recognizes layout data from documents using optical character recognition (OCR) and a custom trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeCustomForms(String modelId,
Flux<ByteBuffer> form,
long length)
Recognizes form data from documents using optical character recognition (OCR) and a custom trained
model with or without labels.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeCustomForms(String modelId,
Flux<ByteBuffer> form,
long length,
RecognizeCustomFormsOptions recognizeCustomFormsOptions)
Recognizes form data from documents using optical character recognition (OCR) and a custom trained
model with or without labels.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeCustomFormsFromUrl(String modelId,
String formUrl)
Recognizes form data from documents using optical character recognition (OCR) and a custom trained
model with or without labels.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeCustomFormsFromUrl(String modelId,
String formUrl,
RecognizeCustomFormsOptions recognizeCustomFormsOptions)
Recognizes form data from documents using optical character recognition (OCR) and a custom trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeIdentityDocuments(Flux<ByteBuffer> identityDocument,
long length)
Analyze identity documents using optical character recognition (OCR) and a prebuilt model trained on identity
documents model to extract key information from passports and US driver licenses.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeIdentityDocuments(Flux<ByteBuffer> identityDocument,
long length,
RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions)
Analyze identity documents using optical character recognition (OCR) and a prebuilt model trained on identity
documents model to extract key information from passports and US driver licenses.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl)
Analyze identity documents using optical character recognition (OCR) and a prebuilt model trained on identity
documents model to extract key information from passports and US driver licenses.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl,
RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions)
Analyze identity documents using optical character recognition (OCR) and a prebuilt model trained on identity
documents model to extract key information from passports and US driver licenses.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeInvoices(Flux<ByteBuffer> invoice,
long length)
Recognizes invoice data using optical character recognition (OCR) and a prebuilt invoice
trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeInvoices(Flux<ByteBuffer> invoice,
long length,
RecognizeInvoicesOptions recognizeInvoicesOptions)
Recognizes invoice data from documents using optical character recognition (OCR)
and a prebuilt invoice trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeInvoicesFromUrl(String invoiceUrl)
Recognizes invoice data using optical character recognition (OCR) and a prebuilt invoice trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeInvoicesFromUrl(String invoiceUrl,
RecognizeInvoicesOptions recognizeInvoicesOptions)
Recognizes invoice data using optical character recognition (OCR) and a prebuilt invoice trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeReceipts(Flux<ByteBuffer> receipt,
long length)
Recognizes receipt data using optical character recognition (OCR) and a prebuilt receipt
trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeReceipts(Flux<ByteBuffer> receipt,
long length,
RecognizeReceiptsOptions recognizeReceiptsOptions)
Recognizes receipt data from documents using optical character recognition (OCR)
and a prebuilt receipt trained model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeReceiptsFromUrl(String receiptUrl)
Recognizes receipt data using optical character recognition (OCR) and a prebuilt receipt trained
model.
|
com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> |
beginRecognizeReceiptsFromUrl(String receiptUrl,
RecognizeReceiptsOptions recognizeReceiptsOptions)
Recognizes receipt data using optical character recognition (OCR) and a prebuilt receipt trained
model.
|
public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringformUrl = "{form_url}";StringmodelId = "{custom_trained_model_id}"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeCustomFormsFromUrl(modelId, formUrl) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(recognizedForm -> recognizedForm.getFields() .forEach((fieldText, formField) -> {System.out.printf("Field text: %s%n", fieldText);System.out.printf("Field value data text: %s%n", formField.getValueData().getText());System.out.printf("Confidence score: %.2f%n", formField.getConfidence()); }));
modelId - The UUID string format custom trained model Id to be used.formUrl - The URL of the form to analyze.PollerFlux that polls the recognize custom form operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If formUrl, modelId is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl, RecognizeCustomFormsOptions recognizeCustomFormsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringformUrl = "{formUrl}";StringmodelId = "{model_id}"; boolean includeFieldElements = true; formRecognizerAsyncClient.beginRecognizeCustomFormsFromUrl(modelId, formUrl, newRecognizeCustomFormsOptions() .setFieldElementsIncluded(includeFieldElements) .setPollInterval(Duration.ofSeconds(10))) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(recognizedForm -> recognizedForm.getFields() .forEach((fieldText, formField) -> {System.out.printf("Field text: %s%n", fieldText);System.out.printf("Field value data text: %s%n", formField.getValueData().getText());System.out.printf("Confidence score: %.2f%n", formField.getConfidence()); }));
modelId - The UUID string format custom trained model Id to be used.formUrl - The source URL to the input form.recognizeCustomFormsOptions - The additional configurable
options that may be passed when recognizing custom forms.PollerFlux that polls the recognize custom form operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If formUrl, modelId is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomForms(String modelId, Flux<ByteBuffer> form, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that thedata passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Fileform = newFile("{local/file_path/fileName.jpg}");StringmodelId = "{custom_trained_model_id}"; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(form.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeCustomForms(modelId, buffer, form.length()) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(recognizedForm -> recognizedForm.getFields() .forEach((fieldText, formField) -> {System.out.printf("Field text: %s%n", fieldText);System.out.printf("Field value data text: %s%n", formField.getValueData().getText());System.out.printf("Confidence score: %.2f%n", formField.getConfidence()); }));
modelId - The UUID string format custom trained model Id to be used.form - The data of the form to recognize form information from.length - The exact length of the data.PollerFlux that polls the recognize custom form operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If form, modelId is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomForms(String modelId, Flux<ByteBuffer> form, long length, RecognizeCustomFormsOptions recognizeCustomFormsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that thedata passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Fileform = newFile("{local/file_path/fileName.jpg}");StringmodelId = "{custom_trained_model_id}"; boolean includeFieldElements = true; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(form.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeCustomForms(modelId, buffer, form.length(), newRecognizeCustomFormsOptions() .setContentType(FormContentType.IMAGE_JPEG) .setFieldElementsIncluded(includeFieldElements) .setPollInterval(Duration.ofSeconds(5))) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(recognizedForm -> recognizedForm.getFields() .forEach((fieldName, formField) -> {System.out.printf("Field text: %s%n", fieldName);System.out.printf("Field value data text: %s%n", formField.getValueData().getText());System.out.printf("Confidence score: %.2f%n", formField.getConfidence()); }));
modelId - The UUID string format custom trained model Id to be used.form - The data of the form to recognize form information from.length - The exact length of the data.recognizeCustomFormsOptions - The additional configurable
options that may be passed when recognizing custom forms.PollerFlux that polls the recognize custom form operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If form, modelId is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContentFromUrl(String formUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringformUrl = "{formUrl}"; formRecognizerAsyncClient.beginRecognizeContentFromUrl(formUrl) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(formPage -> {System.out.printf("Page Angle: %s%n", formPage.getTextAngle());System.out.printf("Page Dimension unit: %s%n", formPage.getUnit()); // Table informationSystem.out.println("Recognized Tables: "); formPage.getTables().forEach(formTable -> formTable.getCells().forEach(recognizedTableCell ->System.out.printf("%s ", recognizedTableCell.getText()))); });
formUrl - The URL of the form to analyze.PollerFlux that polls the recognize content operation until it has completed, has failed, or
has been cancelled. The completed operation returns a list of FormPage.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If formUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContentFromUrl(String formUrl, RecognizeContentOptions recognizeContentOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Content recognition supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language in the options.
Code sample
StringformUrl = "{formUrl}"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeContentFromUrl(formUrl, newRecognizeContentOptions().setPollInterval(Duration.ofSeconds(5))) .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(formPage -> {System.out.printf("Page Angle: %s%n", formPage.getTextAngle());System.out.printf("Page Dimension unit: %s%n", formPage.getUnit()); // Table informationSystem.out.println("Recognized Tables: "); formPage.getTables().forEach(formTable -> formTable.getCells().forEach(recognizedTableCell ->System.out.printf("%s ", recognizedTableCell.getText()))); });
formUrl - The source URL to the input form.recognizeContentOptions - The additional configurable options
that may be passed when recognizing content/layout on a form.PollerFlux that polls the recognized content/layout operation until it has completed,
has failed, or has been cancelled. The completed operation returns a list of FormPage.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If formUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContent(Flux<ByteBuffer> form, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that thedata passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Fileform = newFile("{local/file_path/fileName.jpg}"); // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(form.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeContent(buffer, form.length()) .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(formPage -> {System.out.printf("Page Angle: %s%n", formPage.getTextAngle());System.out.printf("Page Dimension unit: %s%n", formPage.getUnit()); // Table informationSystem.out.println("Recognized Tables: "); formPage.getTables().forEach(formTable -> formTable.getCells().forEach(recognizedTableCell ->System.out.printf("%s ", recognizedTableCell.getText()))); });
form - The data of the form to recognize content information from.length - The exact length of the data.PollerFlux polls the recognize content operation until it has completed, has failed, or has
been cancelled. The completed operation returns a list of FormPage.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If form is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContent(Flux<ByteBuffer> form, long length, RecognizeContentOptions recognizeContentOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that thedata passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Content recognition supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language in the options.
Code sample
Fileform = newFile("{local/file_path/fileName.jpg}"); // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(form.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeContent(buffer, form.length(), newRecognizeContentOptions() .setContentType(FormContentType.IMAGE_JPEG) .setPollInterval(Duration.ofSeconds(5))) .flatMap(AsyncPollResponse::getFinalResult) .flatMap(Flux::fromIterable) .subscribe(formPage -> {System.out.printf("Page Angle: %s%n", formPage.getTextAngle());System.out.printf("Page Dimension unit: %s%n", formPage.getUnit()); // Table informationSystem.out.println("Recognized Tables: "); formPage.getTables().forEach(formTable -> formTable.getCells().forEach(recognizedTableCell ->System.out.printf("%s ", recognizedTableCell.getText()))); });
form - The data of the form to recognize content information from.length - The exact length of the data.recognizeContentOptions - The additional configurable options
that may be passed when recognizing content/layout on a form.PollerFlux polls the recognize content operation until it has completed, has failed, or has
been cancelled. The completed operation returns a list of FormPage.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If form is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceiptsFromUrl(String receiptUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a receipt.Code sample
StringreceiptUrl = "{receiptUrl}"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl) // if training polling operation completed, retrieve the final result. .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) {RecognizedFormrecognizedForm = recognizedReceipts.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Receipt page %d -----------%n", i);FormFieldmerchantNameField = recognizedFields.get("MerchantName"); if (merchantNameField != null) { if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {StringmerchantName = merchantNameField.getValue().asString();System.out.printf("Merchant Name: %s, confidence: %.2f%n", merchantName, merchantNameField.getConfidence()); } }FormFieldmerchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber"); if (merchantPhoneNumberField != null) { if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {StringmerchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", merchantAddress, merchantPhoneNumberField.getConfidence()); } }FormFieldtransactionDateField = recognizedFields.get("TransactionDate"); if (transactionDateField != null) { if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {LocalDatetransactionDate = transactionDateField.getValue().asDate();System.out.printf("Transaction Date: %s, confidence: %.2f%n", transactionDate, transactionDateField.getConfidence()); } }FormFieldreceiptItemsField = recognizedFields.get("Items"); if (receiptItemsField != null) {System.out.printf("Receipt Items: %n"); if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {List<FormField> receiptItems = receiptItemsField.getValue().asList(); receiptItems.stream() .filter(receiptItem ->FieldValueType.MAP == receiptItem.getValue().getValueType()) .map(formField -> formField.getValue().asMap()) .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> { if ("Quantity".equals(key)) { if (FieldValueType.FLOAT == formField.getValue().getValueType()) {Floatquantity = formField.getValue().asFloat();System.out.printf("Quantity: %f, confidence: %.2f%n", quantity, formField.getConfidence()); } } })); } } } });
receiptUrl - The URL of the receipt to analyze.PollerFlux that polls the recognize receipt operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If receiptUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceiptsFromUrl(String receiptUrl, RecognizeReceiptsOptions recognizeReceiptsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringreceiptUrl = "{receiptUrl}"; boolean includeFieldElements = true; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl, newRecognizeReceiptsOptions() .setFieldElementsIncluded(includeFieldElements) .setLocale(FormRecognizerLocale.EN_US) .setPollInterval(Duration.ofSeconds(5))) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) {RecognizedFormrecognizedReceipt = recognizedReceipts.get(i);Map<String,FormField> recognizedFields = recognizedReceipt.getFields();System.out.printf("----------- Recognized Receipt page %d -----------%n", i);FormFieldmerchantNameField = recognizedFields.get("MerchantName"); if (merchantNameField != null) { if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {StringmerchantName = merchantNameField.getValue().asString();System.out.printf("Merchant Name: %s, confidence: %.2f%n", merchantName, merchantNameField.getConfidence()); } }FormFieldmerchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber"); if (merchantPhoneNumberField != null) { if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {StringmerchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", merchantAddress, merchantPhoneNumberField.getConfidence()); } }FormFieldtransactionDateField = recognizedFields.get("TransactionDate"); if (transactionDateField != null) { if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {LocalDatetransactionDate = transactionDateField.getValue().asDate();System.out.printf("Transaction Date: %s, confidence: %.2f%n", transactionDate, transactionDateField.getConfidence()); } }FormFieldreceiptItemsField = recognizedFields.get("Items"); if (receiptItemsField != null) {System.out.printf("Receipt Items: %n"); if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {List<FormField> receiptItems = receiptItemsField.getValue().asList(); receiptItems.stream() .filter(receiptItem ->FieldValueType.MAP == receiptItem.getValue().getValueType()) .map(formField -> formField.getValue().asMap()) .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> { if ("Quantity".equals(key)) { if (FieldValueType.FLOAT == formField.getValue().getValueType()) {Floatquantity = formField.getValue().asFloat();System.out.printf("Quantity: %f, confidence: %.2f%n", quantity, formField.getConfidence()); } } })); } } } });
receiptUrl - The source URL to the input receipt.recognizeReceiptsOptions - The additional configurable options
that may be passed when analyzing a receipt.PollerFlux that polls the recognize receipt operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If receiptUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceipts(Flux<ByteBuffer> receipt, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a receipt. Note that thereceipt passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Filereceipt = newFile("{file_source_url}");Flux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) {RecognizedFormrecognizedForm = recognizedReceipts.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Receipt page %d -----------%n", i);FormFieldmerchantNameField = recognizedFields.get("MerchantName"); if (merchantNameField != null) { if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {StringmerchantName = merchantNameField.getValue().asString();System.out.printf("Merchant Name: %s, confidence: %.2f%n", merchantName, merchantNameField.getConfidence()); } }FormFieldmerchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber"); if (merchantPhoneNumberField != null) { if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {StringmerchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", merchantAddress, merchantPhoneNumberField.getConfidence()); } }FormFieldtransactionDateField = recognizedFields.get("TransactionDate"); if (transactionDateField != null) { if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {LocalDatetransactionDate = transactionDateField.getValue().asDate();System.out.printf("Transaction Date: %s, confidence: %.2f%n", transactionDate, transactionDateField.getConfidence()); } }FormFieldreceiptItemsField = recognizedFields.get("Items"); if (receiptItemsField != null) {System.out.printf("Receipt Items: %n"); if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {List<FormField> receiptItems = receiptItemsField.getValue().asList(); receiptItems.stream() .filter(receiptItem ->FieldValueType.MAP == receiptItem.getValue().getValueType()) .map(formField -> formField.getValue().asMap()) .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> { if ("Quantity".equals(key)) { if (FieldValueType.FLOAT == formField.getValue().getValueType()) {Floatquantity = formField.getValue().asFloat();System.out.printf("Quantity: %f, confidence: %.2f%n", quantity, formField.getConfidence()); } } })); } } } });
receipt - The data of the document to recognize receipt information from.length - The exact length of the data.PollerFlux that polls the recognize receipt operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If receipt is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceipts(Flux<ByteBuffer> receipt, long length, RecognizeReceiptsOptions recognizeReceiptsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a receipt. Note that thereceipt passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Filereceipt = newFile("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length(), newRecognizeReceiptsOptions() .setContentType(FormContentType.IMAGE_JPEG) .setFieldElementsIncluded(includeFieldElements) .setLocale(FormRecognizerLocale.EN_US) .setPollInterval(Duration.ofSeconds(5))) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) {RecognizedFormrecognizedForm = recognizedReceipts.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Receipt page %d -----------%n", i);FormFieldmerchantNameField = recognizedFields.get("MerchantName"); if (merchantNameField != null) { if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {StringmerchantName = merchantNameField.getValue().asString();System.out.printf("Merchant Name: %s, confidence: %.2f%n", merchantName, merchantNameField.getConfidence()); } }FormFieldmerchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber"); if (merchantPhoneNumberField != null) { if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {StringmerchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", merchantAddress, merchantPhoneNumberField.getConfidence()); } }FormFieldtransactionDateField = recognizedFields.get("TransactionDate"); if (transactionDateField != null) { if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {LocalDatetransactionDate = transactionDateField.getValue().asDate();System.out.printf("Transaction Date: %s, confidence: %.2f%n", transactionDate, transactionDateField.getConfidence()); } }FormFieldreceiptItemsField = recognizedFields.get("Items"); if (receiptItemsField != null) {System.out.printf("Receipt Items: %n"); if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {List<FormField> receiptItems = receiptItemsField.getValue().asList(); receiptItems.stream() .filter(receiptItem ->FieldValueType.MAP == receiptItem.getValue().getValueType()) .map(formField -> formField.getValue().asMap()) .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> { if ("Quantity".equals(key)) { if (FieldValueType.FLOAT == formField.getValue().getValueType()) {Floatquantity = formField.getValue().asFloat();System.out.printf("Quantity: %f, confidence: %.2f%n", quantity, formField.getConfidence()); } } })); } } } });
receipt - The data of the document to recognize receipt information from.length - The exact length of the data.recognizeReceiptsOptions - The additional configurable options
that may be passed when analyzing a receipt.PollerFlux that polls the recognize receipt operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If receipt is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a business card.Code sample
StringbusinessCardUrl = "{business_card_url}"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeBusinessCardsFromUrl(businessCardUrl) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedBusinessCards -> { for (int i = 0; i < recognizedBusinessCards.size(); i++) {RecognizedFormrecognizedForm = recognizedBusinessCards.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Business Card page %d -----------%n", i);FormFieldcontactNamesFormField = recognizedFields.get("ContactNames"); if (contactNamesFormField != null) { if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {List<FormField> contactNamesList = contactNamesFormField.getValue().asList(); contactNamesList.stream() .filter(contactName ->FieldValueType.MAP == contactName.getValue().getValueType()) .map(contactName -> {System.out.printf("Contact name: %s%n", contactName.getValueData().getText()); return contactName.getValue().asMap(); }) .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> { if ("FirstName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringfirstName = contactName.getValue().asString();System.out.printf("\tFirst Name: %s, confidence: %.2f%n", firstName, contactName.getConfidence()); } } if ("LastName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringlastName = contactName.getValue().asString();System.out.printf("\tLast Name: %s, confidence: %.2f%n", lastName, contactName.getConfidence()); } } })); } }FormFieldjobTitles = recognizedFields.get("JobTitles"); if (jobTitles != null) { if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {List<FormField> jobTitlesItems = jobTitles.getValue().asList(); jobTitlesItems.forEach(jobTitlesItem -> { if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {StringjobTitle = jobTitlesItem.getValue().asString();System.out.printf("Job Title: %s, confidence: %.2f%n", jobTitle, jobTitlesItem.getConfidence()); } }); } } } });
businessCardUrl - The source URL to the input business card.PollerFlux that polls the recognize business card operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If businessCardUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a business card.Code sample
StringbusinessCardUrl = "{business_card_url}"; boolean includeFieldElements = true; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeBusinessCardsFromUrl(businessCardUrl, newRecognizeBusinessCardsOptions() .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedBusinessCards -> { for (int i = 0; i < recognizedBusinessCards.size(); i++) {RecognizedFormrecognizedBusinessCard = recognizedBusinessCards.get(i);Map<String,FormField> recognizedFields = recognizedBusinessCard.getFields();System.out.printf("----------- Recognized Business Card page %d -----------%n", i);FormFieldcontactNamesFormField = recognizedFields.get("ContactNames"); if (contactNamesFormField != null) { if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {List<FormField> contactNamesList = contactNamesFormField.getValue().asList(); contactNamesList.stream() .filter(contactName ->FieldValueType.MAP == contactName.getValue().getValueType()) .map(contactName -> {System.out.printf("Contact name: %s%n", contactName.getValueData().getText()); return contactName.getValue().asMap(); }) .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> { if ("FirstName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringfirstName = contactName.getValue().asString();System.out.printf("\tFirst Name: %s, confidence: %.2f%n", firstName, contactName.getConfidence()); } } if ("LastName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringlastName = contactName.getValue().asString();System.out.printf("\tLast Name: %s, confidence: %.2f%n", lastName, contactName.getConfidence()); } } })); } }FormFieldjobTitles = recognizedFields.get("JobTitles"); if (jobTitles != null) { if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {List<FormField> jobTitlesItems = jobTitles.getValue().asList(); jobTitlesItems.forEach(jobTitlesItem -> { if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {StringjobTitle = jobTitlesItem.getValue().asString();System.out.printf("Job Title: %s, confidence: %.2f%n", jobTitle, jobTitlesItem.getConfidence()); } }); } } } });
businessCardUrl - The source URL to the input business card.recognizeBusinessCardsOptions - The additional configurable options
that may be passed when analyzing a business card.PollerFlux that polls the recognize business card operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If businessCardUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCards(Flux<ByteBuffer> businessCard, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a business card. Note that thebusinessCard passed must be replayable if retries are enabled (the default).
In other words, the Flux must produce the same data each time it is subscribed to.
Code sample
FilebusinessCard = newFile("{local/file_path/fileName.jpg}");Flux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(businessCard.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeBusinessCards(buffer, businessCard.length()) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedBusinessCards -> { for (int i = 0; i < recognizedBusinessCards.size(); i++) {RecognizedFormrecognizedForm = recognizedBusinessCards.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Business Card page %d -----------%n", i);FormFieldcontactNamesFormField = recognizedFields.get("ContactNames"); if (contactNamesFormField != null) { if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {List<FormField> contactNamesList = contactNamesFormField.getValue().asList(); contactNamesList.stream() .filter(contactName ->FieldValueType.MAP == contactName.getValue().getValueType()) .map(contactName -> {System.out.printf("Contact name: %s%n", contactName.getValueData().getText()); return contactName.getValue().asMap(); }) .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> { if ("FirstName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringfirstName = contactName.getValue().asString();System.out.printf("\tFirst Name: %s, confidence: %.2f%n", firstName, contactName.getConfidence()); } } if ("LastName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringlastName = contactName.getValue().asString();System.out.printf("\tLast Name: %s, confidence: %.2f%n", lastName, contactName.getConfidence()); } } })); } }FormFieldjobTitles = recognizedFields.get("JobTitles"); if (jobTitles != null) { if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {List<FormField> jobTitlesItems = jobTitles.getValue().asList(); jobTitlesItems.forEach(jobTitlesItem -> { if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {StringjobTitle = jobTitlesItem.getValue().asString();System.out.printf("Job Title: %s, confidence: %.2f%n", jobTitle, jobTitlesItem.getConfidence()); } }); } } } });
businessCard - The data of the document to recognize business card information from.length - The exact length of the data.PollerFlux that polls the recognize business card operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If businessCard is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCards(Flux<ByteBuffer> businessCard, long length, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a business card. Note that thebusinessCard passed must be replayable if retries are enabled (the default).
In other words, the Flux must produce the same data each time it is subscribed to.
Code sample
FilebusinessCard = newFile("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(businessCard.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeBusinessCards(buffer, businessCard.length(), newRecognizeBusinessCardsOptions() .setContentType(FormContentType.IMAGE_JPEG) .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedBusinessCards -> { for (int i = 0; i < recognizedBusinessCards.size(); i++) {RecognizedFormrecognizedForm = recognizedBusinessCards.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized Business Card page %d -----------%n", i);FormFieldcontactNamesFormField = recognizedFields.get("ContactNames"); if (contactNamesFormField != null) { if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {List<FormField> contactNamesList = contactNamesFormField.getValue().asList(); contactNamesList.stream() .filter(contactName ->FieldValueType.MAP == contactName.getValue().getValueType()) .map(contactName -> {System.out.printf("Contact name: %s%n", contactName.getValueData().getText()); return contactName.getValue().asMap(); }) .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> { if ("FirstName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringfirstName = contactName.getValue().asString();System.out.printf("\tFirst Name: %s, confidence: %.2f%n", firstName, contactName.getConfidence()); } } if ("LastName".equals(key)) { if (FieldValueType.STRING == contactName.getValue().getValueType()) {StringlastName = contactName.getValue().asString();System.out.printf("\tLast Name: %s, confidence: %.2f%n", lastName, contactName.getConfidence()); } } })); } }FormFieldjobTitles = recognizedFields.get("JobTitles"); if (jobTitles != null) { if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {List<FormField> jobTitlesItems = jobTitles.getValue().asList(); jobTitlesItems.forEach(jobTitlesItem -> { if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {StringjobTitle = jobTitlesItem.getValue().asString();System.out.printf("Job Title: %s, confidence: %.2f%n", jobTitle, jobTitlesItem.getConfidence()); } }); } } } });
businessCard - The data of the document to recognize business card information from.length - The exact length of the data.recognizeBusinessCardsOptions - The additional configurable options
that may be passed when analyzing a business card.PollerFlux that polls the recognize business card operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If businessCard is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringidDocumentUrl = "idDocumentUrl"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeIdentityDocumentsFromUrl(idDocumentUrl) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedIDDocumentResult -> { for (int i = 0; i < recognizedIDDocumentResult.size(); i++) {RecognizedFormrecognizedForm = recognizedIDDocumentResult.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized license info for page %d -----------%n", i);FormFieldfirstNameField = recognizedFields.get("FirstName"); if (firstNameField != null) { if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {StringfirstName = firstNameField.getValue().asString();System.out.printf("First Name: %s, confidence: %.2f%n", firstName, firstNameField.getConfidence()); } }FormFieldlastNameField = recognizedFields.get("LastName"); if (lastNameField != null) { if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {StringlastName = lastNameField.getValue().asString();System.out.printf("Last name: %s, confidence: %.2f%n", lastName, lastNameField.getConfidence()); } }FormFieldcountryRegionFormField = recognizedFields.get("CountryRegion"); if (countryRegionFormField != null) { if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {StringcountryRegion = countryRegionFormField.getValue().asCountryRegion();System.out.printf("Country or region: %s, confidence: %.2f%n", countryRegion, countryRegionFormField.getConfidence()); } }FormFielddateOfExpirationField = recognizedFields.get("DateOfExpiration"); if (dateOfExpirationField != null) { if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {LocalDateexpirationDate = dateOfExpirationField.getValue().asDate();System.out.printf("Document date of expiration: %s, confidence: %.2f%n", expirationDate, dateOfExpirationField.getConfidence()); } }FormFielddocumentNumberField = recognizedFields.get("DocumentNumber"); if (documentNumberField != null) { if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {StringdocumentNumber = documentNumberField.getValue().asString();System.out.printf("Document number: %s, confidence: %.2f%n", documentNumber, documentNumberField.getConfidence()); } } } });
identityDocumentUrl - The source URL to the input identity document.PollerFlux that polls the recognize identity document operation until it has completed,
has failed, or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If identityDocumentUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringlicenseDocumentUrl = "licenseDocumentUrl"; boolean includeFieldElements = true; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeIdentityDocumentsFromUrl(licenseDocumentUrl, newRecognizeIdentityDocumentOptions() .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedIDDocumentResult -> { for (int i = 0; i < recognizedIDDocumentResult.size(); i++) {RecognizedFormrecognizedForm = recognizedIDDocumentResult.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized license info for page %d -----------%n", i);FormFieldfirstNameField = recognizedFields.get("FirstName"); if (firstNameField != null) { if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {StringfirstName = firstNameField.getValue().asString();System.out.printf("First Name: %s, confidence: %.2f%n", firstName, firstNameField.getConfidence()); } }FormFieldlastNameField = recognizedFields.get("LastName"); if (lastNameField != null) { if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {StringlastName = lastNameField.getValue().asString();System.out.printf("Last name: %s, confidence: %.2f%n", lastName, lastNameField.getConfidence()); } }FormFieldcountryRegionFormField = recognizedFields.get("CountryRegion"); if (countryRegionFormField != null) { if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {StringcountryRegion = countryRegionFormField.getValue().asCountryRegion();System.out.printf("Country or region: %s, confidence: %.2f%n", countryRegion, countryRegionFormField.getConfidence()); } }FormFielddateOfExpirationField = recognizedFields.get("DateOfExpiration"); if (dateOfExpirationField != null) { if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {LocalDateexpirationDate = dateOfExpirationField.getValue().asDate();System.out.printf("Document date of expiration: %s, confidence: %.2f%n", expirationDate, dateOfExpirationField.getConfidence()); } }FormFielddocumentNumberField = recognizedFields.get("DocumentNumber"); if (documentNumberField != null) { if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {StringdocumentNumber = documentNumberField.getValue().asString();System.out.printf("Document number: %s, confidence: %.2f%n", documentNumber, documentNumberField.getConfidence()); } } } });
identityDocumentUrl - The source URL to the input identity document.recognizeIdentityDocumentOptions - The additional configurable
options that may be passed when analyzing an identity document.PollerFlux that polls the analyze identity document operation until it has completed, has
failed, or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If identityDocumentUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocuments(Flux<ByteBuffer> identityDocument, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that theidentityDocument passed must be replayable if retries are enabled (the default).
In other words, the Flux must produce the same data each time it is subscribed to.
Code sample
Filelicense = newFile("local/file_path/license.jpg");Flux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(license.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeIdentityDocuments(buffer, license.length()) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedIDDocumentResult -> { for (int i = 0; i < recognizedIDDocumentResult.size(); i++) {RecognizedFormrecognizedForm = recognizedIDDocumentResult.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized license info for page %d -----------%n", i);FormFieldfirstNameField = recognizedFields.get("FirstName"); if (firstNameField != null) { if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {StringfirstName = firstNameField.getValue().asString();System.out.printf("First Name: %s, confidence: %.2f%n", firstName, firstNameField.getConfidence()); } }FormFieldlastNameField = recognizedFields.get("LastName"); if (lastNameField != null) { if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {StringlastName = lastNameField.getValue().asString();System.out.printf("Last name: %s, confidence: %.2f%n", lastName, lastNameField.getConfidence()); } }FormFieldcountryRegionFormField = recognizedFields.get("CountryRegion"); if (countryRegionFormField != null) { if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {StringcountryRegion = countryRegionFormField.getValue().asCountryRegion();System.out.printf("Country or region: %s, confidence: %.2f%n", countryRegion, countryRegionFormField.getConfidence()); } }FormFielddateOfExpirationField = recognizedFields.get("DateOfExpiration"); if (dateOfExpirationField != null) { if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {LocalDateexpirationDate = dateOfExpirationField.getValue().asDate();System.out.printf("Document date of expiration: %s, confidence: %.2f%n", expirationDate, dateOfExpirationField.getConfidence()); } }FormFielddocumentNumberField = recognizedFields.get("DocumentNumber"); if (documentNumberField != null) { if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {StringdocumentNumber = documentNumberField.getValue().asString();System.out.printf("Document number: %s, confidence: %.2f%n", documentNumber, documentNumberField.getConfidence()); } } } });
identityDocument - The data of the document to recognize identity document information from.length - The exact length of the data.PollerFlux that polls the recognize identity document operation until it has completed,
has failed, or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If identityDocument is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocuments(Flux<ByteBuffer> identityDocument, long length, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Note that theidentityDocument passed must be replayable if retries are enabled (the default).
In other words, the Flux must produce the same data each time it is subscribed to.
Code sample
FilelicenseDocument = newFile("local/file_path/license.jpg"); boolean includeFieldElements = true; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(licenseDocument.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeIdentityDocuments(buffer, licenseDocument.length(), newRecognizeIdentityDocumentOptions() .setContentType(FormContentType.IMAGE_JPEG) .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedIDDocumentResult -> { for (int i = 0; i < recognizedIDDocumentResult.size(); i++) {RecognizedFormrecognizedForm = recognizedIDDocumentResult.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();System.out.printf("----------- Recognized license info for page %d -----------%n", i);FormFieldfirstNameField = recognizedFields.get("FirstName"); if (firstNameField != null) { if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {StringfirstName = firstNameField.getValue().asString();System.out.printf("First Name: %s, confidence: %.2f%n", firstName, firstNameField.getConfidence()); } }FormFieldlastNameField = recognizedFields.get("LastName"); if (lastNameField != null) { if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {StringlastName = lastNameField.getValue().asString();System.out.printf("Last name: %s, confidence: %.2f%n", lastName, lastNameField.getConfidence()); } }FormFieldcountryRegionFormField = recognizedFields.get("CountryRegion"); if (countryRegionFormField != null) { if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {StringcountryRegion = countryRegionFormField.getValue().asCountryRegion();System.out.printf("Country or region: %s, confidence: %.2f%n", countryRegion, countryRegionFormField.getConfidence()); } }FormFielddateOfExpirationField = recognizedFields.get("DateOfExpiration"); if (dateOfExpirationField != null) { if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {LocalDateexpirationDate = dateOfExpirationField.getValue().asDate();System.out.printf("Document date of expiration: %s, confidence: %.2f%n", expirationDate, dateOfExpirationField.getConfidence()); } }FormFielddocumentNumberField = recognizedFields.get("DocumentNumber"); if (documentNumberField != null) { if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {StringdocumentNumber = documentNumberField.getValue().asString();System.out.printf("Document number: %s, confidence: %.2f%n", documentNumber, documentNumberField.getConfidence()); } } } });
identityDocument - The data of the document to recognize identity document information from.length - The exact length of the data.recognizeIdentityDocumentOptions - The additional configurable
options that may be passed when analyzing an identity document.PollerFlux that polls the recognize identity document operation until it has completed,
has failed, or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If identityDocument is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoicesFromUrl(String invoiceUrl)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a invoice.Code sample
StringinvoiceUrl = "invoice_url"; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeInvoicesFromUrl(invoiceUrl) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedInvoices -> { for (int i = 0; i < recognizedInvoices.size(); i++) {RecognizedFormrecognizedForm = recognizedInvoices.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();FormFieldcustomAddrFormField = recognizedFields.get("CustomerAddress"); if (customAddrFormField != null) { if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString()); } }FormFieldinvoiceDateFormField = recognizedFields.get("InvoiceDate"); if (invoiceDateFormField != null) { if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {LocalDateinvoiceDate = invoiceDateFormField.getValue().asDate();System.out.printf("Invoice Date: %s, confidence: %.2f%n", invoiceDate, invoiceDateFormField.getConfidence()); } } } });
invoiceUrl - The URL of the invoice to analyze.PollerFlux that polls the recognize invoice operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If invoiceUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoicesFromUrl(String invoiceUrl, RecognizeInvoicesOptions recognizeInvoicesOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
StringinvoiceUrl = "invoice_url"; boolean includeFieldElements = true; // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeInvoicesFromUrl(invoiceUrl, newRecognizeInvoicesOptions() .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedInvoices -> { for (int i = 0; i < recognizedInvoices.size(); i++) {RecognizedFormrecognizedForm = recognizedInvoices.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();FormFieldcustomAddrFormField = recognizedFields.get("CustomerAddress"); if (customAddrFormField != null) { if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString()); } }FormFieldinvoiceDateFormField = recognizedFields.get("InvoiceDate"); if (invoiceDateFormField != null) { if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {LocalDateinvoiceDate = invoiceDateFormField.getValue().asDate();System.out.printf("Invoice Date: %s, confidence: %.2f%n", invoiceDate, invoiceDateFormField.getConfidence()); } } } });
invoiceUrl - The source URL to the input invoice.recognizeInvoicesOptions - The additional configurable options
that may be passed when analyzing a invoice.PollerFlux that polls the recognize invoice operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If invoiceUrl is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoices(Flux<ByteBuffer> invoice, long length)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a invoice. Note that theinvoice passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Fileinvoice = newFile("local/file_path/invoice.jpg");Flux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(invoice.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeInvoices(buffer, invoice.length()) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedInvoices -> { for (int i = 0; i < recognizedInvoices.size(); i++) {RecognizedFormrecognizedForm = recognizedInvoices.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();FormFieldcustomAddrFormField = recognizedFields.get("CustomerAddress"); if (customAddrFormField != null) { if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString()); } }FormFieldinvoiceDateFormField = recognizedFields.get("InvoiceDate"); if (invoiceDateFormField != null) { if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {LocalDateinvoiceDate = invoiceDateFormField.getValue().asDate();System.out.printf("Invoice Date: %s, confidence: %.2f%n", invoiceDate, invoiceDateFormField.getConfidence()); } } } });
invoice - The data of the document to recognize invoice information from.length - The exact length of the data.PollerFlux that polls the recognize invoice operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If invoice is null.public com.azure.core.util.polling.PollerFlux<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoices(Flux<ByteBuffer> invoice, long length, RecognizeInvoicesOptions recognizeInvoicesOptions)
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
See here for fields found on a invoice. Note that theinvoice passed must be replayable if retries are enabled (the default). In other words, the
Flux must produce the same data each time it is subscribed to.
Code sample
Fileinvoice = newFile("local/file_path/invoice.jpg"); boolean includeFieldElements = true; // Utility method to convert input stream to Byte bufferFlux<ByteBuffer> buffer = toFluxByteBuffer(newByteArrayInputStream(Files.readAllBytes(invoice.toPath()))); // if training polling operation completed, retrieve the final result. formRecognizerAsyncClient.beginRecognizeInvoices(buffer, invoice.length(), newRecognizeInvoicesOptions() .setContentType(FormContentType.IMAGE_JPEG) .setFieldElementsIncluded(includeFieldElements)) .setPollInterval(Duration.ofSeconds(5)) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedInvoices -> { for (int i = 0; i < recognizedInvoices.size(); i++) {RecognizedFormrecognizedForm = recognizedInvoices.get(i);Map<String,FormField> recognizedFields = recognizedForm.getFields();FormFieldcustomAddrFormField = recognizedFields.get("CustomerAddress"); if (customAddrFormField != null) { if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString()); } }FormFieldinvoiceDateFormField = recognizedFields.get("InvoiceDate"); if (invoiceDateFormField != null) { if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {LocalDateinvoiceDate = invoiceDateFormField.getValue().asDate();System.out.printf("Invoice Date: %s, confidence: %.2f%n", invoiceDate, invoiceDateFormField.getConfidence()); } } } });
invoice - The data of the document to recognize invoice information from.length - The exact length of the data.recognizeInvoicesOptions - The additional configurable options
that may be passed when analyzing a invoice.PollerFlux that polls the recognize invoice operation until it has completed, has failed,
or has been cancelled. The completed operation returns a list of RecognizedForm.FormRecognizerException - If recognize operation fails and the AnalyzeOperationResult returned with
an OperationStatus.FAILED.NullPointerException - If invoice is null.Copyright © 2021 Microsoft Corporation. All rights reserved.