Image Extraction

Table of Contents

Image Extraction

The Image Extraction example will extract all image content from a PDF page and save the images to disk. The image data is converted to RGB and the images is saved at the original size as defined by the image object reference. For converting PDF pages to image see

Page currentPage = document.getPageTree().getPage(pageNumber);
int count = 0;
RenderedImage rendImage;
List<Image> images = currentPage.getImages();
for (Image image : images) {
    if (image != null) {
        rendImage = (BufferedImage) image;
        System.out.println("Capture page " + pageNumber + " image " + count);
        File file = new File("imageCapture_" + pageNumber + "_" + count + ".png");
        ImageIO.write(rendImage, "png", file);
// clears most resource.

The source-code for this example is located at:

A primer on using Maven or Gradle build commands can be found here (Maven) and here (Gradle)

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2017 ICEsoft Technologies Canada Corp.