我正在网站上开发一个模块,将一些报告导出为pdf。在谷歌搜索哪种类型的库可以帮助我后,我发现DOMPDF(PHP)。DomPDF不适用于div表吗?
我创建并正确显示PDF,但我必须创建与表格,TR和TD的HTML,因为当我尝试显示相同的使用显示选项设置在表,表行或表格单元格上的div不起作用并且不以正确的制表格式显示数据。
这是一个问题,因为在视图中我尝试使用div和responsiv设计,但是当我作为参数传递这个html时它不起作用。通过这个事实,当我测试这个时,我不得不用这两个html代码创建一个视图。第一个视图使用div设计渲染,另一个使用作为参数传递给dompdf渲染的表标记。
任何一个如果是编程问题,dompdf问题或其他?
任何建议welcomen。
在这里,代码
<link href="pdf.css" rel="stylesheet" type="text/css" media="screen" />
<div class="tabledivinscripcion">
<div class="titular-inscripcion">
<img id="header" class="headers" src="ImagenesNoticias/'.$row_headers["timestamp"].'_'.$row_headers["header"].'"/>
</div>
<table>
<tr>
<td colspan="1"> <b>INFORME DE:</b>'.$row["nombreInforme"].'</td>
<td colspan="1" > <b>Categoría:</b>'.$row["categoria"].'</td>
</tr>
<tr>
<td colspan="1"> <b>Fecha:</b>'.$row["fecha"].'</td>
<td colspan="1"> <b>Hora:</b>'.$row["hora"].'</td>
</tr>
<tr>
<td colspan="1"> <b>Nombre:</b>'.$row["nombre"].'</td>
<td colspan="1"> <b>Licencia:</b>'.$row["licencia"].'</td>
</tr>
<tr>
<td colspan="1"> <b>Categoría:</b>'.$row["categoria2"].'</td>
<td colspan="1"> <b>Manga:</b>'.$row["manga"].'</td>
</tr>
<tr>
<td colspan="2"> <b>Hora del hecho::</b>'.$row["horaHecho"].'</td>
</tr>
<tr>
<td colspan="2"> <b>Descripción:</b>
<br>
<p class="justified">'.$row["descripcion"].'</p>
<br>
</td>
</tr>
<div class="titular-inscripcion foot">
<img id="footer" class="headers" src="ImagenesNoticias/'.$row_headers["timestamp"].'_'.$row_headers["footer"].'"/>
</div>
这里的CSS
.headers{
width:100%;
}
td{
//border:1px solid black;
text-align:left;
height:25px;
}
tr{
//border:1px solid red;
}
table{
// border:1px solid green;
height:75%;
width:85%;
margin-left:auto;
margin-right:auto
}
.justified{
text-align:justify;
}
.tabledivinscripcion{
background:#FFF;
margin-bottom:20px;
padding:0px;
position:relative;
width:100%;
min-height:100%;
margin-left:auto;
margin-right:auto;
}
.foot{
position: absolute;
bottom: 0;
}
.pdescripcion{
text-align: justify;
display:inline-block;
padding-left:10px;
padding-right:10px;
}
.titular-inscripcion{
margin-left:auto;
margin-right:auto;
text-align:center;
display:table;
width: 100%; /*Optional*/
table-layout: fixed; /*Optional*/
}
附此代码是PDF的最终版本。为了做到这一点与div的我试图把div与显示:表作为表标记,和div与显示:表行作为tr标记,最后div与显示:table-cell作为td标记。
谢谢。
请分享您所使用的HTML/CSS的一个样本。 – BrianS