java根据模版动态生成pdf的文章点击打开链接
使用XMLWorkerHelper.getInstance().parseXHtml();生成pdf。
如果直接根据ftl模版中的<table></table>填充数据,如果表格列大于第一列填充空白,整个表格会整体移到第二页。
整个表格列大于整页pdf空白,会直接不显示表格。主要看我<#list></list>循环的模版代码,就可以完全解决这个问题。
我的list中循环的是div+表格
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<title></title>
<style type="text/css">
body {
font-family: pingfang sc light;
}
th,td{
border: 1px #ccc;
text-align: center;
word-wrap : break-word ;
word-break:break-all;
}
table{
border-collapse: collapse;
table-layout: fixed;
}
.firstLine{
font-size:12px;
height:25px;
}
.SecondLine{
font-size:12px;
height:25px;
}
.SecondLineOne{
float: left;
text-align: left;
width: 40px;
}
.SecondLineTwo{
float: left;
text-align: left;
width: 320px;
}
.SecondLineThree{
width: 17px;
float: left;
}
.SecondLineFour{
float: left;
text-align: left;
width: 320px;
}
.vertical{
}
</style>
</head>
<body>
<!--第一页开始-->
<div class="center" style="width:697px;">
<div>
<div class="firstLine" >
<div style