在C#里面給PPT文檔添加注釋的實現(xiàn)代碼
平常開會或者做總結(jié)報告的時候我們通常都會用到PowerPoint演示文稿,我們可以在單個幻燈片或者全部幻燈片里面添加注釋,這樣觀眾可以從注釋內(nèi)容里面獲取更多的相關(guān)信息。
有些朋友不清楚如何在幻燈片里面添加注釋,下面我跟大家分享一下如何在C#里面為幻燈片添加注釋。
在這里我使用了一個免費控件——Free Spire.Presentation,有興趣的朋友可以下載使用。
需要添加的命名空間:
using Spire.Presentation; using System.Drawing;
詳細步驟和代碼片段如下:
步驟1:新建一個Presentation對象,從系統(tǒng)里面加載Presentation文件。
Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx");
步驟2:調(diào)用CommentAuthorList.AddAuthor(author name, string initials) 方法來添加作者注釋。
ICommentAuthor author = presentation.CommentAuthors.AddAuthor("E-iceblue", "comment:");
步驟3:調(diào)用Call presentation.Slides[].AddComment() 方法來給某一張?zhí)囟ɑ脽羝砑幼⒔?。注釋的類包含很多信息,像添加注釋的作者、添加注釋的時間、添加注釋的位置和注釋的內(nèi)容。
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文檔添加注釋的實現(xiàn)代碼,需要的朋友可以參考一下。
- C# 多進程打開PPT的示例教程
- C# / VB.NET 在PPT中創(chuàng)建、編輯PPT SmartArt圖形的方法詳解
- C# 實現(xiàn)PPT 每一頁轉(zhuǎn)成圖片過程解析
- C#將PPT文件轉(zhuǎn)換成PDF文件
- C#如何添加PPT背景
- C# 實現(xiàn)對PPT文檔加密、解密及重置密碼的操作方法
- C#提取PPT文本和圖片的實現(xiàn)方法
- C# 使用Free Spire.Presentation 實現(xiàn)對PPT插入、編輯、刪除表格
- C#向PPT文檔插入圖片以及導(dǎo)出圖片的實例
- C#實現(xiàn)將PPT轉(zhuǎn)換成HTML的方法
- word ppt excel文檔轉(zhuǎn)換成pdf的C#實現(xiàn)代碼
- C#/VB.NET 自定義PPT動畫路徑的步驟
相關(guān)文章
C#中的自動類型轉(zhuǎn)換和強制類型轉(zhuǎn)換
這篇文章主要介紹了C#中的自動類型轉(zhuǎn)換和強制類型轉(zhuǎn)換,非常不錯,具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-08-08
C#中實現(xiàn)線程同步lock關(guān)鍵字的用法詳解
實現(xiàn)線程同步的第一種方式是我們經(jīng)常使用的lock關(guān)鍵字,它將包圍的語句塊標記為臨界區(qū),這樣一次只有一個線程進入臨界區(qū)并執(zhí)行代碼,接下來通過本文給大家介紹C#中實現(xiàn)線程同步lock關(guān)鍵字的用法詳解,一起看看吧2016-07-07

