Jtidy& ITextRenderer没有提供正确的输出

时间:2013-12-05 11:50:42

标签: java flying-saucer jtidy

I have the following code to convert the html to pdf and two intermediate files getting created.

File file = new File("file.tmp");
String y1 = "<html><body><table><tr><td><textarea>Hello <br> world1";
String y1+= "</textarea></td></tr> </table></body></html>";
FileWriter fw = new FileWriter(file);
fw.write(y1);
fw.close();

FileReader r = new FileReader(file);

Tidy tidy = new Tidy(); 
String tempFile = file + ".tmpPdf";
FileWriter w = new FileWriter(tempFile); 
tidy.parse(r, w);
r.close();
w.close();

SAXBuilder builder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser", false);
DOMOutputter doo = new DOMOutputter();
ITextRenderer render1 = new ITextRenderer();
render1.setDocument(doo.output(builder.build(new FileReader(tempFile))), null);
render1.layout();
File file1 = new File("file1.pdf");
FileOutputStream fw1 = new FileOutputStream(file1);
render1.createPDF(fw1);
fw1.close();

输出是一行中的Hello World1。我希望它在新行中,因为我使用br标签。如何实现这一目标?

0 个答案:

没有答案