如何使用itext 2.1.7
添加图像标题这是我的代码。但它没有发生任何事情。它创建了pdf文件和示例文本。但它没有图像标题。怎么解决这个问题?请帮帮我
try {
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, new FileOutputStream("./a23.pdf"));
Image logo = Image.getInstance("./2.png");
logo.setAlignment(Image.MIDDLE);
logo.scaleAbsoluteHeight(20);
logo.scaleAbsoluteWidth(20);
logo.scalePercent(100);
Chunk chunk = new Chunk(logo, 0, -45);
HeaderFooter header = new HeaderFooter(new Phrase(chunk), false);
header.setAlignment(Element.ALIGN_CENTER);
header.setBorder(Rectangle.NO_BORDER);
document.open();
document.newPage();
document.setHeader(header);
document.add(new Paragraph("hello world!"));
document.close();
} catch (Exception e) {
e.printStackTrace();
}