C# を使用して PDF 内のアノテーションを管理する

PDF ドキュメント内の注釈の管理プログラムで PDF ファイルを変更するには、Aspose.PDF for .NET を使用してください

.NET ライブラリを使用して注釈を管理する方法

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

Package Manager Console

PM > Install-Package Aspose.PDF

C# を使用して PDF ドキュメントに注釈を作成


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

1。ドキュメントクラスのインスタンスに PDF をロードします。 1。PDF に追加したい注釈を作成します。 1。Page オブジェクトの Annotations コレクションに注釈を追加します。 1。PDF ファイルを保存します。

PDF テキストアノテーション-C#

Example: C#

var inputFile = Path.Combine(dataDir, "AddAnnotation.pdf");
var outputFile = Path.Combine(dataDir, "AddAnnotation_out.pdf");

var pdfDocument = new Aspose.Pdf.Document(inputFile);
var textAnnotation =
    new Aspose.Pdf.Annotations.TextAnnotation(pdfDocument.Pages[1],
    new Aspose.Pdf.Rectangle(200, 400, 400, 600))
    {
        Title = "Sample Annotation Title",
        Subject = "Sample Subject"
    };
textAnnotation.SetReviewState(Aspose.Pdf.Annotations.AnnotationState.Accepted,"user");
textAnnotation.Contents = "Sample contents for the annotation";
textAnnotation.Open = true;
textAnnotation.Icon = Aspose.Pdf.Annotations.TextIcon.Key;

var border = new Aspose.Pdf.Annotations.Border(textAnnotation)
{
    Width = 5,
    Dash = new Aspose.Pdf.Annotations.Dash(1, 1)
};
textAnnotation.Border = border;
textAnnotation.Rect =
    new Aspose.Pdf.Rectangle(200, 400, 400, 600);
pdfDocument.Pages[1].Annotations.Add(textAnnotation);
        
pdfDocument.Save(outputFile);