wood burning stoves*
The moose likes I/O and Streams and the fly likes Convert HTML content into PDF format using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Convert HTML content into PDF format using Java" Watch "Convert HTML content into PDF format using Java" New topic
Author

Convert HTML content into PDF format using Java

Koti Samadhi
Greenhorn

Joined: Aug 26, 2009
Posts: 29
Hi All,

I need to convert HTML content into PDF (or any other format like jpeg,gif ) using Java

Anyone can give the source code for that, it would be a great for me.

Thanks,

Koti
Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
http://www.javaworld.com/javaworld/jw-04-2006/jw-0410-html.html


Cheers
Aneesh
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Quite a coincidence, I've been working on this myself all week

Apart from that JavaWorld article, you may want to look at Flying Saucer or the YaHP Converter. I found the last one the easiest to use and with great results as well. The only drawback is that it is slower than external tools and uses quite a bit of CPU resources. Because it messes with the URLStreamHandlerFactory I've decided to run it as an external tool, launching another JVM from my own (Tomcat) JVM.

If you don't like these you can also use an external tool which you run from the command line, there are several (non-free...) around. Just remember to read the JavaWorld article "when Runtime.exec() won't" if you decide to do this.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41065
    
  43
Since you mention image formats like GIF and JPEG, the easiest way to obtain a PDF from those would to use the iText library - it makes it easy to include images in PDFs.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert HTML content into PDF format using Java
 
Similar Threads
Convert HTML page to PDF..
How to make PDF render to handle HTML specific?
Convert PDF Image to JPG/GIF format
How to convert pdf in jsp page, which have the arabic data
convert to pdf file format