이 간단한 방법 주제에서는 Python을 사용하여 PowerPoint를 TIFF로 변환하는 방법과 환경을 설정하는 자세한 단계 및 작동하는 샘플 코드에 중점을 둡니다. 이 항목에서 제공하는 것과 동일한 예제 코드를 사용하여 Python에서 PPT를 TIFF로 변환을 고려할 수도 있습니다. 이 애플리케이션은 MS Windows, Linux 또는 macOS를 포함하여 Python 및 .NET Core Framework로 구성된 모든 운영 체제에서 사용할 수 있습니다.
Python을 사용하여 PowerPoint를 TIFF로 변환하는 단계
- Python 애플리케이션에서 .NET을 통해 Python용 Aspose.Slides를 사용하는 환경 구성
- PPTX를 TIFF로 내보내기 위해 프로젝트에 aspose.pydrawing 및 aspose.slides 네임스페이스 추가
- Presentation 클래스의 인스턴스를 만들어 소스 프레젠테이션을 로드합니다.
- 출력 TIFF 옵션을 설정하는 Tiffoptions 클래스 객체 생성
- DPI 및 이미지 크기 설정을 포함하여 원하는 TIFF 옵션을 설정합니다.
- Python의 Save 메서드는 PPTX를 TIFF로 변환합니다.
위의 단계는 프레젠테이션 클래스를 사용하여 소스 프레젠테이션 파일을 로드하여 프로세스가 시작되는 몇 가지 API 호출을 사용하여 프레젠테이션을 Python에서 TIFF로 변환합니다. 그런 다음 TiffOptions 클래스 개체를 사용하여 이미지 크기 및 DPI를 포함한 출력 TIFF 이미지 옵션을 설정한 다음 save 메서드를 사용하여 디스크에 프레젠테이션을 TIFF 이미지로 저장합니다.
Python에서 PPTX를 TIFF로 변환하는 코드
import aspose.pydrawing as drawing | |
import aspose.slides as slides | |
# Applying the linence for Aspose.Slides | |
slidesLicense = slides.License() | |
slidesLicense.set_license("Aspose.Total.lic") | |
# Open the source presentation using Presentation class object | |
with slides.Presentation("Input.pptx") as tiffPresentationObj: | |
# Create the TiffOptions class object | |
tiffOpts = slides.export.TiffOptions() | |
# Setting the Tiff compression type | |
tiffOpts.compression_type = slides.export.TiffCompressionTypes.DEFAULT | |
# Now, customize the slides notes option inside exported Tiff | |
notesCommentOptions = tiffOpts.notes_comments_layouting | |
notesCommentOptions.notes_position = slides.export.NotesPositions.BOTTOM_FULL | |
# Setting the Tiff image DPI (Dots/inch). The resolution unit is always equal to 2 dots per inch | |
tiffOpts.dpi_x = 200 | |
tiffOpts.dpi_y = 100 | |
# Tiff output Image Size setting | |
tiffOpts.image_size = drawing.Size(1728, 1078) | |
# Saving the presentation to Tiff | |
tiffPresentationObj.save("ExpoertedTiff_out.tiff", slides.export.SaveFormat.TIFF, tiffOpts) | |
위의 예는 Python에서 PPTX를 Tiff로 변환하는 포괄적인 단계와 코드를 제공합니다. TiffOptions 클래스는 또한 compression_type, pixel_format, show_hidden_slides 및 notes_comments_layouting 설정과 같은 옵션을 사용하여 출력 TIFF를 사용자 정의할 수 있습니다. 위의 응용 프로그램은 MS PowerPoint 또는 기타 타사 도구를 설치하지 않고도 PPTX를 TIFF로 원활하게 변환할 수 있습니다.
이 예에서는 간단한 API 인터페이스를 사용하여 Python의 PowerPoint에서 TIFF를 생성하는 방법을 배웠습니다. 프레젠테이션을 HTML로 변환하는 데 관심이 있는 경우 Python을 사용하여 HTML로 PowerPoint 슬라이드를 만드는 방법에 대한 문서를 참조하세요.