0

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');

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

4
Contributors
5
Replies
11
Views
6 Years
Discussion Span
Last Post by holy-food
0
<?
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!";
?>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

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...

Edited by hotice47: n/a

0

Hi

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

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.