How to analyze only the first and last pages of a PDF document using Azure Document Intelligence SDK

287 views Asked by At

Is there a way to analyze only the first and last pages of a document in DotNet 7 C# program?

I tried with the below C# code but the program is only analyzing the first page and ignoring the rest of the pages

AnalyzeDocumentOperation operation = await client.AnalyzeDocumentFromUriAsync(WaitUntil.Completed, modelId, fileUri, new AnalyzeDocumentOptions() { Pages = { "1", "-1" } });
1

There are 1 answers

1
Rishabh Meshram On BEST ANSWER

Based on the documentation, AnalyzeDocumentOptions.Pages Property can only inputs page list or page number.

So, to process first and last page you need to mention the relevant page numbers to process specific pages.

AnalyzeDocumentOperation  lastPageOperation  =  await  client.AnalyzeDocumentFromUriAsync(WaitUntil.Completed,"prebuilt-layout", fileUri, new  AnalyzeDocumentOptions() { Pages  = { "1","10" } });
//Page 1 and Page 10(Last Page)

Or alternately, you can process the complete document and take the first and last page results based on count of pages.

PageResult.Pages[PageResult.Pages.Count-1] //Page Number of Last Page