Python만으로도 다른 외부 소프트웨어 없이 PowerPoint 및 OpenOffice 프레젠테이션을 만들고, 읽고, 사용자 정의하고, 결합하고, 복제하거나 변환하는 방법을 알고 싶다면, 저희가 도와드리겠습니다.
Aspose.Slides for Python via .NET은 프레젠테이션을 조작하기 위한 클래스 라이브러리로, 처음부터 프레젠테이션을 만들고, 변환하고, 텍스트·도형·표·애니메이션을 관리하며, 슬라이드 미리보기, 슬라이드 PDF·TIFF·XPS·HTML 등으로 내보내기 등 다양한 핵심 기능을 제공합니다. Aspose.Slides for Python via .NET은 API 이해를 돕기 위해 데모와 실용 예제를 제공합니다.
우리 API는 다음과 같은 기능을 제공합니다:
- 템플릿에서 슬라이드 생성 또는 복제
- PowerPoint 표 작업
- 도형에 대한 보호 설정 추가·제거
- MS Excel 차트를 OleObject로 추가
- 데이터베이스에서 프레젠테이션 생성
- 프레젠테이션 보호
- 차트 생성 및 수정
- 프레젠테이션을 PDF·XPS·HTML·JPEG·PNG·SVG 등 다양한 형식으로 내보내기
지원되는 파일 형식:
Aspose.Slides for Python via .NET은 다음 파일 형식을 로드하고 저장할 수 있습니다: PPT, POT, PPS, PPTX, POTX, PPSX, PPTM, PPSM, POTM, ODP, OTP. 또한 TIFF, EMF, PDF, XPS, JPEG, PNG, GIFF, BMP, SVG, SWF, HTML, XAML 형식으로 저장할 수 있습니다.
아래에서는 프레젠테이션을 생성·열기·병합·저장하는 방법을 보여주고 코드 예제를 제공합니다.

Python을 사용하여 PowerPoint (PPTX) 프레젠테이션 만들기
Aspose.Slides for Python via .NET을 사용해 슬라이드에 새 라인을 추가하려면 다음 단계를 따르세요:
- Presentation 클래스 인스턴스 생성
- 인덱스로 슬라이드 참조 얻기
shapes 객체의 add_auto_shape 메서드를 사용해 LINE 유형의 AutoShape 추가
- 프레젠테이션을 PPTX 파일로 저장
위 단계를 사용해 첫 번째 슬라이드에 라인을 추가한 예시입니다:
import aspose.slides as slides
# Instantiate a Presentation object that represents a presentation file
with slides.Presentation() as presentation:
slide = presentation.slides[0]
slide.shapes.add_auto_shape(slides.ShapeType.LINE, 50, 150, 300, 0)
presentation.save("NewPresentation_out.pptx", slides.export.SaveFormat.PPTX)
Python을 사용하여 프레젠테이션 열기
Aspose.Slides for Python via .NET을 사용하면 개발자가 기존 PowerPoint 프레젠테이션에 접근하거나 수정할 수 있습니다.
우리 API는 기존 프레젠테이션을 열기 위한 Presentation 클래스를 제공하며, 해당 클래스의 적절한 생성자를 사용해 기존 PowerPoint 파일을 기반으로 객체를 만들 수 있습니다. 아래 예시에서는 Presentation을 여는 방법을 보여줍니다. 생성자에 프레젠테이션 파일명을 전달하고, 슬라이드 총 개수를 화면에 출력합니다.
import aspose.slides as slides
# Opening the presentation file by passing the file path to the constructor of Presentation class
with slides.Presentation("pres.pptx") as pres:
# Printing the total number of slides present in the presentation
print(pres.slides.length)
그리고 프레젠테이션 크기가 3 GB와 같이 매우 큰 경우에는 아래 샘플 코드를 사용해 열 수 있습니다:
import aspose.slides as slides
import os
loadOptions = slides.LoadOptions()
loadOptions.blob_management_options = slides.BlobManagementOptions()
loadOptions.blob_management_options.presentation_locking_behavior = slides.PresentationLockingBehavior.KEEP_LOCKED
with slides.Presentation("pres.pptx", loadOptions) as pres:
# the huge presentation is loaded and ready to use, but the memory consumption is still low.
# make any changes to the presentation.
pres.slides[0].name = "Very large presentation"
# presentation will be saved to the other file, the memory consumptions still low during saving.
pres.save("veryLargePresentation-copy.pptx", slides.export.SaveFormat.PPTX)
# can't do that! IO exception will be thrown, because the file is locked while pres objects will
# not be disposed
os.remove("pres.pptx")
# it's ok to do it here, the source file is not locked by pres object
os.remove("pres.pptx")
프레젠테이션에 대용량 이미지·비디오·오디오 등 큰 객체가 포함된 경우, 메모리 사용량을 줄이기 위해 Blob facility
를 사용하세요.
Python을 사용하여 PowerPoint 프레젠테이션 병합하기
Aspose.Slides for Python via .NET을 사용하면 다양한 방식으로 프레젠테이션을 병합할 수 있습니다. 도형·서식·텍스트·스타일·주석 등을 손실 없이 병합할 수 있으며, 전체 프레젠테이션, 특정 슬라이드, 동일 형식(PPTX→PPTX, PPT→PPT 등) 또는 서로 다른 형식(PPTX→PPT, PPTX→ODP 등)으로 병합할 수 있습니다.
병합을 위해서는 add_clone
메서드( ISlideCollection
인터페이스) 를 사용할 수 있습니다. Presentation 객체는 슬라이드 컬렉션을 포함하고 있으며, 선택한 프레젠테이션에서 add_clone 메서드를 호출하면 해당 슬라이드가 병합됩니다.
프레젠테이션 병합
AddClone (ISlide)
메서드를 사용하면 기본 매개변수로 슬라이드 외관과 스타일이 유지된 채로 슬라이드를 결합할 수 있습니다.
아래 코드에서 프레젠테이션을 병합하는 방법을 확인하세요:
import aspose.slides as slides
with slides.Presentation("pres.pptx") as pres1:
with slides.Presentation("Presentation1.pptx") as pres2:
for slide in pres2.slides:
pres1.slides.add_clone(slide)
pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
프레젠테이션을 병합하면서 슬라이드 스타일 변경
병합 중에 출력 프레젠테이션의 슬라이드 스타일을 바꾸고 싶다면, add_clone (ISlide, IMasterSlide, Boolean)
메서드를 사용할 수 있습니다.
import aspose.slides as slides
with slides.Presentation("pres.pptx") as pres1:
with slides.Presentation("Presentation1.pptx") as pres2:
for slide in pres2.slides:
pres1.slides.add_clone(slide, pres1.masters[0], allow_clone_missing_layout = True)
pres1.save("combined_with_master.pptx", slides.export.SaveFormat.PPTX)
특정 슬라이드만 병합
아래 코드를 사용하면 서로 다른 프레젠테이션에서 선택한 슬라이드만 결합해 하나의 출력 프레젠테이션을 만들 수 있습니다:
import aspose.slides as slides
with slides.Presentation("pres.pptx") as pres1:
with slides.Presentation("Presentation1.pptx") as pres2:
for slide in pres2.slides:
pres1.slides.add_clone(slide, pres1.layout_slides[0])
pres1.save("combined_with_layout.pptx", slides.export.SaveFormat.PPTX)
프레젠테이션 병합에 대한 추가 방법은 문서의 프레젠테이션 병합
섹션을 참고하세요.
Python을 사용하여 PowerPoint 프레젠테이션 저장하기
Aspose.Slides for Python via .NET을 사용하면 프레젠테이션을 파일이나 스트림으로 저장할 수 있습니다. 아래에서는 두 방법에 대한 샘플 코드를 제공합니다.
파일로 프레젠테이션 저장
Presentation
클래스의 Save 메서드를 호출하면 파일로 저장할 수 있습니다.
아래 코드에서는 파일명과 저장 형식을 전달해 Aspose.Slides for Python via .NET으로 프레젠테이션을 저장하는 방법을 보여줍니다.
import aspose.slides as slides
# Instantiate a Presentation object that represents a PPT file
with slides.Presentation() as presentation:
#...do some work here...
# Save your presentation to a file
presentation.save("Saved_out.pptx", slides.export.SaveFormat.PPTX)
스트림으로 프레젠테이션 저장
프레젠테이션을 스트림에 저장하려면 출력 스트림을 Presentation
클래스의 Save 메서드에 전달하면 됩니다. 아래 예시에서는 새 Presentation 파일을 만들고, 도형에 텍스트를 추가한 뒤 스트림에 저장합니다.
import aspose.slides as slides
# Instantiate a Presentation object that represents a PPT file
with slides.Presentation() as presentation:
shape = presentation.slides[0].shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 200, 200, 200, 200)
# Save your presentation to a stream
with open("Save_As_Stream_out.pptx", "bw") as stream:
presentation.save(stream, slides.export.SaveFormat.PPTX)
우리 문서에서는 미리 정의된 View Type으로 프레젠테이션 저장
, Strict Open XML 스프레드시트 형식으로 저장
, 혹은 진행률을 백분율로 저장
하는 방법을 확인할 수 있습니다.
Aspose.Slides for Python via .NET은 Python 3.5, 3.6, 3.7, 3.8, 3.9와 호환되며, Linux에서 Python 코드를 작성할 경우 추가 Linux 요구 사항
을 확인하세요.
유료 컨설팅
프로젝트에 도움이 필요하시면, 전문가
가 귀하의 프로젝트에 함께 참여해 솔루션을 설계하고 API를 요구에 맞게 구현해 드립니다. 저희가 힘든 작업을 맡아드리니 귀하는 비즈니스에 집중하시면 됩니다.