アノテーション

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.annotation.AnnotationIcon;
import com.ironsoftware.ironpdf.annotation.AnnotationManager;
import com.ironsoftware.ironpdf.annotation.AnnotationOptions;
import java.io.IOException;
import java.nio.file.Paths;

// Create a new PDF or load an existing one from the filesystem
PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/example.pdf"));

// Create an annotation to be placed at a specific location on a page.
AnnotationOptions annotation = new AnnotationOptions(
        "This is a major title", // Title of the annotation
        "This is the long 'sticky note' comment content...", // Content of the annotation
        150, // x-axis coordinate location
        250  // y-axis coordinate location
);
annotation.setIcon(AnnotationIcon.HELP);
annotation.setOpacity(0.9);
annotation.setPrintable(false);
annotation.setHidden(false);
annotation.setOpen(true);
annotation.setReadonly(true);
annotation.setRotateable(true);

// Add the annotation to a specific page of the PDF
AnnotationManager annotationManager = pdf.getAnnotation();
annotationManager.addTextAnnotation(annotation, 0);

// Save the PDF with the modifications
pdf.saveAs(Paths.get("assets/annotated.pdf"));
mvn install
アノテーション

アノテーション

PDFドキュメントの指定されたページに"付箋"スタイルの注釈を追加するために、IronPdfクラスを使用します。

以下のコード例に示すように、AnnotationOptionsコンストラクターの引数としてテキストとデカルト座標(x, y)を指定することによって、ページ上の指定された場所にテキストベースの注釈を作成します。 次に、作業中のPDFドキュメントの希望するページに注釈を追加するために、addTextAnnotationメソッドを呼び出します。

すべてのAnnotationOptionsオブジェクト上の追加メソッドによって、開発者は注釈の外観と動作をカスタマイズできます。 以下のコード例では、そのsetFeaturedIcon()を設定し、編集不可および印刷不可に設定しています。 開発者は、注釈の色、高さ、およびタイトルを変更できるだけでなく、そのタイトル、件名、内容、および場所も変更できます。

JavaでPDFに注釈を作成する手順

  1. PDFドキュメントに注釈を追加するためにIronPdf Javaライブラリをインストールします。
  2. PdfDocumentクラスを利用して、Javaで既存のPDFファイルを読み込みます。
  3. AnnotationOptionsクラスを用いて注釈を作成し、カスタマイズします。
  4. IronPDFのaddTextAnnotationを使用して、PDFの特定のページに注釈を追加します。
  5. 注釈を含むPDFドキュメントをエクスポートします。

PDFでの注釈の開始方法についての詳細情報は、IronPDFドキュメンテーションをご覧ください。

Explore AnnotationOptions in IronPDF Java Docs AnnotationOptions

GitHubで見る

準備はできましたか?

バージョン:2026.10リリースされたばかり