Convert an HTML file to a PDF with their pictures and styles using Java [duplicate]
Possible Duplicate:
Conver开发者_运维技巧ting HTML Files to PDF
I want to convert an HTML file to PDF by using Java. I've searched stackoverflow and other sites. I am suprised. Because I couldn't find any easy way.
Could you help me with to do that?
Thanks in advance.
http://pd4ml.com/index.htm
http://www.javaworld.com/javaworld/jw-04-2006/jw-0410-html.html
http://www.google.co.il/url?sa=t&source=web&cd=3&ved=0CDAQFjAC&url=http%3A%2F%2Fwww.oooforum.org%2Fforum%2Fviewtopic.phtml%3Ft%3D53745&ei=77gITcewF8bGswbl7aCTAw&usg=AFQjCNGYBzcnQVT3kShaz0ls7MSHYJImJQ&sig2=dZlfImCEsW5G5b3Oo4TvyA
more googleing?
If there is no Java library to do this, I suggest finding a command-line tool that does the job, and invoking it from Java using Runtime.exec(). Not ideal though.
here is the sample to do that
import officetools.OfficeFile; // this is my tools package
...
FileInputStream fis = new FileInputStream(new File("test.html"));
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
// suppose OpenOffice.org runs on localhost, port 8100
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");
...
精彩评论