平常开会或者做总结报告的时候我们通常都会用到powerpoint演示文稿,我们可以在单个幻灯片或者全部幻灯片里面添加注释,这样观众可以从注释内容里面获取更多的相关信息,需要的朋友可以参考下
平常开会或者做总结报告的时候我们通常都会用到PowerPoint演示文稿,我们可以在单个幻灯片或者全部幻灯片里面添加注释,这样观众可以从注释内容里面获取更多的相关信息。
有些朋友不清楚如何在幻灯片里面添加注释,下面我跟大家分享一下如何在C#里面为幻灯片添加注释。
在这里我使用了一个免费控件——Free Spire.Presentation,有兴趣的朋友可以下载使用。
需要添加的命名空间:
using Spire.Presentation;using System.Drawing;
登录后复制
详细步骤和代码片段如下:
步骤1:新建一个Presentation对象,从系统里面加载Presentation文件。
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() 方法来给某一张特定幻灯片添加注解。注释的类包含很多信息,像添加注释的作者、添加注释的时间、添加注释的位置和注释的内容。
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演示文稿。
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文档实现添加注释的代码分享的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2444624.html