aspose file tools*
The moose likes BEA/Weblogic and the fly likes Can a servlet convert a html page into pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Can a servlet convert a html page into pdf" Watch "Can a servlet convert a html page into pdf" New topic
Author

Can a servlet convert a html page into pdf

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
How can a servlet convert a html page into pdf document?


kunal
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

With a 3rd party library that does so. I'd search for something like java pdf generation.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
If the HTML is actually CSS-styled XHTML, then the FlyingSaucer library can help. Otherwise, OpenOffice in server mode might do, possibly via a library such as JODConverter.
Ernesto Arroyo
Greenhorn

Joined: Mar 06, 2011
Posts: 11

The question in not really clear: the servlet does not convert anything. The servlet "composes" the response and this response can be HTML, PDF or any other MIME format.

The conversion you need can be done with multiple libraries but instead of a servlet...
what about a filter that converts the output of an HTML response (maybe prepared by a JSP)??

It's only an idea
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
Actually, my requirement is that i have to provide a pdf cnversion facility in Formulae.html(mathematics). That html is just informative. If the user clicks pdf conversion link, it will cnverts the contents of html into pdf.
Ernesto Arroyo
Greenhorn

Joined: Mar 06, 2011
Posts: 11

If you were generating XHTML you could easily convert to PDF with... ¿XSL-FO? (not sure about this acronym).

Google for FOP (Formatting Object to PDF) or http://xml.apache.org/dist/fop/
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can a servlet convert a html page into pdf
 
Similar Threads
how to save a jsp page as pdf in java?
how to save a webpage with struts code as pdf in java?
Can I convert a Jsp to XML
How to convert html to pdf???
Converting .pdf to .html file