I am trying to create a pdf using PDFBox, add text which is dynamic, and place an image in the page in a position relative to a specific text, in this case "name1". All of the references that I have seen are only for placing the image in an absolute position. Is there any way to place the image dynamically? If not, is there a way to determine the position of the line cursor at some point in the code, so that I can use that as a reference for absolute placement of the image?
...
contentStream.showText(name1);
contentStream.newLine();
contentStream.newLine();
contentStream.newLine();
contentStream.newLine();
contentStream.showText(name2);
contentStream.newLine();
contentStream.newLine();
contentStream.endText();
PDImageXObject pdImage = PDImageXObject.createFromFile("C:/pdfbox/image1.jpg", doc);
contentStream.drawImage(pdImage, 288f, 148f );