Home>
What you did

I am trying to output PDF with php + TCPDF.
I see a line at the beginning, but I want to remove it.

TCPDF Version 3, 29

What I did
<? php
include "./libs/TCPDF/tcpdf.php";
$tcpdf = new TCPDF ("Portrait");
$tcpdf->AddPage ();
$tcpdf->SetFont ("kozminproregular", "", 10);
$output = date ("Y year m month d day");
$html =<<<EOF
<style>
  h1 {
    font-size: 16px;
    color: # 333;
  }
  .td-style {
    border: solid 1px;
  }
  .tbl-style {
    border-collapse: collapse;
    border-spacing: 0px;
    }
</style>
<h2>Output document title</h2>
<table>
<tr>
<td colspan = "3">
Document contents ... Long sentences ...
</td>
</tr>
<tr>
<td width = "60%">
<div align = "left">{$output_date}</div>
</td>
<td width = "40%" colspan = "2">
</td>
</tr>
</table>
EOF;
$tcpdf->writeHTML ($html);
$path = "/ var/tmp /";
// file name
$file_name = date ("Y-m-d");
$file_name. = ".pdf";
$tcpdf->Output ($path. $file_name, 'F');
header ("Content-Disposition: attachment;filename = {$file_name}");
readfile ($path.DS. $file_name);
exit ();
?>


When viewing the PDF in the viewer, a line is output just above the title

php
  • Answer # 1

    $tcpdf = new TCPDF ("Portrait");
    $tcpdf->AddPage ();
    $tcpdf->SetFont ("kozminproregular", "", 10);
    $tcpdf->setPrintHeader (false);// add

    $tcpdf->setPrintHeader (false) should be described.