• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Primefaces How to display PDF in JSF page

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try that
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic