# Trích xuất văn bản và hình ảnh từ tài liệu PPT qua Java

> Mã mẫu Java để trích xuất văn bản và hình ảnh từ tệp PPT trên Môi trường thời gian chạy Java cho Ứng dụng JSP / JSF và Ứng dụng máy tính để bàn.

Source: https://products.aspose.com/slides/vi/java/parser/ppt/
Updated: 2026-08-11



## Cách phân tích cú pháp tệp PPT bằng Java

 Để phân tích cú pháp tệp PPT, chúng tôi sẽ sử dụng
 [Aspose.Slides dành cho Java](https://products.aspose.com/slides/vi/java/)
 API là một API phân tích cú pháp giàu tính năng, mạnh mẽ và dễ sử dụng cho nền tảng Java. Bạn có thể tải xuống phiên bản mới nhất của nó trực tiếp từ
 [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides)
 và cài đặt nó trong dự án dựa trên Maven của bạn bằng cách thêm các cấu hình sau vào pom.xml.

### Kho

```xml

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

```

### Sự phụ thuộc

```xml

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>26.8</version>
    <classifier>jdk16</classifier>
</dependency>
```

## Các bước để phân tích cú pháp tệp PPT trong Java

Có thể thực hiện phân tích cú pháp tài liệu cơ bản với API [Aspose.Slides for Java](https://products.aspose.com/slides/vi/java/) chỉ với vài dòng mã.

Tải tệp PPT bằng cách cài đặt lớp Trình bày.

Nhận khung văn bản trang chiếu đầu tiên.

Lặp qua từng phần đoạn văn.

Nhận đầu ra cần thiết như văn bản, phông chữ, v.v.

## yêu cầu hệ thống

 Aspose.Slides cho Java hỗ trợ trên tất cả các nền tảng và Hệ điều hành chính. Vui lòng đảm bảo rằng bạn có các điều kiện tiên quyết sau.

- Microsoft Windows hoặc hệ điều hành tương thích với Môi trường thời gian chạy Java cho Ứng dụng JSP / JSF và Ứng dụng máy tính để bàn.
- Nhận phiên bản mới nhất của Aspose.Slides cho Java trực tiếp từ
 [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides).

### Phân tích cú pháp tệp PPT - Java

```cs
//Load PPT file
Presentation pptPresentation = new Presentation("demo.ppt");
try{
    //Get an Array of TextFrameEx objects from the first slide
    ITextFrame[] textFramesSlideOne = SlideUtil.getAllTextBoxes(pptPresentation.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 (pptPresentation != null) pptPresentation.dispose();
}
//Similarly extarcting text from the Whole Presentation
//Use getAllTextFrames(pptPresentation, true) method and Iterate through Array

```

## Giới thiệu về Aspose.Slides cho Java API

 API Aspose.Slides có thể được sử dụng để đọc, viết, thao tác và chuyển đổi tài liệu Microsoft PowerPoint sang PDF, XPS, HTML, TIFF, ODP và nhiều định dạng khác. Người ta có thể tạo các tệp mới từ đầu và lưu chúng ở các định dạng được hỗ trợ có liên quan. Aspose.Slides là một API độc lập để tạo, phân tích cú pháp hoặc thao tác với các bản trình bày, trang trình bày và các phần tử và nó không phụ thuộc vào bất kỳ phần mềm nào như Microsoft hoặc OpenOffice.

A file with PPT extension represents PowerPoint file that consists of a collection of slides for displaying as SlideShow. It specifies the Binary File Format used by Microsoft PowerPoint 97-2003. A PPT file can contain several different types of information such as text, bulleted points, images, multimedia and other embedded OLE objects. Microsoft came up with newer file format for PowerPoint, known as PPTX, from 2007 onwards that is based on Office OpenXML and is different from this binary file format. Several other application programs such as OpenOffice Impress and Apple Keynote can also create PPT files.

## Các tài liệu phân tích cú pháp được hỗ trợ khác

- [ODP](https://products.aspose.com/slides/vi/java/parser/odp/) — Định dạng bản trình bày OpenDocument
- [PPTX](https://products.aspose.com/slides/vi/java/parser/pptx/) — Định dạng bản trình bày XML mở
