C# を介して、PDFドキュメントに Polygon の注釈を追加

サーバーサイド API を使用して、ドキュメントファイル内のコメントや作成者を操作する独自の.NET アプリを構築します。

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

Package Manager Console

PM > Install-Package Aspose.PDF

.NET を介して Polygon アノテーションを追加


お使いの環境でコードを試すには aspose.pdf.dll が必要です。

  • Document クラスのインスタンスにPDFをロードする
  • 新しいページを作成するか、既存のページへの参照を取得します
  • Polygon アノテーションを作成する
  • Page.Annotations コレクションから Polygon アノテーションのメソッド Add を呼び出します
  • ファイルをもう一度保存する

システム要件


Aspose.PDF for .NET は、すべての主要なオペレーティングシステムでサポートされています。次の前提条件を満たしていることを確認してください。

  • マイクロソフトウィンドウズまたは.NET フレームワーク、.NET コア、および PHP、VBScript、Delphi、C++ と COM 相互運用を介した互換性のある OS
  • マイクロソフトのVisual Studioのような開発環境。
  • プロジェクトで参照されている.NET DLL の Aspose.PDF。

PDFから Polygon の注釈を追加-C#

Example

    // Load the PDF file
    Document document = new Document(System.IO.Path.Combine(_dataDir, "sample.pdf"));

    // Create Polygon Annotation
    var polygonAnnotation = new PolygonAnnotation(document.Pages[1],
        new Rectangle(270, 193, 571, 383),
        new Point[] {
            new Point(274, 381),
            new Point(555, 381),
            new Point(555, 304),
            new Point(570, 304),
            new Point(570, 195),
            new Point(274, 195)})
    {
        Title = "John Smith",
        Color = Color.Blue,
        InteriorColor = Color.BlueViolet,
        Opacity = 0.25,
        Popup = new PopupAnnotation(document.Pages[1], new Rectangle(842, 196, 1021, 338))
    };
    document.Save(System.IO.Path.Combine(_dataDir, "sample_polygon.pdf"));