Hi

I am using the following code to convert html to pdf. But the resulting pdf page shows blank. Please help me...its very urgent..

require('pdf/html2fpdf.php');
  
$str =stripslashes('<div style="width:580px;" align="left">'.$pdfmessage."</div>");
$html=str_replace("&nbsp;","",$str);
$pdf=new HTML2FPDF();
$pdf->AddPage();
$pdf->SetLeftMargin(25);
$pdf->SetFontSize(12);
$pdf->WriteHTML($html);
$pdf->Output($invno.'.pdf','F');
<?
require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
$fp = fopen("sample.html","r");
$strContent = fread($fp, filesize("sample.html"));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output("sample.pdf");
echo "PDF file is generated successfully!";
?>

i was using this http://html2pdf.fr/ it is very simple and good ...works for me...
it have more the 15 examples inside so ...easy to understand and to work with...

Hi

I used it...but the pdf document is blank...Any rules for the html page tags?

There are some tags that it doesn't like (e.g. <center>, <tt>,<title>,<meta>,<outline>) and the rest must be closed where possible. As an example, if you create a table and use <tr> or <td> without closing </tr> or </td> tags, it won't work. It may look fine as HTML but you can't take shortcuts when using this utility. If you give it good input, it works great.

this is best code i catch form here..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.