Parse PPT files in Java
Extract text and presentation content from PPT documents using server-side Aspose.Slides for Java APIs.
Parse PPT File Using Java
Use
Aspose.Slides for Java
to parse PPT presentations and extract text from slides. You can add the library to a Maven-based project by using the repository and dependency configuration below in your pom.xml file.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-slides</artifactId>
<version>version of aspose-slides API</version>
<classifier>jdk17</classifier>
</dependency>
How to Parse PPT Files in Java
Extract text from a PPT presentation with Aspose.Slides for Java in a few lines of code.
Load the
PPTfile with thePresentationclass.Call the
SlideUtil.getAllTextBoxesmethod to get text frames from the first slide.Loop through each
ITextFrame,IParagraph, andIPortionobject.Read text, font height, and font name from each
IPortionobject.
System Requirements
Aspose.Slides for Java supports major platforms and operating systems. Make sure that your environment includes the following prerequisites.
- Microsoft Windows or a compatible operating system with a Java Runtime Environment for JSP/JSF applications and desktop applications.
- The latest version of Aspose.Slides for Java from Maven .
Parse PPT Files - Java
Presentation presentation = new Presentation("demo.ppt");
try {
ISlide slide = presentation.getSlides().get_Item(0);
ITextFrame[] slideTextFrames = SlideUtil.getAllTextBoxes(slide);
for (ITextFrame textFrame : slideTextFrames) {
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
System.out.print(portion.getText());
System.out.print(portion.getPortionFormat().getFontHeight());
System.out.print(portion.getPortionFormat().getLatinFont().getFontName());
}
}
}
} finally {
presentation.dispose();
}
About Aspose.Slides for Java API
Aspose.Slides for Java can read, write, manipulate, and convert presentation documents to formats such as PDF, XPS, HTML, TIFF, and ODP. It is a standalone API for creating, parsing, and manipulating presentations, slides, and slide elements.Online PPT Parser Live Demos
PPT What is PPT File Format?
A PPT file stores a PowerPoint 97-2003 presentation in the binary file format. It can contain slides with text, images, charts, multimedia, and embedded objects.
Read More