Two Laptop Bag*
The moose likes Other JSE/JEE APIs and the fly likes Trouble in generating pdf reports with Jasper and iText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Trouble in generating pdf reports with Jasper and iText" Watch "Trouble in generating pdf reports with Jasper and iText" New topic
Author

Trouble in generating pdf reports with Jasper and iText

Leticia Barbalho
Ranch Hand

Joined: Sep 02, 2005
Posts: 37
Hey everyone,

I have a report created on iReports, and I wanna present it on my browser in my web app. The problem is I need to add a barcode in a specific point of this report. This barcode is being generated correctly, using class BarcodeInter25 of iText.

The problem happens when I'm gonna insert this barcode in the existing report in runtime. I tried it two ways:

First way:



In this first attempt, I use PdfImportedPage to import the page from my existing pdf and put it in my new report. But it it not working: the report shows only with the barcode, it hasn't imported the file I pointed.

Second way:



In this second attempt, I try to open the pdf directly in my document and write the image on it with pdfwriter. The code is normally interpreted and it gives me no error, but when it tries to open the pdf of the screen, it doesn't open. The screen remains gray, like if it was forever loading.

The documentation I'm using comes mainly from here:
http://itextdocs.lowagie.com/tutorial/general/copystamp/.

I accept any kind of help on ways to do it

Thanks in advance
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is not a Servlet specific question so I'm moving it to Other Java APIs.

Try writing the code in a stand-alone class first and write it to the file system. Once you are able to read this you should be able to alter it to stream to the client.

Dave
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
You need to use the PdfStamper class instead of PdfWriter.

You need to do something like :



[ March 31, 2006: Message edited by: Jason Moors ]
[ March 31, 2006: Message edited by: Jason Moors ]
 
wood burning stoves
 
subject: Trouble in generating pdf reports with Jasper and iText