Iterate through the collection and get sizes, image types and image contents.
The following example shows how to extract images from a document page:
// Create an instance of Parser class
try(Parserparser=newParser(Constants.SampleImagesPdf)){// Check if the document supports images extraction
if(!parser.getFeatures().isImages()){System.out.println("Document isn't supports images extraction.");return;}// Get the document info
IDocumentInfodocumentInfo=parser.getDocumentInfo();// Check if the document has pages
if(documentInfo.getPageCount()==0){System.out.println("Document hasn't pages.");return;}// Iterate over pages
for(intpageIndex=0;pageIndex<documentInfo.getPageCount();pageIndex++){// Print a page number
System.out.println(String.format("Page %d/%d",pageIndex+1,documentInfo.getPageCount()));// Iterate over images
// We ignore null-checking as we have checked images extraction feature support earlier
for(PageImageAreaimage:parser.getImages(pageIndex)){// Print a rectangle and image type
System.out.println(String.format("R: %s, Text: %s",image.getRectangle(),image.getFileType()));}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: