Add Underline Annotations in PDF document via Java
Build your own Java apps to manipulate comments & authors in PDF files using native APIs.
How to Annotate PDF Document with Underline Annotation Using Java
In order to annotate PDF file, we’ll use Aspose.PDF for Java API which is a feature-rich, powerful and easy to use conversion API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>version of aspose-pdf API</version> <classifier>jdk17</classifier> </dependency>
Add Underline Annotation via Java
You need Aspose.PDF for Java to try the code in your environment.
- Load PDF in an instance of Document class
- Create a new page or get a reference to an existing one
- Create Underline annotation
- Call method Add for Underline annotation from Page.Annotations collections
- Save the file again
Aspose.PDF for Java is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
- Development environment like Eclipse or IntelliJ IDEA
- Aspose.PDF for Java library referenced in your project.