เริ่มต้นอย่างรวดเร็ว
เริ่มต้นอย่างรวดเร็ว
คู่มือนี้แสดงเส้นทางที่เร็วที่สุดจากการติดตั้งไปยังการบันทึก .pptx ไฟล์ที่ใช้ Aspose.Slides FOSS for Python. The library is pure Python, MIT-licensed, and requires ไม่มี Microsoft Office หรือไบนารีพื้นฐาน.
Prerequisites
| Requirement | Detail |
|---|---|
| Python | 3.10 or later |
| OS | วินโดว์, แมคโอเอส ลิเนกซ์ ดอเกอร์ |
| Package | aspose-slides-foss จาก PyPI |
Install
การติดตั้งแพ็คเกจจาก PyPI โดยใช้ pip. ต้องการเวอร์ชั่น 26.3.2 หรือหลังกว่า:
pip install aspose-slides-foss>=26.3.2สร้าง การ นําเสนอ
สร้าง A Presentation โดยไม่มีการโต้แย้งที่จะสร้างตู้ว่าง. ห้องสมุด เพิ่มสไลด์ว่าง 1 ภาพโดยอัตโนมัติ. โทรหา save() มีเส้นทางและ SaveFormat.PPTX เพื่อเขียนไฟล์:
from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
prs.save("empty.pptx", SaveFormat.PPTX)เพิ่มรูปแบบด้วยข้อความ
เข้าไปกับสไลด์แรกผ่าน prs.slides[0], แล้วใส่สี่เหลี่ยม โดยใช้ slide.shapes.add_auto_shape().โทรหาฉันนะ add_text_frame() เพื่อติดกรอบข้อความ และกําหนดคุณสมบัติตัวอักษรผ่าน portion_format:
from aspose.slides_foss import Presentation, ShapeType
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 400, 150)
tf = shape.add_text_frame("Hello from Aspose.Slides FOSS!")
tf.paragraphs[0].portions[0].portion_format.font_height = 24
prs.save("with_shape.pptx", SaveFormat.PPTX)ใช้ เติม ที่ มั่นคง
เซ็ต fill_format.fill_type ไปยัง FillType.SOLID, แล้วให้สี ARGB โดยใช้ Color.from_argb().สีถูกนําไปใช้ในพื้นหลังรูปแบบ ก่อนการบันทึก:
from aspose.slides_foss import Presentation, ShapeType, FillType
from aspose.slides_foss.export import SaveFormat
from aspose.slides_foss.drawing import Color
prs = Presentation()
shape = prs.slides[0].shapes.add_auto_shape(
ShapeType.RECTANGLE, 100, 100, 400, 200
)
shape.fill_format.fill_type = FillType.SOLID
shape.fill_format.solid_fill_color.color = Color.from_argb(255, 70, 130, 180)
shape.add_text_frame("Styled shape")
prs.save("styled.pptx", SaveFormat.PPTX)อัตราการอัพโหลดไฟล์ที่มีอยู่
ส่งทางไฟล์ไปยัง Presentation คอนสตรัคเตอร์ที่จะเปิดตัวที่มีอยู่ .pptx แฟ้ม. อ่านการนับสไลด์ ปรับเปลี่ยนเกม ตามความต้องการ แล้วเรียก save() เพื่อเขียน output:
from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat
prs = Presentation("existing.pptx")
print(f"Slides: {len(prs.slides)}")
prs.save("copy.pptx", SaveFormat.PPTX)