Using HTML2FPDF (an extension of FPDF) to output a pdf - this is working fine. a PDF is opened in the browser with the uri still showing the php file that created it.
I am trying to take the output of that and save it as a pdf file on the server.
The Pdf file is being created, but it's empty.
Where am I going wrong here?
if ($optionSave == "new" || !isset($optionSave) || trim($optionSave) == ""){
$fileName = "proposal_" . $id . "_" . date("U") . ".pdf";
}
else {
$fileName = $dbp->published_file_name;
}
// PDF generation actions
require('/path/to/FPDF/html2fpdf.php');
//Initialize class
//define RELATIVE_PATH,FPDF_FONTPATH if needed
$pdf=new HTML2FPDF();
$pdf->AddPage();
$pdf->WriteHTML($dbp->content);
$handle = file_exists('/path/removed/'.$fileName);
if (!$handle){
$f = fopen('/path/removed/'.$fileName,'x+');
}else{
echo $fileName;
}
if(!$f) $this->Error('Unable to create output file: '.$fileName);
fwrite ($f,$pdf->Output());
fclose($f);