Microsoft PowerPoint提供了向幻灯片中添加注释的选项。这些注释可以通过提供其他信息和上下文对演示者有所帮助。可能会遇到必须在PowerPoint演示文稿中以编程方式添加或更新此类注释的情况。鉴于此,本文将介绍如何使用C ++以编程方式在PowerPoint演示文稿中使用笔记。
- 使用C ++从PowerPoint幻灯片阅读笔记
- 使用C ++将笔记添加到PowerPoint幻灯片
- 使用C ++更新PowerPoint幻灯片的说明
- 使用C ++从PowerPoint幻灯片中删除笔记
Aspose.Slides for C ++ 本机C ++库,支持创建,读取和操作PowerPoint文件。该API还支持在PowerPoint演示文稿中使用笔记。您可以点击下方按钮下载体验。(获取最新版)
使用C ++从PowerPoint幻灯片阅读笔记
以下是从PowerPoint幻灯片中读取注释的步骤。
- 使用Presentation 类加载PowerPoint演示 文稿
- 访问INotesSlideManager使用用于特定的幻灯片> idx_get(int32_t指数) - - > get_NotesSlideManager()Presentation-> get_Slides()方法。
- 使用INotesSlideManager-> get_NotesSlide()方法检索幻灯片注释。
- 使用INotesSlide-> get_NotesTextFrame()-> get_Text()方法阅读注释。
以下是使用C ++从PowerPoint幻灯片中读取注释的示例代码。
// Source PowerPoint file
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
// Load the Presentation file
SharedPtrpresentation = MakeObject(sourceFilePath);
SharedPtrnotesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Read slide notes
SharedPtrnote = notesManager->get_NotesSlide();
Console::WriteLine(note->get_NotesTextFrame()->get_Text());
使用C ++将笔记添加到PowerPoint幻灯片
Aspose.Slides for C ++使您能够向PowerPoint幻灯片添加注释。为此,请访问INotesSlideManager以获取所需的幻灯片,然后添加注释。以下是将注释添加到特定PowerPoint幻灯片的步骤。
- 首先,使用Presentation 类加载PowerPoint演示 文稿。
- 访问INotesSlideManager使用用于特定的幻灯片> idx_get(int32_t指数) - - > get_NotesSlideManager()Presentation-> get_Slides()方法。
- 使用INotesSlide-> get_NotesTextFrame()-> set_Text(System :: String值)方法设置注释文本
- 最后,使用Presentation-> Save(系统::字符串名称,导出:: SaveFormat格式)方法保存带注释的 演示文稿。
以下是使用C ++将注释添加到特定PowerPoint幻灯片的示例代码。
// File paths
const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\added-slide-notes.pptx";
// Load the Presentation file
SharedPtrpresentation = MakeObject(sourceFilePath);
SharedPtrnotesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Add new slide notes
SharedPtrnote = notesManager->AddNotesSlide();
// Set the note text
note->get_NotesTextFrame()->set_Text(u"Test");
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
使用C ++更新PowerPoint幻灯片的说明
要更新便笺,请使用INotesSlideManager检索现有便笺,然后更新便笺文本。以下是更新PowerPoint幻灯片的注释的步骤。
- 首先,使用Presentation 类加载PowerPoint演示 文稿。
- 访问INotesSlideManager使用用于特定的幻灯片> idx_get(int32_t指数) - - > get_NotesSlideManager()Presentation-> get_Slides()方法。
- 使用INotesSlideManager-> get_NotesSlide()方法检索幻灯片注释。
- 使用INotesSlide-> get_NotesTextFrame()-> set_Text(System :: String值)方法更新注释文本。
- 最后,使用Presentation-> Save(系统::字符串名称,导出:: SaveFormat格式)方法将演示文稿与更新后的注释一起 保存。
以下是使用C ++更新PowerPoint幻灯片注释的示例代码。
// File paths
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\updated-slide-notes.pptx";
// Load the Presentation file
SharedPtrpresentation = MakeObject(sourceFilePath);
SharedPtrnotesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Access slide notes
SharedPtrnote = notesManager->get_NotesSlide();
// Update the notes
note->get_NotesTextFrame()->set_Text(u"Test Updated");
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
使用C ++从PowerPoint幻灯片中删除笔记
通过检索删除的滑动的音符 INotesSlideManager 用于该特定幻灯片,然后使用 RemoveNotesSlide() 方法。以下是从PowerPoint幻灯片中删除笔记的步骤。
- 首先,使用Presentation 类加载PowerPoint演示 文稿。
- 访问INotesSlideManager使用用于特定的幻灯片> idx_get(int32_t指数) - - > get_NotesSlideManager()Presentation-> get_Slides()方法。
- 使用INotesSlideManager-> RemoveNotesSlide()方法删除注释。
- 最后,使用Presentation-> Save(系统::字符串名称,导出:: SaveFormat格式)方法保存演示文件。
以下是使用C ++从PowerPoint幻灯片中删除注释的示例代码。
// File paths
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\removed-slide-notes.pptx";
// Load the Presentation file
SharedPtrpresentation = MakeObject(sourceFilePath);
SharedPtrnotesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Remove slide notes
notesManager->RemoveNotesSlide();
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
如果您有任何疑问或需求,请随时加入Aspose技术交流群(761297826),我们很高兴为您提供查询和咨询。