Convert HTML file to PDF with their pictures and styles using Java

Possible duplicate:
Convert HTML to PDF

I want to convert an HTML file to PDF using Java. I searched for stackoverflow and other sites. I am surprised. Because I could not find an easy way.

Could you help me do this?

Thanks in advance.

+4
source share
3 answers

If there is no Java library for this, I suggest finding a command-line tool that does the job and calling it in Java using Runtime.exec (). Not perfect though.

0
source

here is an example to do it

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"); ... 
-3
source

Source: https://habr.com/ru/post/1332216/


All Articles