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

> Mã mẫu Java để trích xuất văn bản và hình ảnh từ tệp PPTX 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/pptx/
Updated: 2026-08-11



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

 Để phân tích cú pháp tệp PPTX, 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 PPTX 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 PPTX 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 PPTX - Java

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

Files with PPTX extension are presentation files created with popular Microsoft PowerPoint application. Unlike the previous version of presentation file format PPT which was binary, the PPTX format is based on the Microsoft PowerPoint open XML presentation file format. 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.

## 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
- [PPT](https://products.aspose.com/slides/vi/java/parser/ppt/) — Microsoft PowerPoint 97-2003
