>  기사  >  백엔드 개발  >  C#에서 PPT 문서에 주석을 추가하기 위한 코드 공유

C#에서 PPT 문서에 주석을 추가하기 위한 코드 공유

黄舟
黄舟원래의
2017-03-25 11:40:081459검색

우리는 일반적으로 회의를 열거나 요약 보고서를 작성할 때 PowerPoint 프레젠테이션을 사용합니다. 필요에 따라 청중이 댓글 내용에서 더 관련성 있는 정보를 얻을 수 있도록 단일 슬라이드 또는 모든 슬라이드에 댓글을 추가할 수 있습니다.

우리는 회의를 하거나 요약 보고서를 작성할 때 주로 PowerPoint 프레젠테이션을 사용합니다. 단일 슬라이드 또는 모든 슬라이드에 주석을 추가하여 청중이 많은 관련 정보를 얻을 수 있습니다.

슬라이드에 댓글을 추가하는 방법을 모르는 친구들이 있습니다. C#에서 슬라이드에 댓글을 추가하는 방법을 알려드리겠습니다.

여기에서는 무료 컨트롤인 Free Spire.Presentation을 사용했습니다. 관심 있는 친구들은 다운로드하여 사용할 수 있습니다.

추가해야 하는 네임스페이스:

using Spire.Presentation;
using System.Drawing;

자세한 단계와 코드 조각은 다음과 같습니다.

1단계: 새 프레젠테이션 만들기 객체, 시스템에서 프레젠테이션 파일을 로드합니다.

Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx");

2단계: CommentAuthorList.AddAuthor(저자 이름, 문자열 이니셜) 메서드를 호출하여 작성자 댓글을 추가합니다.

ICommentAuthor author = presentation.CommentAuthors.AddAuthor("E-iceblue", "comment:");

3단계: Call Presentation.Slides[].AddComment() 메서드를 호출하여 특정 슬라이드에 댓글을 추가합니다. Annotated 클래스에는 Annotation을 추가한 작성자, Annotation이 추가된 시간, Annotation이 추가된 위치, Annotation의 내용 등 많은 정보가 포함되어 있습니다.

presentation.Slides[1].AddComment(author, "This part is pretty important. 
Please pay attention to it", new System.Drawing.PointF(42, 4), DateTime.Now);

4단계: 프레젠테이션을 저장하고 다시 엽니다.

presentation.SaveToFile("PPTwithcomment.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("PPTwithcomment.pptx");

렌더링:

전체 코드:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
 
namespace PPTComment
{
  class Program
  {
    static void Main(string[] args)
    {
      //create PPT document and load file
      Presentation presentation = new Presentation();
      presentation.LoadFromFile("sample.pptx");
      //comment author
      ICommentAuthor author = presentation.CommentAuthors.AddAuthor("E-iceblue", "comment:");
      //add comment
      presentation.Slides[1].AddComment(author, "This part is pretty important. Please pay attention to it", new System.Drawing.PointF(42, 4), DateTime.Now);
      //save the document
      presentation.SaveToFile("PPTwithcomment.pptx", FileFormat.Pptx2010);
      System.Diagnostics.Process.Start("PPTwithcomment.pptx");
    }
  }
}

위 내용은 C#에서 PPT 문서에 주석을 추가하기 위한 코드 공유의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.