如果将模板添加到contentByte,则不会显示添加到文档的图像。
writer = PdfWriter.getInstance(document, fos);
cb = writer.getDirectContent();
document.newPage();
//*******************************************************
// *** adding following line causes the image not to be shown ***
cb.addTemplate(form, 0, 0);
//*******************************************************
cb.beginText();
cb.setRGBColorFill(0,0,0);
cb.setFontAndSize(bf, fontSize);
//*******************************************************
// *** the image is shown only if addTemplate is not called above.***
document.add(image);
//*******************************************************
cb.showTextAligned(...);
cb.endText();
答案 0 :(得分:0)
通过调用writer.getDirectContentUnder();解决了该问题。而不是writer.getDirectContent();