IRONSOFTWAREHOME
Annotations

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"));
NuGet Download
Install-Package com.ironsoftware.ironpdf
Annotations

Annotations

Use a PdfDocument object's AnnotationManager, along with the IronPdf class from IronPDF, to add "sticky note"-style annotations to specified pages of a PDF document.

Create a text-based annotation at a given location on a page by specifying the text and the Cartesian (x, y) coordinates as arguments in an AnnotationOptions constructor, as shown in the code example below. Next, invoke the addTextAnnotation method on the AnnotationManager to add the annotation to the desired page in the working PDF document.

Additional methods on every AnnotationOptions object enable developers to customize an annotation's appearance and behavior. In the code example below, we set its setOpacity() and setFeaturedIcon(), as well as configure it to be neither editable nor printable. Developers can also change the color, height, and title of an annotation, as well as its title, subject, content, and location.

Steps to create an Annotation in a PDF using Java

  1. Install the IronPdf Java library to add annotations to PDF documents.
  2. Utilize the PdfDocument class to load an existing PDF file in Java.
  3. Create and customize annotations with the AnnotationOptions class.
  4. Use the addTextAnnotation from IronPDF to add annotations to specific pages of the PDF.
  5. Export the PDF document containing annotations.

For more information on how to get started with annotations in PDFs using IronPDF, visit the IronPDF Documentation.

Explore AnnotationOptions in IronPDF Java Docs AnnotationOptions

View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge related to IronPDF Product Demo

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required