现在我正在使用xhtmlrenderer将html转换为PDF。我对Maven的依赖性如下:
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.1.0.drools2</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.8</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
我正在尝试在每个PDF页面中重复表头。因此,我使用CSS:
table {
-fs-table-paginate: paginate;
}`
CSS的解释为here。
-fs-table-paginate
当与值-fs-table-paginate: paginate
一起使用时,修改表布局算法以在后续页面上重复表头和表尾,并改善跨页的单元格的外观(例如,通过关闭和重新打开边框),但仅此而已是的。如果表格的最小宽度大于页面的宽度,则会将其切掉。
当添加上述CSS时,我的表的边框被分离。
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS96RFFqai5wbmcifQ==” alt =“在此处输入图像说明”>“ >>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS92VDlTNS5wbmcifQ==” alt =“在此处输入图像描述”>
所以我认为table { -fs-table-paginate: paginate; }
使我的表border-collapse:collapse
无效。
所以,我该怎么办才能解决错误,使表格的边框折叠?
我的表的应用程序CSS如下
。在表格标题下方将增加额外的空白行。如下:table{ border:1px solid #000000; border-collapse:collapse; -fs-table-paginate: paginate; } table td{ border:1px solid #000000; word-wrap:break-word; white-space:normal; overflow:hidden; text-align:left; line-height:16px; height:16px; } table tr{ page-break-inside:avoid; } table thead tr th{ background:#f2f2f2; border:1px solid #000000; text-align:center; } table tr th{ background:#f2f2f2; border:1px solid #000000; text-align:center; }
并且当添加
-fs-table-paginate: paginate;
时,有时表头将不正常。标头将无法正确显示
任何人有任何想法吗?
现在,我正在使用xhtmlrenderer将html转换为PDF。我对Maven的依赖性如下:
对于相同的问题,我使用了此解决方法:
是...你是正确的...
对我有用的解决方法: