File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am trying to generate a PDF file in Hibernate

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate has no support for PDF generation (its just an ORM tool). You need to use something else, for example iText.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a link which states that

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



Link
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic