I am having a problem inserting a transparent png image into my pdf file. I am basically adding the image using PdfContentByte but it never seems to appear. I can insert a jpeg that is not transparent ok but it covers the existing content even if I set the image transparency. I am able to stamp the image on a pdf properly using adobe professional so I know the image is ok but I am not sure what the proper way to add the transparent image ... have not seen anything on the list.
Tim
this is basically what I am doing
PdfWriter pdfwriter = PdfWriter.getInstance(document, new FileOutputStream(args[2]));
Watermark watermark = new Watermark(Image.getInstance("prelim2.jpg"), 0.0F, 320F);
Image image = Image.getInstance("Image5.png");
//image.setTransparency(new int[] {255, 255});
//document.add(watermark);
document.open();
PdfContentByte pdfcontentbyte = pdfwriter.getDirectContent();
for(int j = 0; j < i;)
{
document.newPage();
j++;
com.lowagie.text.pdf.PdfImportedPage pdfimportedpage = pdfwriter.getImportedPage(pdfreader1, 1);
com.lowagie.text.pdf.PdfImportedPage pdfimportedpage1 = pdfwriter.getImportedPage(pdfreader, j);
int k = pdfreader.getPageRotation(j);
int l = pdfreader1.getPageRotation(1);
System.out.println("rotation: " + k);
if(k == 90)
pdfcontentbyte.addTemplate(pdfimportedpage1, 0.6F, -f2, f2, 0.6F, 0.0F, f1 - 20F);
else
pdfcontentbyte.addTemplate(pdfimportedpage1, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, -10F);
//pdfcontentbyte.addTemplate(pdfimportedpage, 0.0F, -25F);
//pdfcontentbyte.setRGBColorStroke(0x00, 0x00, 0xFF);
// pdfcontentbyte.rectangle(50, 250, 100, 375);
//pdfcontentbyte.stroke();
//pdfcontentbyte.addTemplate(pdfimportedpage, 0.0F, -25.0F);
image.setAbsolutePosition(0,0);
//image.setTransparency(new int[] {255, 255});
pdfcontentbyte.addImage(image);
//document.add(image);
//Chunk chunk1 = new Chunk("This text is underlined", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE));
//document.add(chunk1);
//document.add(new Annotation("annotation", "This is a post-it note", 50f, 250f, 500f, 600f));
}
