Last active
October 18, 2021 12:09
-
-
Save GroupDocsGists/b8061ef7e09f811300992f5e29b18a27 to your computer and use it in GitHub Desktop.
Add Highlight and Links Annotations to Annotate PDF documents using Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Hyperlinks in PDF using link annotations in Java | |
Annotator annotator = new Annotator("path/sample.pdf"); | |
List<Point> points = new ArrayList<Point>(); | |
points.add(new Point(120, 300)); | |
points.add(new Point(600, 300)); | |
points.add(new Point(120, 270)); | |
points.add(new Point(600, 270)); | |
LinkAnnotation link = new LinkAnnotation(); | |
link.setCreatedOn(Calendar.getInstance().getTime()); | |
link.setPageNumber(0); | |
link.setPoints(points); | |
link.setUrl("https://products.groupdocs.com/annotation"); | |
annotator.add(link); | |
annotator.save("path/annotation-link.pdf"); | |
annotator.dispose(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Highlight PDF using highlight annotation in Java | |
Annotator annotator = new Annotator("path/sample.pdf"); | |
List<Point> points = new ArrayList<Point>(); | |
points.add(new Point(120, 270)); | |
points.add(new Point(600, 270)); | |
points.add(new Point(120, 300)); | |
points.add(new Point(600, 300)); | |
HighlightAnnotation highlight = new HighlightAnnotation(); | |
highlight.setBackgroundColor(0xFFF000); | |
highlight.setOpacity(0.5); | |
highlight.setPageNumber(0); | |
highlight.setPoints(points); | |
annotator.add(highlight); | |
annotator.save("path/annotation-highlight.pdf"); | |
annotator.dispose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment