try {
java.io.InputStream ims = context1.getAssets().open("logo.png");
Bitmap bmp = BitmapFactory.decodeStream(ims);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
Image image = Image.getInstance(stream.toByteArray());
ColumnText.showTextAligned(writer.getDirectContent(),
Element.ALIGN_CENTER, new Phrase(new Chunk(image, 0, 0)), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0);
} catch (IOException ex) {
return;
} catch (BadElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我正在尝试向页面添加文本和页脚,但它没有被添加。当我尝试以下操作时,会显示文本,但是如何添加带有图像的文本。
ColumnText.showTextAligned(writer.getDirectContent(),
Element.ALIGN_CENTER, new Phrase("Some Text"), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0);