3
我使用FlyingSaucer(R8pre2版本)将XHTML转换为PDF。Flying Saucer iTextPDF中文字体
该HTML具有中文字符并正在使用MS Mincho字体。
文档已转换,但转换后的PDF文件中缺少所有中文字符。
任何想法如何解决这个问题?
代码:需要
OutputStream os = new FileOutputStream("output.pdf");
String inputFile = "input.html";
String url = new File(inputFile).toURI().toURL().toString();
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
你能显示你的源代码吗? – Raptor
请参阅带代码的更新问题以将XHTML转换为PDF –
我没有看到您加载字体。加载中文字体并确保内容使用UTF-8。类似的情况:http://stackoverflow.com/questions/10231194/encoding-issue-while-generating-pdf-file-from-html-using-itextrenderer – Raptor