Follow these steps to extract images from ODP documents using GroupDocs.Parser in your Java application:
- Create a Parser instance and load the ODP file.
- Extract image data from the loaded document.
- Use or export the extracted images as needed.
Follow these steps to extract images from ODP documents using GroupDocs.Parser in your Java application:
// Initialize parser and load the document with images using Parser
try (Parser parser = new Parser("input.odp"))
{
// Collect all image elements embedded in the document
Iterable<PageImageArea> images = parser.getImages();
// Skip processing if the document has no images
if (images == null) {
return;
}
// Handle each image as required
for (PageImageArea image : images) {
System.out.println(String.format("Page: %d, R: %s, Type: %s", image.getPage().getIndex(),
image.getRectangle(), image.getFileType()));
}
}
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-parser</artifactId>
<version>24.9</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://repository.groupdocs.com/repo/</url>
</repository>
</repositories>
In addition to image extraction, GroupDocs.Parser allows you to extract raw content like text, links, metadata, and structured data for processing and analysis.
Extract images from different document types including PDF, DOCX, PPTX, XLSX, and image formats like PNG, JPEG, and GIF.
All extracted images retain their original resolution and file type to ensure consistent quality and usability.
Customize the image extraction process by filtering images by type, size, page index, or file format.
This example shows how to extract images from a PDF document and save them individually on your device.
// Use Parser to open the PDF file
try (Parser parser = new Parser("input.pdf"))
{
// Get the images from the document content
Iterable<PageImageArea> images = parser.getImages();
// Set output parameters like format (e.g., JPEG or PNG)
ImageOptions options = new ImageOptions(ImageFormat.Png);
// Save extracted images to a local directory
int imageNumber = 0;
for (PageImageArea image : images)
{
image.save(Constants.getOutputFilePath(String.format("%d.png", imageNumber)), options);
imageNumber++;
}
}
Download GroupDocs.Parser for free or get a trial license for full access!
Explore documentation, code samples, and community support to enhance your experience.
GroupDocs.Parser supports image extraction across a broad array of documents and images. Explore the commonly supported formats below.