File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes  I am trying to generate a PDF file in Hibernate 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 " I am trying to generate a PDF file in Hibernate" Watch " I am trying to generate a PDF file in Hibernate" New topic
Author

I am trying to generate a PDF file in Hibernate

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528


I am trying to generate a PDF file in Hibernate and want to to do similarly :

ServletOutputStream out = response.getOutputStream();
ByteArrayOutputStream.writeTo(out);
out.flush();


Can anyone Please help

If you want something you never had do something which you had never done
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate has no support for PDF generation (its just an ORM tool). You need to use something else, for example iText.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Thanks for the Prompt reply.

I downloaded the iText jar .

But i don't know how could i perform this type of operation using Hibernate



I want to construct a PDF dynamically by select a link from JSP Hibernate acting as a Model?? Any ideas??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
As Paul said, Hibernate has nothing to do with PDFs; where do you think is the connection between the two?

And, since you mention JSPs, let me point out that you can't stream binary content (like a PDF) from a JSP - you need to use a servlet.

As to the code snippet you posted, what's the extra ByteArrayOutputStream for? Why not use the ServletOutputStream directly?
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Ulf Dittmer wrote:As Paul said, Hibernate has nothing to do with PDFs; where do you think is the connection between the two?


My plan is once i get the handle for the InputStream fro the Blob , i will be writing it to the pdfWriter using iText.


And, since you mention JSPs, let me point out that you can't stream binary content (like a PDF) from a JSP - you need to use a servlet.


I will be using Servlet only.


As to the code snippet you posted, what's the extra ByteArrayOutputStream for? Why not use the ServletOutputStream directly?


seems easier to work with iText API once i get the BinaryStream from a Blob
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
There is a link which states that

In Hibernate2, Using Clobs/Blobs with Oracle and Hibernate :



Link
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What does your Blob store? What type of content is currently in the database?


(BTW: that link looks very out of date - it refers to Hibernate version 1.2.1 and Oracle 8 & 9 - neither of which are supported by Oracle anymore. You should also head the "beware" section at the end).
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Paul ,

Actually what i am trying to achive is to get the character data and construct an PDF file for every user related to his information.

But i can't understand where to start from including waht the variables should be in the User DTO.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Character data of what? From the request? From something already in the database?

Whatever its the source, this appears to be nothing to do with Hibernate. Since its more about PDF generation, I'll move it to a more appropriate forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am trying to generate a PDF file in Hibernate