// add to the annotations on the page
annotations.add(aSquare);
// Now we want to draw a line between the two, one end with an open arrow
PDAnnotationLine aLine = new PDAnnotationLine();
aLine.setEndPointEndingStyle( PDAnnotationLine.LE_OPEN_ARROW );
aLine.setContents("Circle->Square");
aLine.setCaption(true); // Make the contents a caption on the line
// Set the rectangle containing the line
position = new PDRectangle(); // Reuse the variable, but note it's a new object!
position.setLowerLeftX(2*inch); // 1" in + width of circle
position.setLowerLeftY(ph-(float)(3.5*inch)-inch); // 1" height, 3.5" down
position.setUpperRightX(pw-inch-inch); // 1" in from right, and width of square
position.setUpperRightY(ph-(3*inch)); // 3" down (top of circle)
aLine.setRectangle(position);
// Now set the line position itself
float[] linepos = new float[4];
linepos[0] = 2*inch; // x1 = rhs of circle
linepos[1] = ph-(float)(3.5*inch); // y1 halfway down circle
linepos[2] = pw-(2*inch); // x2 = lhs of square
linepos[3] = ph-(4*inch); // y2 halfway down square
aLine.setLine(linepos);
aLine.setBorderStyle(borderThick);
aLine.setColour(colourBlack);
// add to the annotations on the page
annotations.add(aLine);