![](https://box.kancloud.cn/a3ba36b9d10c9f4cd0031279c00d68e0_795x1124.png) ``` <?php //============================================================+ // File name : example_002.php // Begin : 2008-03-04 // Last Update : 2013-05-14 // // Description : 示例002用于TCPDF类 // 删除页眉和页脚 // // Author: Nicola Asuni // // (c) Copyright: // Nicola Asuni // Tecnick.com LTD // www.tecnick.com // info@tecnick.com //============================================================+ /** * 使用TCPDF创建示例PDF测试文档 * @package com.tecnick.tcpdf * @abstract TCPDF - Example: 删除页眉和页脚 * @author Nicola Asuni * @since 2008-03-04 */ // 包括主TCPDF库(搜索安装路径) require_once('tcpdf_include.php'); // 创建新的PDF文档 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 设置文档信息 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 002'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // 删除默认页眉/页脚 $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // 设置默认的单间距字体 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // 设定边距 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // 设置自动分页 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // 设定图像尺度因子 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // 设置一些依赖于语言的字符串(可选) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // 设置字体 $pdf->SetFont('times', 'BI', 20); // 添加一页 $pdf->AddPage(); // 设置要打印的文本 $txt = <<<EOD TCPDF示例002 使用setPrintHeader()和setPrintFount()方法禁用默认页眉和页脚。 EOD; // 使用write()打印一个文本块 $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); // --------------------------------------------------------- //关闭和输出PDF文档 $pdf->Output('example_002.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ ```