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

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

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

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

Python Package Manager Console

pip install aspose-pdf

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


お使いの環境でコードを試すには Aspose.PDF for .NET が必要です。

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

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

    # Open document
    document = Document(dataDir+ "AddTextStamp.pdf")
    # Create text stamp
    textStamp = new TextStamp("Sample Stamp")

    # Set whether stamp is background
    textStamp.Background = true

    # Set origin
    textStamp.XIndent = 100
    textStamp.YIndent = 100

    # Rotate stamp
    textStamp.Rotate = Rotation.on90

    # Set text properties

    textStamp.TextState.Font = FontRepository.FindFont("Arial")
    textStamp.TextState.FontSize = 14
    textStamp.TextState.FontStyle = FontStyles.Bold
    textStamp.TextState.FontStyle = FontStyles.Italic
    textStamp.TextState.ForegroundColor = System.Drawing.Color.Aqua

    # Add stamp to particular page
    document.Pages[1].AddStamp(textStamp)

    dataDir = dataDir + "AddTextStamp_out.pdf"
    # Save output document
    document.Save(dataDir)