Python에서 PowerPoint PPT 슬라이드에 주석 추가

종종 프레젠테이션의 내용은 피드백을 받기 위해 다른 사람들이 검토해야 합니다. PowerPoint에서 주석은 슬라이드의 특정 단어, 구 또는 기타 항목에 대한 피드백을 작성하는 데 사용됩니다. 이 기사에서는 Python에서 프로그래밍 방식으로 PowerPoint PPT 슬라이드에 주석을 추가하는 방법에 대해 설명합니다. 또한 기존 댓글을 읽고 답글을 추가하는 방법을 배우게 됩니다.

PowerPoint PPT에 주석을 추가하는 Python 라이브러리

댓글과 답변을 추가하고 읽으려면 .NET을 통한 Python용 Aspose.Slides를 사용합니다. 라이브러리는 처음부터 풍부한 PowerPoint 프레젠테이션을 만들 수 있도록 설계되었습니다. 또한 기존 프레젠테이션을 원활하게 조작할 수 있습니다. 다음 명령을 사용하여 PyPI에서 애플리케이션에 라이브러리를 설치할 수 있습니다.

> pip install aspose.slides

Python에서 PPT 슬라이드에 주석 추가

PowerPoint 프레젠테이션에서 주석은 작성자와 연결됩니다. 반면, 각 주석에는 생성 시간, 추가된 슬라이드 및 위치와 같은 몇 가지 추가 정보가 포함되어 있습니다. 다음은 Python을 사용하여 PPT의 슬라이드에 주석을 추가하는 단계입니다.

  • 먼저 프레젠테이션 파일을 로드하거나 Presentation 클래스를 사용하여 새로 만듭니다.
  • 그런 다음 새 슬라이드를 추가하거나 Presentation.slides 컬렉션에서 기존 슬라이드의 참조를 가져옵니다.
  • Presentation.comment\authors.add\author(string, string) 메서드를 사용하여 새 작성자를 작성자 컬렉션에 추가합니다.
  • 개체에서 새로 생성된 작성자의 참조를 가져옵니다.
  • 주석의 위치를 정의합니다.
  • Author.comments.add\comment(string, ISlide, point, date) 메서드를 사용하여 주석을 추가합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 프레젠테이션을 저장합니다.

다음 코드 샘플은 Python에서 PPT 슬라이드에 주석을 추가하는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing
import datetime

# Create presentation
with slides.Presentation() as presentation:
    # Add empty slide
    presentation.slides.add_empty_slide(presentation.layout_slides[0])

    # Add author
    author = presentation.comment_authors.add_author("Usman", "MF")

    # Set position of comment
    point = drawing.PointF(0.2, 0.2)

    # Add slide comment for an author on slide 1
    author.comments.add_comment("Hello, this is slide comment", presentation.slides[0], point, datetime.date.today())

    # Add slide comment for an author on slide 1
    author.comments.add_comment("Hello, this is second slide comment", presentation.slides[1], point, datetime.date.today())

    # Save presentation
    presentation.save("ppt-comments.pptx", slides.export.SaveFormat.PPTX)

다음은 댓글을 추가한 후 얻은 슬라이드의 스크린샷입니다.

Python에서 PPT 슬라이드에 주석 삽입

Python의 PPT 슬라이드에 댓글 답글 추가

Aspose.Slides를 사용하면 댓글에 답글을 추가할 수도 있습니다. 응답 자체는 기존 주석과 연결된 주석입니다. 이제 Python에서 PowerPoint PPT 슬라이드의 주석에 답글을 추가하는 방법을 살펴보겠습니다.

  • 먼저 프레젠테이션 파일을 로드하거나 Presentation 클래스를 사용하여 새로 만듭니다.
  • 그런 다음 새 슬라이드를 추가하거나 Presentation.slides 컬렉션에서 기존 슬라이드의 참조를 가져옵니다.
  • 새 작성자를 추가하고 개체에서 참조를 가져옵니다.
  • Author.comments.add\comment(string, ISlide, point, date) 메서드를 사용하여 주석을 삽입하고 반환된 개체를 가져옵니다.
  • 같은 방법으로 다른 주석을 삽입하고 개체에서 참조를 가져옵니다.
  • parent\comment 속성을 사용하여 두 번째 주석의 부모를 설정합니다.
  • 마지막으로 Presentation.save(string, SaveFormat) 메서드를 사용하여 프레젠테이션을 저장합니다.

다음 코드 샘플은 Python에서 PPTX 프레젠테이션의 주석에 회신을 추가하는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing
import datetime

# Create or load presentation
with slides.Presentation() as presentation:
    # Add empty slide
    presentation.slides.add_empty_slide(presentation.layout_slides[0])

    # Add author and comment
    author = presentation.comment_authors.add_author("Usman", "MF")
    comment = author.comments.add_comment("Hello, this is slide comment.", presentation.slides[0], drawing.PointF(0.2, 0.2), datetime.date.today())

    # Add reply comment
    reply = author.comments.add_comment("This is the reply to the comment.", presentation.slides[0], drawing.PointF(0.2, 0.2), datetime.date.today())
    reply.parent_comment = comment

    # Add reply comment
    reply2 = author.comments.add_comment("This is second reply.", presentation.slides[0], drawing.PointF(0.2, 0.2), datetime.date.today())
    reply2.parent_comment = comment

    # Save presentation
    presentation.save("ppt-comments.pptx", slides.export.SaveFormat.PPTX)

다음 스크린샷은 위 코드 샘플의 출력을 보여줍니다.

PPT에 댓글에 답장 추가

Python에서 PPT 슬라이드의 주석 읽기

특정 작성자 또는 모든 작성자가 추가한 PPT 슬라이드에서 댓글을 읽을 수도 있습니다. 다음은 Python에서 PPT 슬라이드의 주석을 읽는 단계입니다.

  • Presentation 클래스를 사용하여 프레젠테이션 파일을 로드합니다.
  • Presentation.comment\authors 컬렉션을 사용하여 작성자 목록을 반복합니다.
  • 각 작성자에 대해 Author.comments 속성을 사용하여 주석을 반복합니다.
  • 속성을 사용하여 주석을 읽으십시오.

다음 코드 샘플은 Python에서 PPT 슬라이드의 주석을 읽는 방법을 보여줍니다.

import aspose.slides as slides
import aspose.pydrawing as drawing
import datetime

with slides.Presentation("ppt-comments.pptx") as presentation:
    # Loop through authors
    for author in presentation.comment_authors:
        # Loop through comments
        for comment in author.comments:
            print("ISlide :" + str(comment.slide.slide_number) + 
            " has comment: " + comment.text + 
            " with Author: " + comment.author.name + 
            " posted on time :" + str(comment.created_time) + "\n")

무료 라이선스 받기

임시 라이선스를 요청하여 평가 제한 없이 .NET을 통해 Python용 Aspose.Slides를 사용할 수 있습니다.

결론

이 기사에서는 Python에서 PowerPoint PPT 슬라이드에 주석을 추가하는 방법을 배웠습니다. 또한 프로그래밍 방식으로 PowerPoint 프레젠테이션에서 회신을 추가하고 주석을 읽는 방법을 다뤘습니다. 또한 문서를 방문하여 .NET을 통해 Python용 Aspose.Slides에 대해 자세히 알아볼 수 있습니다. 또한 포럼에 질문을 게시할 수 있습니다.

또한보십시오