client.AnalyzeDocumentFromUriAsync works fine.
But when I submit the stream of the exact same local file as the FileFromUri, it does not return any fields. Why is that?
Dim invoiceUri As Uri = New Uri("https://blablabla.ch/testfile_xy.pdf")
Dim operation As AnalyzeDocumentOperation = Await client.AnalyzeDocumentFromUriAsync(WaitUntil.Completed, "prebuilt-invoice", invoiceUri)
Dim result As AnalyzeResult = operation.Value
Dim filePath = "c:usersmynamedesktoptestfile_xy.pdf"
Dim stream = New IO.FileStream(filePath, IO.FileMode.Open)
Dim operation2 As AnalyzeDocumentOperation = Await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-layout", stream)
Dim result2 As AnalyzeResult = operation2.Value
stream.Close()
Debug.Print(result.Documents.Count) '1 :-)
Debug.Print(result2.Documents.Count) '0 :-(
Why is no documents property transmitted?
2
Answers
I do not want to use both variants, but only analyze the local files. But your answer worked. In my case it had a typo: I have to use "prebuilt-invoice" both times, of course, and not "prebuilt-layout" once. Thank you very much!
Errors have been encountered where the
AnalyzeDocumentAsync
method does not return any fields when analyzing a document from a stream, while it works fine when analyzing from a URI. You can modify your code to ensure the correct stream position.With URL:
Output:
Without URL from Local path: