4
我试图在php中使用tcpdf生成pdf。如果我在浏览器中打开它比任何事情都好。没有错误,但如果保存或下载文件比在PDF文件中只复选框的值是可见的,它只是放在第一复选框的值之前的复选标记。 预期输出:所有复选框均正常显示。如何为所有值添加复选框(勾选标记正方形)?当生成pdf复选框不显示
这里是我的代码:
<?php
error_reporting(0);
$file = "PDF.csv";
$handle = fopen($file,"r");
$data= fgetcsv($handle);
$job_no=$data[0];
$postcode=$data[1];
$address=$data[2];
$order_no=$data[4];
$d_date=$data[5];
$product=$data[8];
$myArray = explode(utf8_encode(''), $product);
$date = DateTime::createFromFormat("Y-m-d", $d_date);
$filename="General ". $date->format("d"). $date->format("M").$y=$date->format("y").".pdf";
$filepath="C:\\Users\\Admin\\Documents\\pdf";
require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->setFooterData(array(0,64,0), array(0,64,128));
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// add a page
$pdf->AddPage();
$pdf->SetFont('times', '',11);
$pdf->setPage(1, true);
$txt = '<style type="text/css">
.height1
{
height:1000px;
}
</style>
<table border="1" cellpadding="6" cellspacing="0" width="100%" style="font-family:Arial, Helvetica, sans-serif">
<tr>
<td colspan="2">
<input type="checkbox" name="product[]" value="Electrician"'.(in_array("Electrician",$myArray) ? ' checked="checked" ' : '') .'>Electrician
<input type="checkbox" name="product[]" value="Painter"'.(in_array("Painter",$myArray) ? ' checked="checked" ' : '') .'>Painter
<input type="checkbox" name="product[]" value="Specialist company"'.(in_array("Specialist company",$myArray) ? ' checked="checked" ' : '') .'>Specialist company
</td> </tr>
</table>';
$pdf->writeHTML($txt,1,null,null,null,null);
// ---------------------------------------------------------
$fileNL = $filepath."\\".$filename;
$pdf->Output($fileNL,'F');
?>
它不适合我 –