Пример #1
0
<body>
<div align="center"><img src="logo.gif" alt="HTML 2 PDF logo" /></div>
<h2 align="center">HTML 2 PDF Project²âÊÔ</h2>
Below are the descriptions of each MENU button:
<ul>
<li><b><font color="red">HOME</font></b> - Returns to the main page (this one)</li>
<li><b>FEATURES</b> - Explains the script's main features</li>
<li><b>EXAMPLES</b> - A series of examples in which the script works</li>
<li><b>CLASS-DOC</b> - Some documentation about the used classes</li>
<li><b>LICENSE</b> - In case you want to distribute or modify the code</li>
<li><b>CREDITS</b> - (the name says it all)</li>
<li><b>FAQ</b> - Frequently asked questions...and answers!</li>
</ul>
<p>This project is hosted on Source Forge. DOWNLOAD IT <a
href="http://sourceforge.net/projects/html2fpdf" target="_blank">THERE</a>!</p>
This script was written on PHP 4.3.3 (should work on 4.0 and greater)
<br /><br/>
</body>
</html>
<?
// Output-Buffer in variable:
$html=ob_get_contents();
// delete Output-Buffer
ob_end_clean();
$pdf=new HTML2FPDF();
$pdf->AddGBFont('GB','·ÂËÎ_GB2312');
$pdf->AddPage();
$pdf->WriteHTML(iconv("UTF-8","GB2312",$html));
$pdf->Output("tmp.pdf",true);
?>
Пример #2
0
    $farr = array(  
        "/\s+/", //过滤多余空白  
         //过滤 <script>等可能引入恶意内容或恶意改变显示布局的代码,如果不需要插入flash等,还可以加入<object>的过滤  
        "/<(\/?)(script|i?frame|style|html|body|title|link|meta|INPUT|A|img|\?|\%)([^>]*?)>/isU", 
        "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",//过滤javascript的on事件  
   );  
   $tarr = array(  
        " ",  
        "",//如果要直接清除不安全的标签,这里可以留空  
        "",
   );  
  $str = preg_replace( $farr,$tarr,$str);  
   return $str;  
}
$pdf=new HTML2FPDF();
$pdf->AddGBFont('GB','仿宋_GB2312');
$pdf->SetFontSize('8');
$pdf->AddPage();
$fp = fopen("sample.html","r");
$strContent = fread($fp, filesize("sample.html"));
fclose($fp);
$msg=urldecode($_POST['userdefine']);
$msg=str_replace("class=TableBlock", "border=1", $msg);
$msg=str_replace("class=TableHeader", "bgcolor=#DDDDDD", $msg);
$msg=str_replace("class=TableContent", "bgcolor=#EEEEEE", $msg);
$msg=str_replace("class=TableDatat", "bgcolor=#FFFFFF", $msg);
$msg=str_replace("<tr>", "<TR>", $msg);
$msg=str_replace("</tr>", "</TR>", $msg);
$msg=str_replace("<td", "<TD", $msg);
$msg=str_replace("</td>", "</TD>", $msg);
$msg=str_replace("nowrap", " ", $msg);
Пример #3
-6
 public function Pdf_do($config = array())
 {
     $source_name = $config['name'];
     $task_name = $config['output'];
     require 'htmlofpdf/html2fpdf.php';
     $pdf = new HTML2FPDF();
     $pdf->AddGBFont('GB', 'GB2312');
     $pdf->AddPage();
     $fp = fopen($source_name, "r");
     $strContent = fread($fp, filesize($source_name));
     fclose($fp);
     $pdf->WriteHTML(iconv("UTF-8", "GB2312", $strContent));
     ob_clean();
     $pdf->Output($task_name, true);
 }