Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // Create a new annotation and make it invisible
  2. PDAnnotationLink txtLink = new PDAnnotationLink();
  3. txtLink.setInvisible(true);
  4.  
  5. // Add an action
  6. PDActionURI action = new PDActionURI();
  7. action.setURI(url);
  8. txtLink.setAction(action);
  9.  
  10. // Create a new rectangle that will be the clickable area
  11. PDRectangle position = new PDRectangle();
  12. position.setLowerLeftX(currentXpos);
  13. position.setLowerLeftY(currentYpos - rectangleHeight);
  14. position.setUpperRightX(currentXpos + rectangleWidth);
  15. position.setUpperRightY(currentYpos);
  16.  
  17. // Write the "Link" string in blue
  18. contentStream.setNonStrokingColor(Color.blue);
  19. contentStream.showText(elm.text());
  20. contentStream.setNonStrokingColor(Color.black);
  21.  
  22. // Make the rectangle a clickable link and add it to the page
  23. txtLink.setRectangle(position);
  24. page.getAnnotations().add(txtLink);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement