private static List extractAnnotations(final PDPage page, final PDFTextStripperByArea stripper, final List linkAnnotations, final List linkRegions) throws IOException {
final List annotations = page.getAnnotations();
for (int j = 0; j < annotations.size(); j++) {
final PDAnnotation annot = (PDAnnotation) annotations.get(j);
if (annot instanceof PDAnnotationLink) {
final PDRectangle rect = annot.getRectangle();
//need to reposition link rectangle to match text space plus add
//a little to account for descenders and the like
final float x = rect.getLowerLeftX() - 1;
float y = rect.getUpperRightY() - 1;
final float width = rect.getWidth() + 2;
final float height = rect.getHeight() + rect.getHeight() / 4;
final int rotation = page.findRotation();
if (rotation == 0) {
final PDRectangle pageSize = page.findMediaBox();
y = pageSize.getHeight() - y;
}
final Rectangle2D.Float awtRect = new Rectangle2D.Float(x, y, width, height);
stripper.addRegion(Integer.toString(j), awtRect);
linkAnnotations.add(annot);