• 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

Question for Marty Hall : pdf output from servlet ?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can servlets / jsp output generate output as a .pdf file ?
If yes then how can we achieve that ?
Thanks in Advance !
Nikhil
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Binary output, is dependent on mainly the underlying OS (in the case of something like Excel) or supporting packages called by the servlet (in the case of PDF). This is at least my understanding, having never actually done it.
I have seen, especially in the XML.Apache.org site, and some related projects at Jakarta, PDF output support in XSTL. There are a number of projects doing this and the technology is most definitely servlet/jsp complementary.
I would cruise/surf over to xml.apache.org and take a look at FOP.

FOP: XSL Formatting Object processor in Java
FOP is the world's first print formatter driven by XSL formatting objects. It is a Java 1.2 application that reads a formatting object tree and then turns it into a PDF document. The formatting object tree, can be in the form of an XML document (output by an XSLT engine like Xalan) or can be passed in memory as a DOM Document or (in the case of Xalan) SAX events.

 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nikhil Pendharkar:
Can servlets / jsp output generate output as a .pdf file ?
If yes then how can we achieve that ?
Thanks in Advance !
Nikhil


We can use setContentType("application/pdf") to send a pdf to the client's browser... I think the following link might help you...
http://www.devx.com/xml/article/16430
 
Author
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can servlets / jsp output generate output as a .pdf file ?
If yes then how can we achieve that ?


Well, I am not quite sure which of the following two questions you are asking:
  • Assuming that I already have a program such as StyleReport or Acrobat that builds PDF, how do I use a servlet or JSP page to make it Web-accessible?
  • Are there Java packages that directly generate PDF?


  • If you are asking the former, then the answer is straightforward, as described in Section 7.2 of the book:
    1) Do
    2) Call the real PDF generation tool.
    3) Read the result using an input Stream and the binary method.
    4) Call (not -- Writers are for character-based data)
    5) Feed the binary data to the client using the method.
    BTW, you would use a servlet for this task, not a JSP page. JSP provides no advantages when generating binary data, only when generating character-based data that contains a mix of stuff you type in directly and dynamically-generated stuff.
    If you are asking the second question ("what Java packages are there that generate PDF?"), try looking at some of these sites:
  • http://xml.apache.org/fop/
  • http://www.lowagie.com/iText/
  • http://www.etymon.com/pjx/
  • http://www.inetsoft.com/inetsoft/solutions/pdf.html


  • Cheers-
    - Marty
     
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I have used iText ( http://www.lowagie.com/iText/index.html ) to generate PDF documents from servlets and JSP pages, and it works fine.
    Bill
     
    Ko Ko Naing
    Ranch Hand
    Posts: 3178
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Bill Dornbush:
    I have used iText ( http://www.lowagie.com/iText/index.html ) to generate PDF documents from servlets and JSP pages, and it works fine.
    Bill


    Hi Bill,
    The link that you provide is very useful to me as well... iText make things easy, when dealing with PDF on Servlets and JSPs... Thank you very much from me too...
    I think Nikhil got the direct solution too...
     
    Nikhil Pendharkar
    Ranch Hand
    Posts: 44
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks everyone for their valued inputs .
    I am sure the iText libs would be an intresting option to try out .
    Regards ,
    Nikhil
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic