使用TCPDF出现报错

浏览:3260 发布日期:2017/04/10 分类:求助交流 关键字: PDF TCPDF
TCPDF错误:有些数据已经输出,不能发送PDF文件
TCPDF ERROR: Some data has already been output, can't send PDF file    1. function pdf($html='<h1 style="color:red">hello word</h1>'){  
    2.     vendor('Tcpdf.tcpdf');  
    3.     $pdf = new \Tcpdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
    4.     // 设置打印模式  
    5.     $pdf->SetCreator(PDF_CREATOR);  
    6.     $pdf->SetAuthor('Nicola Asuni');  
    7.     $pdf->SetTitle('TCPDF Example 001');  
    8.     $pdf->SetSubject('TCPDF Tutorial');  
    9.     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');  
    10.     // 是否显示页眉  
    11.     $pdf->setPrintHeader(false);  
    12.     // 设置页眉显示的内容  
    13.     $pdf->SetHeaderData('logo.png', 60, 'baijunyao.com', '白俊遥博客', array(0,64,255), array(0,64,128));  
    14.     // 设置页眉字体  
    15.     $pdf->setHeaderFont(Array('dejavusans', '', '12'));  
    16.     // 页眉距离顶部的距离  
    17.     $pdf->SetHeaderMargin('5');  
    18.     // 是否显示页脚  
    19.     $pdf->setPrintFooter(true);  
    20.     // 设置页脚显示的内容  
    21.     $pdf->setFooterData(array(0,64,0), array(0,64,128));  
    22.     // 设置页脚的字体  
    23.     $pdf->setFooterFont(Array('dejavusans', '', '10'));  
    24.     // 设置页脚距离底部的距离  
    25.     $pdf->SetFooterMargin('10');  
    26.     // 设置默认等宽字体  
    27.     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);  
    28.     // 设置行高  
    29.     $pdf->setCellHeightRatio(1);  
    30.     // 设置左、上、右的间距  
    31.     $pdf->SetMargins('10', '10', '10');  
    32.     // 设置是否自动分页  距离底部多少距离时分页  
    33.     $pdf->SetAutoPageBreak(TRUE, '15');  
    34.     // 设置图像比例因子  
    35.     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);  
    36.     if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {  
    37.         require_once(dirname(__FILE__).'/lang/eng.php');  
    38.         $pdf->setLanguageArray($l);  
    39.     }  
    40.     $pdf->setFontSubsetting(true);  
    41.     $pdf->AddPage();  
    42.     // 设置字体  
    43.     $pdf->SetFont('stsongstdlight', '', 14, '', true);  
    44.     $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);  
    45.     $pdf->Output('example_001.pdf', 'I');  
    46. }  
最佳答案
评论( 相关
后面还有条评论,点击查看>>