PNG JPG BMP TIFF ODP
Aspose.Slides  for Java

在 Java 中解析 ODP 格式

使用用于 Java API 的服务器端 Aspose.Slides 进行本机和高性能 ODP 文档解析,无需使用 Microsoft 或 Adob​​e PDF 等任何软件。

如何使用 Java 解析 ODP 文件

为了解析 ODP 文件,我们将使用

Aspose.Slides for Java

API 是一个功能丰富、功能强大且易于使用的 Java 平台解析 API。您可以直接从

Maven

并通过将以下配置添加到 pom.xml 将其安装在基于 Maven 的项目中。

存储库


<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository>

依赖


<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>version of aspose-slides API</version>
    <classifier>jdk17</classifier>
</dependency>

在 Java 中解析 ODP 文件的步骤

使用 Aspose.Slides for Java API 解析基本文档只需几行代码即可完成。

  1. 通过实例化 Presentation 类加载 ODP 文件。

  2. 获取第一张幻灯片文本框架。

  3. 循环遍历每个段落部分。

  4. 获取所需的输出,如文本、字体等。

系统要求

Aspose.Slides for Java 支持所有主要平台和操作系统。请确保您具有以下先决条件。

  • 适用于 JSP/JSF 应用程序和桌面应用程序的 Microsoft Windows 或具有 Java 运行时环境的兼容操作系统。
  • 直接从 Java 获取最新版本的 Aspose.Slides [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides)。
 

解析 ODP 文件 - Java

//Load ODP file
Presentation odpPresentation = new Presentation("demo.odp");
try{
    //Get an Array of TextFrameEx objects from the first slide
    ITextFrame[] textFramesSlideOne = SlideUtil.getAllTextBoxes(odpPresentation.getSlides().get_Item(0));

    //Loop through the Array of TextFrames
    for (int i = 0; i < textFramesSlideOne.length; i++){
        //Loop through paragraphs in current TextFrame
        for (IParagraph para : textFramesSlideOne[0].getParagraphs()){
            //Loop through portions in the current Paragraph
            for (IPortion port : para.getPortions()){
                //Display text in the current portion
                System.out.print(port.getText());

                //Display font height of the text
                System.out.print(port.getPortionFormat().getFontHeight());

                //Display font name of the text
                System.out.print(port.getPortionFormat().getLatinFont().getFontName());
            }
        }
    }
} finally {
    if (odpPresentation != null) odpPresentation.dispose();
}
//Similarly extarcting text from the Whole Presentation
//Use getAllTextFrames(odpPresentation, true) method and Iterate through Array   

    
 
  • 关于 Aspose.Slides for Java API

    Aspose.Slides API 可用于读取、编写、操作 Microsoft PowerPoint 文档并将其转换为 PDF、XPS、HTML、TIFF、ODP 和各种其他格式。可以从头开始创建新文件并将其保存为相关支持的格式。 Aspose.Slides 是一个独立的 API,用于创建、解析或操作演示文稿、幻灯片和元素,它不依赖于 Microsoft 或 OpenOffice 等任何软件。

    Online ODP Parser Live Demos

    Extract text and images from ODP documents right now by visiting our Live Demos website . The live demo has the following benefits

      No need to download Aspose API.
      No need to write any code.
      Just upload your ODP files.
      It will be parsed instantly.

    ODP 什么是ODP文件格式

    Files with ODP extension represent presentation file format used by OpenOffice.org in the OASISOpen standard. A presentation file is a collection of slides where each slide can comprise of text, images, formatting, animations, and other media. These slides are presented to audience in the form of slideshows with custom presentation settings. ODP files can be opened by applications that conform to the OpenDocument format (such as OpenOffice or StarOffice).

    阅读更多

    其他支持的解析文档

    使用 Java,可以轻松解析其他格式,包括。

    PPT (微软PowerPoint 97-2003)
    PPTX (打开 XML 表示格式)