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

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

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

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

Package Manager Console

PM > Install-Package Aspose.PDF

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


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

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

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


// Open document
Document pdfDocument = new Document(dataDir+ "AddTextStamp.pdf");

// Create text stamp
TextStamp 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.0F;
textStamp.TextState.FontStyle = FontStyles.Bold;
textStamp.TextState.FontStyle = FontStyles.Italic;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Aqua);
// Add stamp to particular page
pdfDocument.Pages[1].AddStamp(textStamp);

dataDir = dataDir + "AddTextStamp_out.pdf";
// Save output document
pdfDocument.Save(dataDir);