ParserGetImages Method (Int32) |
Namespace: GroupDocs.Parser
To extract images from a document page the following method is used:
// Create an instance of Parser class using (Parser parser = new Parser(filePath)) { // Check if the document supports images extraction if (!parser.Features.Images) { Console.WriteLine("Document isn't supports images extraction."); return; } // Get the document info IDocumentInfo documentInfo = parser.GetDocumentInfo(); // Check if the document has pages if (documentInfo.PageCount == 0) { Console.WriteLine("Document hasn't pages."); return; } // Iterate over pages for (int pageIndex = 0; pageIndex<documentInfo.PageCount; pageIndex++) { // Print a page number Console.WriteLine(string.Format("Page {0}/{1}", pageIndex + 1, documentInfo.PageCount)); // Iterate over images // We ignore null-checking as we have checked images extraction feature support earlier foreach (PageImageArea image in parser.GetImages(pageIndex)) { // Print a rectangle and image type Console.WriteLine(string.Format("R: {0}, Text: {1}", image.Rectangle, image.FileType)); } } }