Hi,
I have PDFs generated by JasperReports, but occasionally I want to add
images (of previously scanned items) to the end of the report. I've found
some code that I thought would work. But, it adds an additional page (the
size of the image), but the image is never viewable. What did I do wrong?
Thanks.
Code:
PdfReader pdfReader = new PdfReader(new FileInputStream(new
File("c:\\frames\\test1.pdf")));
int n = pdfReader.getNumberOfPages();
FileOutputStream fileOut = new FileOutputStream(new
File("C:\\frames\\test2.pdf"));
PdfStamper ps = new PdfStamper(pdfReader, fileOut);
RandomAccessFile rf = new RandomAccessFile("c:\\frames\\screenshot.jpg",
"r");
int size = (int)rf.length();
byte imext[] = new byte[size];
rf.readFully(imext);
rf.close();
com.lowagie.text.Image img1 = com.lowagie.text.Image.getInstance(imext);
img1.setAbsolutePosition(0, 0);
ps.insertPage(++n, img1);
ps.close();
fileOut.close();
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/