I'm new to PdfBox,
I'm having trouble adding multiple images on a PDPage
This is the method that adds images:
[...]
private void addImage(PDDocument document, PDPage page, String
imageName, int x, int y) throws IOException {
System.out.println("Image Name: " + imageName);
PDXObjectImage image = new PDJpeg(document, new
FileInputStream(imageName));
PDPageContentStream contentStream = new
PDPageContentStream(document, page, true, false);
int oldWidth = 200;
int oldHeight = 300;
int newWidth = 150;
int newHeight = (newWidth * oldHeight) / oldWidth;
image.setHeight(newHeight);
image.setWidth(newWidth);
contentStream.drawImage(image, x, y);
contentStream.close();
}
[...]t
even if the image name changes only the first image is repeatedly drawn on page.
and If I move the line:
PDXObjectImage image = new PDJpeg(document, new
FileInputStream(imageName));
after
PDPageContentStream contentStream = new
PDPageContentStream(document, page, true, false);
the resulting page is blank.
thanks in advance,
Stefano