public static void main(String[] args) throws FileNotFoundException,
Exception {
String htmlFile = "C:\\Users\\Administrator\\Desktop\\test.htm";
String pdfFile = "C:\\Users\\Administrator\\Desktop\\test.pdf";
// PdfUtils.parseHTML2PDFFile(pdfFile, new FileInputStream(htmlFile));
String ss = "";
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(htmlFile), "UTF-8"));
String t = "";
while ((t = br.readLine()) != null) {
// System.out.println(t);
ss += t;
}
PdfUtils.parseHTML2PDFFile2(pdfFile, ss);
}
public static void parseHTML2PDFFile2(String pdfFile, String html)
throws DocumentException, IOException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream(pdfFile));
document.open();
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new ByteArrayInputStream(html.getBytes("Utf-8")),
Charset.forName("UTF-8"));
document.close();
}