
Microsoft PowerPointには、スライドにメモを追加するオプションがあります。これらのメモは、追加情報とコンテキストを提供することにより、プレゼンターに役立ちます。 PowerPointプレゼンテーションでそのようなメモをプログラムで追加または更新しなければならない状況に陥る可能性があります。これに照らして、この記事では、C++を使用してプログラムでPowerPointプレゼンテーションのメモを操作する方法を説明します。
- PowerPointプレゼンテーションでメモを操作するためのC++API
- C++を使用してPowerPointスライドからメモを読む
- C++を使用してPowerPointスライドにメモを追加する
- C++を使用してPowerPointスライドのメモを更新する
- C++を使用してPowerPointスライドからメモを削除する
- 無料ライセンスを取得する
PowerPointプレゼンテーションでメモを操作するためのC++API
Aspose.Slides for C++は、PowerPointファイルの作成、読み取り、操作をサポートするネイティブC++ライブラリです。 APIは、PowerPointプレゼンテーションでのメモの操作もサポートしています。 APIは、NuGetからインストールするか、ダウンロードセクションから直接ダウンロードできます。
PM> Install-Package Aspose.Slides.Cpp
C++を使用してPowerPointスライドからメモを読む
以下は、PowerPointスライドからメモを読むための手順です。
- Presentationクラスを使用してPowerPointプレゼンテーションをロードします。
- Presentation->get_Slides()->idx_get(int32_t index)->get_NotesSlideManager()メソッドを使用して、特定のスライドのINotesSlideManagerにアクセスします。
- INotesSlideManager->get_NotesSlide()メソッドを使用してスライドノートを取得します。
- INotesSlide->get_NotesTextFrame()->get_Text()メソッドを使用してメモを読みます。
以下は、C++を使用してPowerPointスライドからメモを読み取るためのサンプルコードです。
// ソースPowerPointファイル
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
// プレゼンテーションファイルをロードする
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// スライドノートを読む
SharedPtr<INotesSlide> note = notesManager->get_NotesSlide();
Console::WriteLine(note->get_NotesTextFrame()->get_Text());
C++を使用してPowerPointスライドにメモを追加する
Aspose.Slides for C++は、PowerPointスライドにメモを追加する機能を提供します。そのためには、必要なスライドのINotesSlideManagerにアクセスして、メモを追加します。以下は、特定のPowerPointスライドにメモを追加する手順です。
- まず、Presentationクラスを使用してPowerPointプレゼンテーションをロードします。
- Presentation->get_Slides()->idx_get(int32_t index)->get_NotesSlideManager()メソッドを使用して、特定のスライドのINotesSlideManagerにアクセスします。
- INotesSlideManager->AddNotesSlide()メソッドを使用して新しいスライドノートを追加します。
- INotesSlide->get_NotesTextFrame()->set_Text(System::String value)メソッドを使用してメモのテキストを設定します。
- 最後に、Presentation->Save(System::String name, Export::SaveFormat format)メソッドを使用して、メモ付きのプレゼンテーションを保存します。
以下は、C++を使用して特定のPowerPointスライドにメモを追加するためのサンプルコードです。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\added-slide-notes.pptx";
// プレゼンテーションファイルをロードする
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// 新しいスライドノートを追加する
SharedPtr<INotesSlide> note = notesManager->AddNotesSlide();
// メモのテキストを設定する
note->get_NotesTextFrame()->set_Text(u"Test");
// プレゼンテーションファイルを保存する
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
C++を使用してPowerPointスライドのメモを更新する
メモを更新するには、INotesSlideManagerを使用して既存のメモを取得してから、メモのテキストを更新します。以下は、PowerPointスライドのメモを更新する手順です。
- まず、Presentationクラスを使用してPowerPointプレゼンテーションをロードします。
- Presentation->get_Slides()->idx_get(int32_t index)->get_NotesSlideManager()メソッドを使用して、特定のスライドのINotesSlideManagerにアクセスします。
- INotesSlideManager->get_NotesSlide()メソッドを使用してスライドノートを取得します。
- INotesSlide->get_NotesTextFrame()->set_Text(System::String value)メソッドを使用してメモテキストを更新します。
- 最後に、Presentation->Save(System::String name, Export::SaveFormat format)メソッドを使用して、更新されたメモでプレゼンテーションを保存します。
以下は、C++を使用してPowerPointスライドのメモを更新するためのサンプルコードです。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\updated-slide-notes.pptx";
// プレゼンテーションファイルをロードする
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// スライドノートにアクセスする
SharedPtr<INotesSlide> note = notesManager->get_NotesSlide();
// メモを更新する
note->get_NotesTextFrame()->set_Text(u"Test Updated");
// プレゼンテーションファイルを保存する
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
C++を使用してPowerPointスライドからメモを削除する
その特定のスライドのINotesSlideManagerを取得し、RemoveNotesSlide()メソッドを使用して、スライドからメモを削除します。以下は、PowerPointスライドからメモを削除する手順です。
- まず、Presentationクラスを使用してPowerPointプレゼンテーションをロードします。
- Presentation->get_Slides()->idx_get(int32_t index)->get_NotesSlideManager()メソッドを使用して、特定のスライドのINotesSlideManagerにアクセスします。
- INotesSlideManager->RemoveNotesSlide()メソッドを使用してメモを削除します。
- 最後に、Presentation->Save(System::String name, Export::SaveFormat format)メソッドを使用してプレゼンテーションファイルを保存します。
以下は、C++を使用してPowerPointスライドからメモを削除するためのサンプルコードです。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\removed-slide-notes.pptx";
// プレゼンテーションファイルをロードする
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// スライドノートを削除する
notesManager->RemoveNotesSlide();
// プレゼンテーションファイルを保存する
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
無料ライセンスを取得する
無料の一時ライセンスをリクエストして、評価の制限なしでAPIを試すことができます。
結論
この記事では、C++を使用してPowerPointプレゼンテーションのスライドノートを管理する方法を学習しました。具体的には、PowerPointスライドからメモを読んだり、追加したり、更新したり、削除したりする方法を学びました。 Aspose.Slides for C++は、プレゼンテーション関連のタスクを支援する多くの追加機能も提供します。 公式ドキュメントにアクセスすると、APIの詳細を調べることができます。ご不明な点がございましたら、無料サポートフォーラムまでお気軽にお問い合わせください。