• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert HTML content into PDF format using Java

 
Koti Samadhi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic