Java でPDFの注釈を管理

APIを使用してPDF注釈を管理するための最新の Java ライブラリ。

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

テキスト注釈を追加するために、Aspose.PDF for Java APIを使用します。これは、Javaプラットフォーム用の機能豊富で強力で使いやすい変換APIです。最新バージョンを Maven から直接ダウンロードし、pom.xml に以下の設定を追加することで、Mavenベースのプロジェクト内にインストールできます。

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java AP</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository>

Dependency

<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>version of aspose-pdf API</version>
</dependency>

Java を介して PDF ドキュメントに注釈を作成します


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

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

PDF テキスト注釈-Java。

Example: Java


    Document document = new Document(_dataDir + "sample.pdf");
    Page page = document.getPages().get_Item(1);
    Rectangle rect = new Rectangle(200, 750, 400, 790);
    TextAnnotation textAnnotation = new TextAnnotation(page, rect);

    textAnnotation.setTitle("Aspose User");
    textAnnotation.setSubject("Sample Subject");
    textAnnotation.setState (AnnotationState.Accepted);
    textAnnotation.setContents("Sample contents for the annotation");
    textAnnotation.setOpen(true);
    textAnnotation.setIcon(TextIcon.Circle);

    Border border = new Border(textAnnotation);
    border.setWidth(5);
    border.setDash(new Dash(1, 1));
    textAnnotation.setBorder(border);
    textAnnotation.setRect(rect);

    page.getAnnotations().add(textAnnotation);
    document.save(_dataDir + "sample_textannot.pdf");