C++ 経由でテキストスタンプPDFを追加

C++ API を使用して Aspose.PDF でテキストスタンプを作成します。

C++ ライブラリを使用して PDF にテキストスタンプを追加する方法

PDFファイル内のテキストスタンプを操作するために、cpp プラットフォーム用の機能豊富で強力で使いやすいドキュメント操作APIである [Aspose.PDF for C++](https://products.aspose.com/pdf/cpp)APIを使用します。NuGet パッケージマネージャーを開き、aspose.pdf を検索してインストールします。パッケージマネージャーコンソールから次のコマンドを使用することもできます。

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

PDF ドキュメント C++ にテキストスタンプを追加


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

1。Document のインスタンスを持つ PDF を読み込みます。 1。Document オブジェクトを使用して PDF ドキュメントを開きます。 1。テキストスタンプを作成し、そのプロパティを定義します。 1。addStampメソッドを使用してテキストスタンプをページに追加する

テキストスタンプをPDFに追加-C++。


    // Open document
    auto document = MakeObject<Document>(_dataDir + inputFileName);
    
    // Create text stamp
    auto textStamp =MakeObject<TextStamp>(u"Sample Stamp");

    // Set whether stamp is background
    textStamp->set_Background(true);
    // Set origin
    textStamp->set_XIndent(100);
    textStamp->set_YIndent(100);
    // Rotate stamp
    textStamp->set_Rotate(Rotation::on90);

    // Set text properties
    textStamp->get_TextState()->set_Font(FontRepository::FindFont(u"Arial"));
    textStamp->get_TextState()->set_FontSize(14.0F);
    textStamp->get_TextState()->set_FontStyle(FontStyles::Bold);
    textStamp->get_TextState()->set_FontStyle(FontStyles::Italic);
    textStamp->get_TextState()->set_ForegroundColor(Color::get_Green());
    // Add stamp to particular page
    document->get_Pages()->idx_get(1)->AddStamp(textStamp);

    // Save output document
    document->Save(_dataDir + outputFileName);