is Azure SDK for Document Intelligence .NET support analyzing multiple pages with my custom models ?

Yonatan Mangisto 0 Reputation points
2024-02-24T06:32:17.7+00:00

hello All, I am using the Azure.AI.DocumentIntelligence SDK for .NET to analyze a document on my custom model with multiple pages. However, I am encountering an issue where the resulting AnalyzeResult object only contains a single page result, even though the documentation states that the SDK supports analyzing multiple pages. here is my code :
        private async Task<AnalyzeResult> ExtractDocumentAsync(string filePath, string modelId)         {             // Your Form Recognizer endpoint and API key             string endpoint = <my_Endpoint>;             string apiKey = <my_ApiKey>;                          var client = new DocumentIntelligenceClient(new Uri(endpoint), new AzureKeyCredential(apiKey));             // Now you can use the client to interact with the Form Recognizer service             // For example:                 try                 {                     //string documentText = system.ReadTextFile(system.GetResourceForLocalPath(filePath,PathType.File));                     //string fileContent = Convert.ToBase64String(Encoding.UTF8.GetBytes(documentText));                     byte[] fileContent = File.ReadAllBytes(filePath);                     //Uri uriSource = new Uri("file://" + filePath);                     var content = new AnalyzeDocumentContent()                     {                          Base64Source= System.BinaryData.FromBytes(fileContent)                         //UrlSource=uriSource                         //Base64Source = BinaryData.FromBytes(Encoding.UTF8.GetBytes(fileContent))                     };                                          Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, modelId, content,"1,2,3");                     AnalyzeResult result = operation.Value;                     Console.WriteLine($"Document was analyzed with model with ID: {result.ModelId}");                     return result;                 }                 catch (Exception ex)                 {                     Console.WriteLine($"An error occurred: {ex.Message}");                     throw;                 }         }

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,100 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,602 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 18,676 Reputation points Moderator
    2024-02-25T03:49:33.5133333+00:00

    Hello @Yonatan Mangisto , Thanks for using Microsoft Q&A Platform.

    Yes, the Document Intelligence does support analyzing multiple pages with custom models. Try to check your pricing tier, for Free tier Max number of pages (Analysis) is 2.

    Otherwise, using this AnalyzeResult.Pages Property you can set page range.

    pages: "<pages>" like pages = { "1-3", "5-6" }.

    Here is the sample code: https://learn.microsoft.com/en-us/dotnet/api/azure.ai.documentintelligence.documentintelligenceclient.analyzedocumentasync?view=azure-dotnet-preview

    Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "<modelId>", analyzeRequest: analyzeRequest, pages: "<pages>", locale: "<locale>", stringIndexType: StringIndexType.TextElements, features: new DocumentAnalysisFeature[] { DocumentAnalysisFeature.OcrHighResolution }, queryFields: new string[] { "<queryFields>" }, outputContentFormat: ContentFormat.Text); 
    
    AnalyzeResult responseData = operation.Value;
    
    

    I hope this helps.

    Regards,

    Vasavi

    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.