Table Header 在 v 9.1.20 中生成 PDF 时不在第二页显示文本
Table Header not displaying text in second page while generating PDF in v 9.1.20
我们使用的是最新版本的飞碟 v 9.1.20,因为 table header 在第一页上正确显示了文本,但 它似乎是剩余页面中断,header 重复但文本不可见。
我们在代码中也使用了属性 -fs-table-paginate:paginate,但仍然是header文本
页似乎是空白
之前的版本我们也试过了,一直到9.1.15版本都可以。有没有人遇到过这个问题,请告诉我们解决方案。
还附上了示例 PDF 的屏幕截图和我们使用的代码。
示例代码:
<style>
table {
-fs-table-paginate: paginate;
}
</style>
<table style="width:20%;" border="1">
<thead style="background: #222; color: #fff;">
<tr>
<td>Header 1</td>
<td>Header 2</td>
</tr>
</thead>
<tbody>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
</tbody>
</table>
这适用于飞碟 9.1.20 版。
jar是通过maven添加的:
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.20</version>
</dependency>
Maven 依赖项
[INFO] ------------------------< org.example:SO-temp >------------------------
[INFO] Building SO-temp 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ SO-temp ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.bouncycastle:bctsp-jdk14:jar:1.46:compile
[INFO] org.xhtmlrenderer:flying-saucer-pdf:jar:9.1.20:compile
[INFO] org.xhtmlrenderer:flying-saucer-core:jar:9.1.20:compile
[INFO] com.lowagie:itext:jar:2.1.7:compile
[INFO] org.bouncycastle:bcmail-jdk14:jar:1.64:compile
[INFO] org.bouncycastle:bcpkix-jdk14:jar:1.64:compile
[INFO] org.bouncycastle:bcprov-jdk14:jar:1.64:compile
Java部分
public class SO {
public static void main(String[] args) throws Exception {
String html = String.join("\n", Files.readAllLines(Paths.get("so.html"), StandardCharsets.UTF_8));
ITextRenderer renderer = new ITextRenderer();
OutputStream out = new FileOutputStream(new File("so.pdf"));
renderer.setDocumentFromString(html);
renderer.layout();
renderer.createPDF(out);
out.close();
}
}
HTML部分
<html>
<head>
<style type="text/css">
table {-fs-table-paginate: paginate;}
</style>
</head>
<body>
<table style="width:20%;" border="1">
<thead style="background: #222; color: #fff;">
<tr><td>Header 1</td><td>Header 2</td></tr>
</thead>
<tbody>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
</tbody>
</table>
</body>
</html>
我们使用的是最新版本的飞碟 v 9.1.20,因为 table header 在第一页上正确显示了文本,但 它似乎是剩余页面中断,header 重复但文本不可见。
我们在代码中也使用了属性 -fs-table-paginate:paginate,但仍然是header文本
页似乎是空白之前的版本我们也试过了,一直到9.1.15版本都可以。有没有人遇到过这个问题,请告诉我们解决方案。
还附上了示例 PDF 的屏幕截图和我们使用的代码。
示例代码:
<style>
table {
-fs-table-paginate: paginate;
}
</style>
<table style="width:20%;" border="1">
<thead style="background: #222; color: #fff;">
<tr>
<td>Header 1</td>
<td>Header 2</td>
</tr>
</thead>
<tbody>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
<tr>
<td>test html</td>
<td>test html</td>
</tr>
</tbody>
</table>
这适用于飞碟 9.1.20 版。
jar是通过maven添加的:
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.20</version>
</dependency>
Maven 依赖项
[INFO] ------------------------< org.example:SO-temp >------------------------
[INFO] Building SO-temp 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ SO-temp ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.bouncycastle:bctsp-jdk14:jar:1.46:compile
[INFO] org.xhtmlrenderer:flying-saucer-pdf:jar:9.1.20:compile
[INFO] org.xhtmlrenderer:flying-saucer-core:jar:9.1.20:compile
[INFO] com.lowagie:itext:jar:2.1.7:compile
[INFO] org.bouncycastle:bcmail-jdk14:jar:1.64:compile
[INFO] org.bouncycastle:bcpkix-jdk14:jar:1.64:compile
[INFO] org.bouncycastle:bcprov-jdk14:jar:1.64:compile
Java部分
public class SO {
public static void main(String[] args) throws Exception {
String html = String.join("\n", Files.readAllLines(Paths.get("so.html"), StandardCharsets.UTF_8));
ITextRenderer renderer = new ITextRenderer();
OutputStream out = new FileOutputStream(new File("so.pdf"));
renderer.setDocumentFromString(html);
renderer.layout();
renderer.createPDF(out);
out.close();
}
}
HTML部分
<html>
<head>
<style type="text/css">
table {-fs-table-paginate: paginate;}
</style>
</head>
<body>
<table style="width:20%;" border="1">
<thead style="background: #222; color: #fff;">
<tr><td>Header 1</td><td>Header 2</td></tr>
</thead>
<tbody>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
<tr><td>test html</td><td>test html</td></tr>
</tbody>
</table>
</body>
</html>