Regarding inconsistent position: this should be fixed by adding vertical offset:
crop.getRight(72f), crop.getBottom() + crop.getHeight() / 2
You see? You took the right border with a 1 inch edge as the x coordinate, but you forgot to consider the y coordinate of the bottom of the page (this is not always 0 ). This should usually fix the positioning problem.
Regarding the fact that only part of the overlay text is visible: at first I assumed that you were adding content to existing content, but this assumption is wrong (you are using getOverContent() ). What exactly do you mean by this second question? Do you know that text is trimmed by CropBox? Are you looking for a way to measure the contents of a phrase to see if it matches the height before adding it?
Bruno lowagie
source share