Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create a new annotation and make it invisible
- PDAnnotationLink txtLink = new PDAnnotationLink();
- txtLink.setInvisible(true);
- // Add an action
- PDActionURI action = new PDActionURI();
- action.setURI(url);
- txtLink.setAction(action);
- // Create a new rectangle that will be the clickable area
- PDRectangle position = new PDRectangle();
- position.setLowerLeftX(currentXpos);
- position.setLowerLeftY(currentYpos - rectangleHeight);
- position.setUpperRightX(currentXpos + rectangleWidth);
- position.setUpperRightY(currentYpos);
- // Write the "Link" string in blue
- contentStream.setNonStrokingColor(Color.blue);
- contentStream.showText(elm.text());
- contentStream.setNonStrokingColor(Color.black);
- // Make the rectangle a clickable link and add it to the page
- txtLink.setRectangle(position);
- page.getAnnotations().add(txtLink);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement