빠른 시작
빠른 시작
이 가이드는 Aspose.Slides FOSS를 사용하여 Python에 대한 설치부터 저장된 .pptx 파일까지 가장 빠른 경로를 보여줍니다. 이 라이브러리는 순수 Python이며, MIT 라이선스를 갖고 있고 Microsoft Office나 네이티브 바이너리를 필요로 하지 않습니다.
필수 조건
| 요구 사항 | 세부 사항 |
|---|---|
| Python | 3.10 이상 |
| OS | Windows, macOS, Linux, Docker |
| Package | aspose-slides-foss from PyPI |
Install
pip를 사용하여 PyPI에서 패키지를 설치합니다. 버전 26.3.2 이상이 필요합니다:
pip install aspose-slides-foss프레젠테이션 만들기
인수가 없는 Presentation를 생성하여 빈 데크를 만들세요. 라이브러리는 자동으로 빈 슬라이드 하나를 추가합니다. 경로와 함께 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으로 설정하고, Color.from_argb()를 사용하여 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()를 호출하세요:
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)