# แยกข้อความและรูปภาพจากไฟล์ ODP โดยใช้ Python

> ซอร์สโค้ด Python เพื่อแยกวิเคราะห์การนำเสนอ ODP

Source: https://products.aspose.com/slides/th/python-net/parser/odp/
Updated: 2023-05-01



## แยกข้อความจากการนำเสนอ ODP ผ่าน Python

หากต้องการสแกนข้อความจากงานนำเสนอทั้งหมด ให้ใช้เมธอดแบบสแตติก [GetAllTextFrames](https://reference.aspose.com/slides/python-net/aspose.slides.util/slideutil/) ที่เปิดเผยโดยคลาส SlideUtil โค้ดด้านล่างจะสแกนข้อความและข้อมูลการจัดรูปแบบจากงานนำเสนอ รวมถึงสไลด์ต้นแบบ

### แยกข้อความจากงานนำเสนอ ODP โดยใช้ Python

```py

import aspose.slides as slides

#Instatiate Presentation class that represents a ODP file
with slides.Presentation("pres.odp") as pptxPresentation:
    # Get an Array of ITextFrame objects from all slides in the ODP
    textFramesPPTX = slides.util.SlideUtil.get_all_text_frames(pptxPresentation, True)

    # Loop through the Array of TextFrames
    for i in range(len(textFramesPPTX)):
	    # Loop through paragraphs in current ITextFrame
        for para in textFramesPPTX[i].paragraphs:
            # Loop through portions in the current IParagraph
            for port in para.portions:
			    # Display text in the current portion
                print(port.text)

    			# Display font height of the text
                print(port.portion_format.font_height)

			    # Display font name of the text
                if port.portion_format.latin_font != None:
                    print(port.portion_format.latin_font.font_name)
```

## วิธีแยกข้อความจาก ODP ผ่าน Python

นี่คือขั้นตอนในการแยกวิเคราะห์ไฟล์ ODP

โหลด ODP ด้วยอินสแตนซ์ของงานนำเสนอ

รับวัตถุ Array of TextFrame จากสไลด์ทั้งหมดใน ODP

วนซ้ำ Array ของ TextFrames

วนซ้ำย่อหน้าใน TextFrame ปัจจุบัน

วนซ้ำส่วนต่างๆ ในย่อหน้าปัจจุบัน

รับข้อความในส่วนปัจจุบัน

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