C++ 経由で PDF 形式のスタンプを操作する

C++ API を使用して Aspose.PDF でスタンプします。

C++ ライブラリを使ってPDFにスタンプを追加する方法

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

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

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


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

1.PDF を Document のインスタンスとともに読み込みます。 1.Document.Info プロパティを使用してドキュメント情報を取得します。 1.異なる Document.Info プロパティにアクセスして表示します。

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


    String _dataDir("C:\\Samples\\");

    // String for input file name
    String inputFileName("AddTextStamp.pdf");
    String outputFileName("AddTextStamp_out.pdf");

    // 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);