PPT PPTX ODP POT ppsx
Aspose.Slides  for Python via .NET
PPT

แยกข้อความและรูปภาพจากงานนำเสนอ PPT โดยใช้ Python

สร้างแอป Python ของคุณเองเพื่อแยกข้อความ รูปภาพ วิดีโอ และไฟล์เสียงจาก PowerPoint โดยใช้ API ฝั่งเซิร์ฟเวอร์

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

หากต้องการสแกนข้อความจากงานนำเสนอทั้งหมด ให้ใช้เมธอดแบบสแตติก GetAllTextFrames ที่เปิดเผยโดยคลาส SlideUtil โค้ดด้านล่างจะสแกนข้อความและข้อมูลการจัดรูปแบบจากงานนำเสนอ รวมถึงสไลด์ต้นแบบ

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


import aspose.slides as slides

#Instatiate Presentation class that represents a PPT file
with slides.Presentation("pres.ppt") as pptxPresentation:
    # Get an Array of ITextFrame objects from all slides in the PPT
    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)

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

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

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

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

  3. วนซ้ำ Array ของ TextFrames

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

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

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

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

เมื่อใช้ Python คุณยังสามารถสแกนรูปแบบต่อไปนี้: