在C#里面给PPT添加注释

日常开会或者作总结报告的时候咱们一般都会用到PowerPoint演示文稿,咱们能够在单个幻灯片或者所有幻灯片里面添加注释,这样观众能够从注释内容里面获取更多的相关信息。html

有些朋友不清楚如何在幻灯片里面添加注释,下面我跟你们分享一下如何在C#里面为幻灯片添加注释。ide

在这里我使用了一个免费控件——Free Spire.Presentation,有兴趣的朋友能够下载使用。 spa

 

须要添加的命名空间:component

using Spire.Presentation; 
using System.Drawing;

 

详细步骤和代码片断以下:orm

 

步骤1新建一个Presentation对象,从系统里面加载Presentation文件。htm

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

 

步骤2调用CommentAuthorList.AddAuthor(author name, string initials) 方法来添加做者注释。对象

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

 

步骤3调用Call presentation.Slides[].AddComment() 方法来给某一张特定幻灯片添加注解。注释的类包含不少信息,像添加注释的做者、添加注释的时间、添加注释的位置和注释的内容。blog

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演示文稿。get

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

 

效果图:string

所有代码:

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");
        }
    }
}
相关文章
相关标签/搜索