1、使用Flying-Saucer虽然可以支持css2.1,但是不能支持中文换行。
解决方式,你可以手动给超长的文字设定一个width,例如
p{
max-width:395.05pt;
}
使其自动换行。就我试验,像网上的修改源码,修改源码的网站:http://downpour.iteye.com/blog/509417?page=3#comments,http://www.iteye.com/topic/509417?page=6#1279762,给table加table-layout:fixed; word-break:break-strict;总会出现表格一部分显示不全。
2、折腾了很久的中文换行,简直要哭晕在厕所。表格显示不全,竟然是因为从word转换的表格的一行中的最后一个单元格有宽度,把最后一个单元格的宽度删掉,然后在样式中加上下面的代码,就奇迹般的自动换行了。
table{
border:1px solid #000;
table-layout:fixed;
word-break:break-strict;
}
table td{
border:1px solid #000;
word-wrap:break-word;
word-break:break-all;
}
3、中文字体使用SimSum,样式表中的宋体也要改成SImSum才能识别。
4、word转换的html中样式中有 以下描述。加入会在生成的pdf中出现空白页,故在生成pdf时替换掉。
@page WordSection1
{size:595.3pt 841.9pt;
margin:36.0pt 36.0pt 36.0pt 36.0pt;
layout-grid:15.6pt;}
div.WordSection1
{page:WordSection1;}
5、文档模式选择,避免不识别 实体。
"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>”