Hi,
I need to display pdf files (stored as blob datatypes in Oracle 8i) to client in a web browser. The pdf-stream should be generated in a servlet. Can anyone recommend some examples / tutorials / documentation about this process?
thanks..
-
streaming PDF from database to browser? (4 messages)
- Posted by: Hendrik Pai
- Posted on: March 22 2005 05:09 EST
Threaded Messages (4)
- Use iText by Soner Dastan on March 22 2005 06:45 EST
- It depends on how pretty you want you PDF by Kris Thompson on March 22 2005 10:14 EST
- streaming PDF from database to browser? by Jim McLean on March 22 2005 10:50 EST
- streaming PDF from database to browser? by Hendrik Pai on March 23 2005 03:53 EST
-
Use iText[ Go to top ]
- Posted by: Soner Dastan
- Posted on: March 22 2005 06:45 EST
- in response to Hendrik Pai
Hello,
just use iText the API to generate PDF Documents on the flow from Java applications. You can use it also in Servlet to create a PDF Stream. Here is an example to use iText in a servlet:
http://itext.sourceforge.net/tutorial/general/webapp/index.html#MyJavaServer
Ciao,
Soner -
It depends on how pretty you want you PDF[ Go to top ]
- Posted by: Kris Thompson
- Posted on: March 22 2005 10:14 EST
- in response to Hendrik Pai
I just went through evaluating iText to XSL/FO for generating my PDF and in my case I needed a very pretty PDF. Therefore I found XSL/FO to be my solution. However I would have used iText had the design of the PDF been easier. -
streaming PDF from database to browser?[ Go to top ]
- Posted by: Jim McLean
- Posted on: March 22 2005 10:50 EST
- in response to Hendrik Pai
It sounds like you already have your BLOBs stored in the DB, so iText, etc would be a waste of time because the PDFs are already genereated.
Here is a recipe for you to consider...
1. run a query along the lines of "select bloblcolumn from sometable"
2. use the ResultSet.getBlob() method to get the Blob object
3. the use the Blob.getBytes() to get a byte array of the PDF
4. create a ByteArrayInputStream with this byte array
5. set the content of the response object to PDF i.e.
resp.setContentType("application/vnd.ms-excel");
resp.setContentLength(arrayLength);
6. read from the ByteArrayInputStream and write to the resp.getOutputStream() until everything is written
7. close all streams -
streaming PDF from database to browser?[ Go to top ]
- Posted by: Hendrik Pai
- Posted on: March 23 2005 03:53 EST
- in response to Jim McLean
thanks Jim!
works perfectly :)