# แยกข้อความและรูปภาพจากเอกสาร PPTX ผ่าน Java

> โค้ดตัวอย่าง Java เพื่อแยกข้อความและรูปภาพจากไฟล์ PPTX บน Java Runtime Environment สำหรับแอปพลิเคชัน JSP/JSF และแอปพลิเคชันเดสก์ท็อป

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



## วิธีแยกไฟล์ PPTX โดยใช้ Java

 ในการแยกวิเคราะห์ไฟล์ PPTX เราจะใช้
 [Aspose.Slides สำหรับ Java](https://products.aspose.com/slides/th/java/)
 API ซึ่งเป็น API การแยกวิเคราะห์ที่มีคุณลักษณะหลากหลาย มีประสิทธิภาพ และใช้งานง่ายสำหรับแพลตฟอร์ม Java คุณสามารถดาวน์โหลดเวอร์ชันล่าสุดได้โดยตรงจาก
 [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides)
 และติดตั้งภายในโปรเจ็กต์ที่ใช้ Maven โดยเพิ่มการกำหนดค่าต่อไปนี้ใน pom.xml

### ที่เก็บ

```xml

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

```

### การพึ่งพา

```xml

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

## ขั้นตอนในการแยกวิเคราะห์ไฟล์ PPTX ใน Java

การแยกวิเคราะห์เอกสารพื้นฐานด้วย API ของ [Aspose.Slides for Java](https://products.aspose.com/slides/th/java/) สามารถทำได้โดยใช้โค้ดเพียงไม่กี่บรรทัด

โหลดไฟล์ PPTX โดยสร้างคลาสการนำเสนอ

รับกรอบข้อความสไลด์แรก

วนซ้ำแต่ละส่วนย่อหน้า

รับผลลัพธ์ที่ต้องการ เช่น ข้อความ แบบอักษร ฯลฯ

## ความต้องการของระบบ

 Aspose.Slides สำหรับ Java รองรับบนแพลตฟอร์มหลักและระบบปฏิบัติการทั้งหมด โปรดตรวจสอบให้แน่ใจว่าคุณมีข้อกำหนดเบื้องต้นดังต่อไปนี้

- Microsoft Windows หรือ OS ที่เข้ากันได้กับ Java Runtime Environment สำหรับแอปพลิเคชัน JSP/JSF และแอปพลิเคชันเดสก์ท็อป
- รับเวอร์ชันล่าสุดของ Aspose.Slides สำหรับ Java โดยตรงจาก
 [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides)

### แยกไฟล์ 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

```

## เกี่ยวกับ Aspose.Slides สำหรับ Java API

 Aspose.Slides API สามารถใช้อ่าน เขียน จัดการ และแปลงเอกสาร Microsoft PowerPoint เป็น PDF, XPS, HTML, TIFF, ODP และรูปแบบอื่นๆ ได้ หนึ่งสามารถสร้างไฟล์ใหม่ตั้งแต่เริ่มต้นและบันทึกในรูปแบบที่รองรับที่เกี่ยวข้อง Aspose.Slides เป็น API แบบสแตนด์อโลนสำหรับการสร้าง แยกวิเคราะห์ หรือจัดการการนำเสนอ สไลด์ และองค์ประกอบ และไม่ขึ้นกับซอฟต์แวร์ใดๆ เช่น Microsoft หรือ 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.

## เอกสารแยกวิเคราะห์อื่นๆ ที่รองรับ

- [ODP](https://products.aspose.com/slides/th/java/parser/odp/) — รูปแบบการนำเสนอ OpenDocument
- [PPT](https://products.aspose.com/slides/th/java/parser/ppt/) — Microsoft PowerPoint 97-2003
