[英]how to download html table using tcpdf
我有一个页面,需要使用tcpdf下载。 以下是我编写的代码,但仅显示零。
这是我编写的代码:
<?php
require_once('tcpdf.php');
include('simple_html_dom.php');
$filename = '10r6.php';
$ptemplate = file_get_contents($filename);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('AD');
$pdf->SetTitle('TCPDF Example 002');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->SetFont('times', 'BI', 20);
$pdf->AddPage();
$html = <<<EOD
$ptemplate
EOD;
$pdf->writeHTML(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output('example_002.pdf', 'I');
?>
谁能帮我这个忙。
使用此命令将html代码输出到pdf文件。
$pdf->writeHTML($html, true, 0, true, true, '');
我注意到您使用了类似的方法,但是您似乎没有为$ html变量分配任何内容。 您需要将整个html代码放入该变量中,以便将其输出到pdf文件。 因此,如果(我假设)您的html代码是'simple_html_dom.php'(您将其包含在代码顶部),只需执行以下操作:
$html = include('simple_html_dom.php');
$pdf->writeHTML($html, true, 0, true, true, '');
我希望这会有所帮助,昨天我实际上在TCPDF上也遇到了困难,但是整整一天后,我设法使所有工作正常进行。
您的参数不正确。
$pdf->writeHTML($html, 0, '', '', false, 0, 1, 0, true, '', true);
从文档中 ,参数为;
TCPDF::writeHTML(
$html,
$ln = true,
$fill = false,
$reseth = false,
$cell = false,
$align = ''
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.