This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Primefaces How to display PDF in JSF page  RSS feed

 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need your assistant in showing the content of a PDF document in an object component.Currently the PDF is shown as blank.

The bean code is:


JSF Code:
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't afford an assistant. At the moment, I'm having trouble affording lunch. :)

Seriously. Don't use JSF to produce PDF's. It's like using a hammer to drive screws. Use a common servlet to produce the PDF. Your JSF code can talk to it by passing stuff in session-scope objects.
 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using iText to produce the PDFs but since this is my first time that I am trying to display it in the browser. Is there any example that I can follow ?
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can probably "google" something.

What I'd recommend is that you create a stand-alone bean that does the document creation to an OutputStream.

Then you can write a stand-alone application class that creates a FileOutputStream, invokes your PDF-building bean and outputs a PDF file. Use this to debug the PDF creation offline. It will save you the time it takes to start/stop a webapp server and it keeps external trash out of the process.

Once you have your document creation bean working, write a simple servlet that invokes it, but instead of a FileOutputStream, call the PDF generator with the servlet's Response OutputStream as the parameter for the output data. Make sure that you set any necessary Http headers such as content-type and (if possible) content size. That should make the task easier.
 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try that
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!