备注是一种特殊的幻灯片,它可以被添加到演示幻灯片以提供提示信息给演讲者。在放映powerpoint文档时开启演示者视图,演讲者就可以看到幻灯片的内容和备注,而观众则仅能看到幻灯片的内容。
本文将介绍如何使用spire.presentation添加备注到powerpoint文档以及获取现有powerpoint文档中的备注。
添加备注
c#
//新建powerpoint文档
presentation ppt = new presentation();
//获取第一张幻灯片
islide slide = ppt.slides[0];
//添加备注幻灯片到第一张幻灯片
notesslide notesslide = slide.addnotesslide();
textparagraph paragraph = new textparagraph();
paragraph.text = "备注: ";
notesslide.notestextframe.paragraphs.append(paragraph);
//添加第一条备注
paragraph = new textparagraph();
paragraph.text = "这是我的第一条备注;";
notesslide.notestextframe.paragraphs.append(paragraph);
notesslide.notestextframe.paragraphs[1].bullettype = textbullettype.numbered;
notesslide.notestextframe.paragraphs[1].bulletstyle = numberedbulletstyle.bulletarabicperiod;
//添加第二条备注
paragraph = new textparagraph();
paragraph.text = "这是我的第二条备注;";
notesslide.notestextframe.paragraphs.append(paragraph);
notesslide.notestextframe.paragraphs[2].bullettype = textbullettype.numbered;
notesslide.notestextframe.paragraphs[2].bulletstyle = numberedbulletstyle.bulletarabicperiod;
//添加第三条备注
paragraph = new textparagraph();
paragraph.text = "这是我的第三条备注;";
notesslide.notestextframe.paragraphs.append(paragraph);
notesslide.notestextframe.paragraphs[3].bullettype = textbullettype.numbered;
notesslide.notestextframe.paragraphs[3].bulletstyle = numberedbulletstyle.bulletarabicperiod;
//保存文档
ppt.savetofile("notes.pptx", fileformat.pptx2013);
vb.net
'新建powerpoint文档
dim ppt as new presentation()
'获取第一张幻灯片
dim slide as islide = ppt.slides(0)
'添加备注幻灯片到第一张幻灯片
dim notesslide as notesslide = slide.addnotesslide()
dim paragraph as new textparagraph()
paragraph.text = "备注: "
notesslide.notestextframe.paragraphs.append(paragraph)
'添加第一条备注
paragraph = new textparagraph()
paragraph.text = "这是我的第一条备注;"
notesslide.notestextframe.paragraphs.append(paragraph)
notesslide.notestextframe.paragraphs(1).bullettype = textbullettype.numbered
notesslide.notestextframe.paragraphs(1).bulletstyle = numberedbulletstyle.bulletarabicperiod
'添加第二条备注
paragraph = new textparagraph()
paragraph.text = "这是我的第二条备注;"
notesslide.notestextframe.paragraphs.append(paragraph)
notesslide.notestextframe.paragraphs(2).bullettype = textbullettype.numbered
notesslide.notestextframe.paragraphs(2).bulletstyle = numberedbulletstyle.bulletarabicperiod
'添加第三条备注
paragraph = new textparagraph()
paragraph.text = "这是我的第三条备注;"
notesslide.notestextframe.paragraphs.append(paragraph)
notesslide.notestextframe.paragraphs(3).bullettype = textbullettype.numbered
notesslide.notestextframe.paragraphs(3).bulletstyle = numberedbulletstyle.bulletarabicperiod
'保存文档
ppt.savetofile("notes.pptx", fileformat.pptx2013)
获取备注
c#
//加载powerpoint文档
presentation ppt = new presentation();
ppt.loadfromfile("notes.pptx");
//获取第一张幻灯片
islide slide = ppt.slides[0];
//获取第一张幻灯片的备注幻灯片
notesslide notesslide = slide.notesslide;
//遍历备注幻灯片中的所有段落
foreach (textparagraph paragraph in notesslide.notestextframe.paragraphs)
{
//获取段落文本
string notes = paragraph.text;
console.writeline(notes);
}
vb.net
'加载powerpoint文档
dim ppt as new presentation()
ppt.loadfromfile("notes.pptx")
'获取第一张幻灯片
dim slide as islide = ppt.slides(0)
'获取第一张幻灯片的备注幻灯片
dim notesslide as notesslide = slide.notesslide
'遍历备注幻灯片中的所有段落
for each paragraph as textparagraph in notesslide.notestextframe.paragraphs
'获取段落文本
dim notes as string = paragraph.text
console.writeline(notes)
next