4

Possible Duplicate:
Converting 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.

Community
  • 1
  • 1
Tim Tuckle
  • 1,372
  • 7
  • 21
  • 31
  • I think, because there is no easy way to do it. You can consider HTML+CSS -> xhtml -> XSLT->XSL-FO->PDF. Too complicated, really. – khachik Dec 15 '10 at 12:49
  • 1
    Does anyone ever search existing answers? This question has been asked over and over again. – Mark Storer Dec 15 '10 at 19:36

3 Answers3

0

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?

AlexR
  • 114,158
  • 16
  • 130
  • 208
  • thanks.. but did you really check these links? As I said before I've already checked from google. OO doesn't support css. So in the second link includes a huge workflow (first you should change html to xhtml and you should prepare a huge architecture etc.) And pdml is not free? There is no easy way??? – Tim Tuckle Dec 15 '10 at 13:13
0

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.

Steve McLeod
  • 51,737
  • 47
  • 128
  • 184
-3

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");
        ...
bharath
  • 141
  • 8
  • and where do we find this tool package ? – Valentin Rocher Dec 15 '10 at 12:55
  • Just doing a copy/paste from a link such as http://www.daniweb.com/forums/thread130906.html isn't of much help – darioo Dec 15 '10 at 12:56
  • @Valentin: seems to be a part of `officetools.jar`, which is unfortunately not free, but can be obtained from [this site](http://www.dancrintea.ro/doc-to-pdf/). – darioo Dec 15 '10 at 12:58
  • it is a JAR file u can find it in the net.http://www.tomshardware.com/forum/239156-49-officefile-download – bharath Dec 15 '10 at 13:01