I'm trying to create a PDF that's PAC3 compliant and I need to add images to the PDF. I was able add an image to the PDF but when I run the PDF in PAC 3. I get an error because my image doesn't have a bounding box. PAC3 output: image of PAC3 Here's my code for adding an image to the pdf document.
PDStructureElement currentElem;
public void drawImage(PDStructureElement parent, float width, float height, float x,float y) throws IOException {
currentElem = addContentToParent(null, StandardStructureTypes.Figure, parent);
currentElem.setAlternateDescription("logo");
PDImageXObject logoImg = PDImageXObject.createFromFile("logo.jpg", this.pdf);
PDPageContentStream contentStream = new PDPageContentStream(this.pdf, this.pdf.getPage(0), PDPageContentStream.AppendMode.APPEND, false);
setNextMarkedContentDictionary();
contentStream.beginMarkedContent(COSName.IMAGE, PDPropertyList.create(currentMarkedContentDictionary));
contentStream.drawImage(logoImg, x, y,45,42);
contentStream.endMarkedContent();
contentStream.close();
addContentToParent(COSName.IMAGE, null, currentElem);
}
My Question: How do I add a bounding box to a image? Is it even possible with PDFBox?