VS 2022 and DocumentIntelligence Library (1.0)
Hello,
I am new to Azure AI Document Intelligence. I just download the Azure.AI.DocumentIntelligence library in my VS 2022 IDE via NuGet packages.
I copied the sample code from the tutorials and able to read the content using Uri option. But my files are stored locally or in the network path. I tried following code, but getting following error
The type or namespace name 'AnalyzeDocumentResult' could not be found (are you missing a using directive or an assembly reference?)
I appreciate your help on this. Thanks in advance.
using Azure;
using Azure.AI.DocumentIntelligence;
using System;
using System.IO;
using System.Threading.Tasks;
string key = "tempkey";
string endpoint = "https://dev-temp-di.cognitiveservices.azure.com/";
AzureKeyCredential credential = new AzureKeyCredential(key);
DocumentIntelligenceClient client = new DocumentIntelligenceClient(new Uri(endpoint), credential);
string filePath = "C:\Users\devar_r\Downloads\testpdfimage.pdf";
using (FileStream stream = File.OpenRead(filePath))
{
AnalyzeDocumentResult result = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-layout", stream);
bool containsHandwrittenContent = result.Styles != null && result.Styles.Any(style => style.IsHandwritten == true);
Console.WriteLine(containsHandwrittenContent ?
"Document contains handwritten content" :
"Document does not contain handwritten content");
foreach (var page in result.Pages)
{
Console.WriteLine($"----Analyzing layout from page #{page.PageNumber}----");
Console.WriteLine($"Page has width: {page.Width} and height: {page.Height}, measured with unit: {page.Unit}");
if (page.Lines != null)
{
foreach (var line in page.Lines)
{
Console.WriteLine($"Content: {line.Content}"); // Print content of the line
}
}
}
}
Console.ReadLine();