IRONSOFTWAREHOME
注释

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
注释

注释

使用PdfDocument 对象的IronPdf 类,将"便签"样式注释添加到PDF文档的指定页面。

通过在AnnotationOptions构造函数中指定文本和笛卡尔(x, y)坐标作为参数,在页面的给定位置创建基于文本的注释,如下面的代码示例所示。 接下来,在addTextAnnotation 方法,将注释添加到正在处理的PDF文档中的所需页面。

每个AnnotationOptions对象上的其他方法使开发者可以自定义注释的外观和行为。 在下面的代码示例中,我们设置了它的setFeaturedIcon(),并配置它既不可编辑也不可打印。 开发人员还可以更改注释的颜色、高度和标题,以及其标题、主题、内容和位置。

使用Java在PDF中创建注释的步骤

  1. 安装IronPdf Java库以向PDF文档添加注释。
  2. 利用PdfDocument 类在Java中加载现有的PDF文件。
  3. 使用AnnotationOptions 类创建和定制注释。
  4. 使用来自IronPDF的addTextAnnotation向PDF的特定页面添加注释。
  5. 导出包含注释的PDF文档。

有关如何使用IronPDF在PDF中开始使用注释的更多信息,请访问IronPDF文档。

Explore AnnotationOptions in IronPDF Java Docs AnnotationOptions

在 GitHub 上查看

准备开始了吗?

版本:2026.6刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥。

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

OR
bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
Java Maven PDF 库
using Maven 安装

版本: 2026.6

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.6.1</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.6.1
or
Java PDF JAR
下载 JAR

版本: 2026.6

手动安装到您的项目中