TCPDF ERROR: Some data has already been output, can’t send PDF file

Asked By 0 points N/A Posted on -
qa-featured

 

Hi there, when I use wampp to connect to pdf, an error message appears. The message says that the error involves something like missing argument. Please find below the screenshot for your reference.

Can someone explain the meaning of the error and give me some advice how to resolve this? Thank you very much. Have a nice day.

Missing argument 13 for Printheader

Warning: Missing argument 13 for Printheader (), called in C:/….

SHARE
Answered By 20 points N/A #175577

TCPDF ERROR: Some data has already been output, can’t send PDF file

qa-featured

Hi Donald!

The error you have mentioned happens when the output is sent from the script well before the PDF file is being sent.

To resolve this, in the function Output() just add the line ob_end_clean(), as shown below:

public function Output($name = \\\’\\\’, $dest = false)
{
// close the pdf and clean up
$this->_cleanUp();

// if on debug mode
if ($this->_debugActif) {
$this->_DEBUG_add(\\\’Before output\\\’);
$this->pdf->Close();
exit;
}

// complete parameters
if ($dest===false) $dest = \\\’I\\\’;
if ($dest===true) $dest = \\\’S\\\’;
if ($dest===\\\’\\\’) $dest = \\\’I\\\’;
if ($name==\\\’\\\’) $name=\\\’document.pdf\\\’;

// clean up the destination
$dest = strtoupper($dest);
if (!in_array($dest, array(\\\’I\\\’, \\\’D\\\’, \\\’F\\\’, \\\’S\\\’, \\\’FI\\\’,\\\’FD\\\’))) $dest = \\\’I\\\’;

// the name must be a PDF name
if (strtolower(substr($name, -4))!=\\\’.pdf\\\’) {
throw new HTML2PDF_exception(0, \\\’The output document name \\\”\\\’.$name.\\\’\\\” is not a PDF name\\\’);
}

// call the output of TCPDF
ob_end_clean(); //solved
return $this->pdf->Output($name, $dest);
}

Related Questions