我在线尝试了很多示例代码,但我无法弄清楚如何将图像实现为Itext
PDF文件。有人可以帮帮我吗?
谢谢。
// This is written based on ItextPdf java
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("sample1.pdf"));
document.open();
Image img = Image.getInstance("arvind-rai.png");
document.add(new Paragraph("Sample 1: This is simple image demo."));
document.add(img);
document.close();
// Follow below link if you want solution in android
https://stackoverflow.com/a/15742238/5380981
这是支票的解决方案,
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("sample2.pdf"));
document.open();
Image img = Image.getInstance("arvind-rai.png");
img.setAbsolutePosition(450f, 10f);
document.add(img);
document.close();