Python을 사용하여 PPTX에 초안 워터마크를 삽입하는 방법

이 단계별 자습서에서는 MS PowerPoint에 의존하지 않고 Python**을 사용하여 **PPTX에 임시 워터마크를 삽입하는 방법에 대해 자세히 설명합니다. 이 애플리케이션을 사용하여 Windows, Linux 또는 macOS 내부의 모든 .NET Core 및 Python 지원 환경에서 Python을 사용하는 PowerPoint에 워터마크 초안을 추가할 수 있습니다.

Python에서 PowerPoint에 기밀 워터마크를 추가하는 단계

  1. 프레젠테이션에 워터마크 텍스트 삽입을 위한 .NET을 통한 Python용 Aspose.Slides 설치 환경 설정
  2. 새 프레젠테이션을 만들거나 기존 프레젠테이션을 로드하여 Presentation 클래스 개체를 사용하여 워터마크를 삽입합니다.
  3. 프레젠테이션 내 Master Slide/s 프레젠테이션을 반복합니다.
  4. 마스터 슬라이드 컬렉션 내의 모든 슬라이드에 대해 기밀 워터마크 텍스트가 있는 자동 모양 추가
  5. 도형 및 텍스트 속성의 서식을 지정하고 도형에 잠금을 적용하여 워터마크를 보호합니다.
  6. 워터마크가 있는 프레젠테이션을 디스크에 저장

앞서 언급한 단계에 따라 Python*을 사용하여 PPTX 내부에 *기밀 워터마크를 삽입할 수 있습니다. 그러면 Presentation 클래스의 인스턴스를 사용하여 기존 프레젠테이션을 로드하거나 새 프레젠테이션을 생성하여 프로세스가 시작됩니다. 그런 다음 마스터 슬라이드 컬렉션 내의 모든 슬라이드를 반복하고 그 안에 초안 워터마크 텍스트 모양을 추가합니다. 마지막으로 auto_shape_lock 클래스 인스턴스에 의해 노출된 다른 잠금으로 모양을 보호하고 워터마크가 표시된 프레젠테이션을 디스크에 저장합니다.

Interop 없이 Python을 사용하여 PowerPoint에서 초안 워터마크를 추가하는 코드

from os import system
import aspose.pydrawing as drawing
import aspose.slides as slides
filepath = "C://Slides//"
#Apply the licence for Aspose.Slides
slidesTextWatermarkLicense = slides.License()
slidesTextWatermarkLicense.set_license(filepath + "Conholdate.Total.Product.Family.lic")
# Generate an empty presentation using Presentation class object
with slides.Presentation() as textWatermarkPptxPresentation:
#Iterate through the master slide collection for adding a watermark text
for masterSlide in textWatermarkPptxPresentation.masters:
#Adding a shape to hold the watermark
pptxTextWatermark = masterSlide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE,
textWatermarkPptxPresentation.slide_size.size.width / 2 - 50,
textWatermarkPptxPresentation.slide_size.size.height / 2 - 50,
200, 50)
#Setting the rotation angle and fill type of the shape
pptxTextWatermark.rotation = 325
pptxTextWatermark.fill_format.fill_type = slides.FillType.NO_FILL
#Add the Text frame with watermark text
watermarkTextFrame = pptxTextWatermark.add_text_frame("Confidential Draft")
#set the textual properties of the watermark text
watermarkTextFormat = watermarkTextFrame.paragraphs[0].portions[0].portion_format
watermarkTextFormat.font_bold = slides.NullableBool.TRUE
watermarkTextFormat.font_italic = slides.NullableBool.TRUE
watermarkTextFormat.font_height = 20
watermarkTextFormat.fill_format.fill_type = slides.FillType.SOLID
watermarkTextFormat.fill_format.solid_fill_color.color = drawing.Color.red
#Lock the Pptx watermark shape and make it uneditable in PowerPoint
pptxTextWatermark.auto_shape_lock.text_locked=True
pptxTextWatermark.auto_shape_lock.select_locked = True
pptxTextWatermark.auto_shape_lock.position_locked = True
#Save the presentations with a text watermark on the disk
textWatermarkPptxPresentation.save(filepath + "PresentationWithWatermarkText.pptx", slides.export.SaveFormat.PPTX)
print("Finished")

이 예제는 간단한 API 호출의 도움으로 Python에서 PowerPoint에 기밀 워터마크를 추가하기 위해 PPT 및 ODP 프레젠테이션 형식에도 사용할 수 있습니다. 모양 잠금 기능은 MS PowerPoint에서 사용할 수 없는 API에서 제공하는 고유한 기능입니다. 잠금 기능을 구현하여 워터마크 모양을 보호하고 PowerPoint 내부에서도 누구나 수정하거나 제거할 수 없도록 하여 프레젠테이션의 지적 재산권을 보호할 수 있습니다.

이 주제에서는 Python에서 PowerPoint에 초안 워터마크를 추가하고 프레젠테이션을 보호하는 방법을 배웠습니다. 프레젠테이션에 HTML 콘텐츠를 추가하는 방법에 대해 알아보려면 Python을 사용하여 PowerPoint에 HTML을 삽입하는 방법의 문서를 참조하세요.

 한국인