【发布时间】:2015-04-09 16:12:30
【问题描述】:
我正在使用 tcpdf 创建 pdf。 PDF 创建工作正常,但我想格式化这些数据。但我没有得到想要的输出。 我想要以下格式的 PDF(附加图像),但我没有得到。请帮助获得所需格式的输出。
我的代码是这样的:
<?php
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('Lorem Ipsum');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->AddPage();
$appendBlock = '';
foreach ($res as $key => $value) {
$appendBlock .= '<table><tr>
<td>
<img class="hw" style="width:150px;" src="'.$bar_code.'"> '.$username.'
<b style="float:right;">Date:</b> <br/>
'9-4-2015'
'address of the user'
'887766554433,009988775566'
<b>Description:</b>'.Lorem ipsumLorem ipsumLorem ipsumLorem ipsum.'
<b>ProductCode:</b>'2012' 'red' '9'
'10-4-2015'
</td>
</tr>
</table>
<hr>';
}
//mprd($appendBlock);
// create some HTML content
$html = '
<!DOCTYPE html>
<html>
<head>
'.$style.'
</head>
<body>
<section id="page">
'.$appendBlock.'
</section>
</body>
</html>';
// output the HTML content
//$pdf->writeHTML($html, true, 0, true, 0);
// set default font subsetting mode
//$pdf->setFontSubsetting(true);
// set font
// $pdf->SetAutoPageBreak(TRUE, 0);
$pdf->SetFont('helvetica', '', 11);
// $pdf->writeHTML($html, '', 0, '', false, 0, false, false, 0);
$pdf->writeHTML($html);
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
$name = strtotime('Y-m-d H:i:s');
//Close and output PDF document
$pdf->Output('test.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
我得到这种格式:
【问题讨论】:
-
@craig 但我已经集成了 tcpdf .. 在 tcpdf 中不可能吗?
-
您在格式方面究竟需要什么? @rick
-
我对 tcpdf 不了解,但如果这能帮助您快速解决问题,请查看此链接 -github.com/bcit-ci/CodeIgniter/wiki/PDF-generation-using-dompdf
-
@Testing 我已经发布了图片,我想要那种格式
-
如果它是您的预期输出,目前您会得到什么? @rick
标签: php codeigniter tcpdf