C++ 経由で PDF ドキュメント内のブックマークを操作する

C++ を使ってPDFのブックマークをプログラム的に操作する方法。

C++ ライブラリで PDF ドキュメント内のブックマークを操作する方法

PDFファイルにブックマークを追加するために、Aspose.PDF for C++ APIを使用します。これは、cpp プラットフォーム用の機能豊富で強力で使いやすいドキュメント操作APIです。NuGet パッケージマネージャーを開き、Aspose.pdf を検索してインストールします。Package Manager コンソールから次のコマンドを使用することもできます。

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

C++ 経由でブックマークを操作する手順


ご使用の環境でコードを試すには Aspose.PDF for C++ が必要です。

1。Document オブジェクトを使用して PDF ドキュメントを開きます。 1。ブックマークを作成し、そのプロパティを定義します。 1。OutlineItemCollection コレクションをアウトラインコレクションに追加します。 1。ファイルをもう一度保存する

<% bookmarks.code-block.text %>

PDF ドキュメントにブックマークを追加-C++。

<% bookmarks.code-block.subtitle %>

    auto pdfOutline = MakeObject<OutlineItemCollection>(pdfDocument->get_Outlines());
    pdfOutline->set_Title(u"Test Outline");
    pdfOutline->set_Italic(true);
    pdfOutline->set_Bold(true);

    // Set the destination page number
    pdfOutline->set_Action(MakeObject<Aspose::Pdf::Annotations::GoToAction>(pdfDocument->get_Pages()->idx_get(2)));

    // Add a bookmark in the document's outline collection.
    pdfDocument->get_Outlines()->Add(pdfOutline);

    // Save the update document
    pdfDocument->Save(_dataDir + u"AddBookmark_out.pdf");