0
我正在使用文件代码以附加模式打开pdf文件。如何使用itextpdf将图像附加到android中的现有pdf文件
String FILE = ROOT + "/PDF/" + "DemoLogix.pdf";
PdfWriter.getInstance(document, new FileOutputStream(FILE, true));
document.open();
但是,当我使用下面的代码
PdfPTable table5 = new PdfPTable(new float[]{1});
Bitmap bitmap = BitmapFactory.decodeFile(path); //path is where image is stored.
ByteArrayOutputStream stream1 = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream1);
Image image1 = Image.getInstance(stream1.toByteArray());
PdfPCell cell3 = new PdfPCell(image1, false);
cell3.setPadding(30);
cell3.setBorderWidth(0.0f);
image1.scaleToFit(100, 500);
image1.setAlignment(image1.ALIGN_RIGHT);
table5.addCell(cell3);
document.add(table5);
document.close();
它仍然没有作品加入我的形象。相反,它会覆盖以前的文本。请有人帮助我。
此答案正在工作。你能提出任何可以在内容结尾添加图像的方法吗? –