Php &引用;可见性:隐藏&引用;无法使用TCPDF
我只是尝试用TCPDF将HTML转换成PDF 但有点不对劲 CSS可见性属性对我不起作用 这是我的php代码:Php &引用;可见性:隐藏&引用;无法使用TCPDF,php,html,css,pdf,tcpdf,Php,Html,Css,Pdf,Tcpdf,我只是尝试用TCPDF将HTML转换成PDF 但有点不对劲 CSS可见性属性对我不起作用 这是我的php代码: <?php 创建新的PDF文档 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 设置文档信息 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf-&g
<?php
创建新的PDF文档
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
设置文档信息
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 061');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
设置默认标题数据
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$html = <<<EOF
//HTML code
EOF;
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_061.pdf', 'I');
$pdf->SetHeaderData(pdf\u页眉\u徽标、pdf\u页眉\u徽标\u宽度、pdf\u页眉\u标题'061',pdf\u页眉\u字符串);
//设置页眉和页脚字体
$pdf->setHeaderFont(数组(pdf\u FONT\u NAME\u MAIN',pdf\u FONT\u SIZE\u MAIN));
$pdf->setFooterFont(数组(pdf字体名称数据),pdf字体大小数据);
//设置默认的单间距字体
$pdf->SetDefaultMonospacedFont(pdf\u字体\u等距);
//设置边距
$pdf->SetMargins(pdf\u MARGIN\u左、pdf\u MARGIN\u上、pdf\u MARGIN\u右);
$pdf->SetHeaderMargin(pdf\u MARGIN\u HEADER);
$pdf->SetFooterMargin(pdf\U MARGIN\U FOOTER);
//设置自动分页符
$pdf->SetAutoPageBreak(TRUE,pdf\u MARGIN\u BOTTOM);
//设置图像比例因子
$pdf->setImageScale(pdf图像比例);
//设置一些语言相关字符串(可选)
如果(@file_存在(dirname(_文件)。'/lang/eng.php')){
require_once(dirname(__文件)'/lang/eng.php');
$pdf->setLanguageArray($l);
}
//设置字体
$pdf->SetFont('helvetica','',10);
//添加页面
$pdf->AddPage();
$html=Output('example_061.pdf','I');
这是我的html代码
<!-- EXAMPLE OF CSS STYLE -->
<!DOCTYPE HTML>
<style>
table{
border:1px solid #C0C0C0;
border-collapse:collapse;
}
tr{
}
td {
border:1px solid #C0C0C0;
}
</style>
<table id="BA1">
<tr style=" visibility:hidden;" >
<td height= "1" ></td>
<td height= "1" class="ui-resizable" style="width: 39px;"></td>
<td height= "1" class="ui-resizable" style="width: 76px;"></td>
<td height= "1" class="ui-resizable" style="width: 33px;"></td>
<td height= "1" class="ui-resizable" style="width: 132px;"></td>
<td height= "1" class="ui-resizable" style="width: 345px;"></td>
</tr>
<tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"> </td>
<td class="" style=" font-size: 10px;">編號</td>
<td></td>
<td class="" style="font-size: 10px;">姓名</td>
<td></td><td class="" style=" font-size: 10px;">公布欄</td></tr>
<tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"></td>
<td colspan="3" rowspan="1" class="" style=" font-size: 10px;">繳費項目</td> <td class="" style="font-size: 10px;">金額</td><td colspan="1" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 134px; visibility: hidden;"></td>
<td colspan="4" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 92px; visibility: hidden;"></td>
<td colspan="1" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 17px; visibility: hidden;"></td>
<td colspan="4" rowspan="1" class="" style=" font-size: 10px;">合計:</td></tr></table>
桌子{
边框:1px实心#C0C0;
边界塌陷:塌陷;
}
tr{
}
运输署{
边框:1px实心#C0C0;
}
編號
姓名
公布欄
繳費項目 金額
合計:
如果不支持此属性
没有其他推荐的方法了?TCPDF扩展对css的支持很少 目前,仅支持以下CSS属性:
- 字体系列
- 字号
- 字重
- 字体样式
- 颜色
- 背景色
- 文字装饰
- 宽度
- 高度
- 文本对齐
<!-- EXAMPLE OF CSS STYLE -->
<!DOCTYPE HTML>
<style>
table{
border:1px solid #C0C0C0;
border-collapse:collapse;
}
tr{
}
td {
border:1px solid #C0C0C0;
}
</style>
<table id="BA1">
<tr style=" visibility:hidden;" >
<td height= "1" ></td>
<td height= "1" class="ui-resizable" style="width: 39px;"></td>
<td height= "1" class="ui-resizable" style="width: 76px;"></td>
<td height= "1" class="ui-resizable" style="width: 33px;"></td>
<td height= "1" class="ui-resizable" style="width: 132px;"></td>
<td height= "1" class="ui-resizable" style="width: 345px;"></td>
</tr>
<tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"> </td>
<td class="" style=" font-size: 10px;">編號</td>
<td></td>
<td class="" style="font-size: 10px;">姓名</td>
<td></td><td class="" style=" font-size: 10px;">公布欄</td></tr>
<tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"></td>
<td colspan="3" rowspan="1" class="" style=" font-size: 10px;">繳費項目</td> <td class="" style="font-size: 10px;">金額</td><td colspan="1" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 134px; visibility: hidden;"></td>
<td colspan="4" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 92px; visibility: hidden;"></td>
<td colspan="1" rowspan="2"></td></tr>
<tr><td class="ui-resizable" style="height: 17px; visibility: hidden;"></td>
<td colspan="4" rowspan="1" class="" style=" font-size: 10px;">合計:</td></tr></table>