加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 我不能要求tcpdf库

发布时间:2020-12-13 22:23:02 所属栏目:PHP教程 来源:网络整理
导读:我想在我的代码中使用tcpdf库.它只是一个样本,我用它进行测试. 我在笔记本电脑中使用wamp服务器.我的项目名称是“mysite”.在项目中我有一个名为:tcpdf的文件夹,其中包含我刚刚下载的库.和另一个php文件:index.php,其中包含我的主要代码.只是它 ! 在我的
我想在我的代码中使用tcpdf库.它只是一个样本,我用它进行测试.
我在笔记本电脑中使用wamp服务器.我的项目名称是“mysite”.在项目中我有一个名为:tcpdf的文件夹,其中包含我刚刚下载的库.和另一个php文件:index.php,其中包含我的主要代码.只是它 !
在我的浏览器中,当我输入:loclhost / mysite时,它会给我一个无法填充文件的错误:tcpdf_include.
我相信这是一个简单的问题,但我不能handel它!请帮我.这是紧急情况.
<>

<php> 

    /**
    * Creates an example PDF TEST document using TCPDF
    * @package com.tecnick.tcpdf
    * @abstract TCPDF - Example: Removing Header and Footer
    * @author Nicola Asuni
    * @since 2008-03-04
    **  /

    // Include the main TCPDF library (search for installation path).
    require_once('tcpdf_include.php');

    // create new PDF document 
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,'UTF-8',false);

    // set document information
   $pdf->SetCreator(PDF_CREATOR); 
   $pdf->SetAuthor('Nicola Asuni');
   $pdf->SetTitle('TCPDF Example 002');
   $pdf->SetSubject('TCPDF Tutorial');
   $pdf->SetKeywords('TCPDF,PDF,example,test,guide');

   // remove default header/footer
   $pdf->setPrintHeader(false);
   $pdf->setPrintFooter(false);

   // set default monospaced font
   $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

   // set margins
   $pdf->SetMargins(PDF_MARGIN_LEFT,PDF_MARGIN_TOP,PDF_MARGIN_RIGHT);

   // set auto page breaks 
   $pdf->SetAutoPageBreak(TRUE,PDF_MARGIN_BOTTOM);

   // set image scale factor
   $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

   // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

    // set font
    $pdf->SetFont('times','BI',20);

    // add a page
    $pdf->AddPage();

    // set some text to print
    $txt = <<<EOD
TCPDF Example 002

Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods.
EOD;

// print a block of text using Write()
$pdf->Write(0,$txt,'','C',true,false,0);

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('example_002.pdf','I');

//============================================================+
// END OF FILE
//============================================================+


----------

解决方法

您的代码正在index.php文件所在的同一文件夹中查找tcpdf_include.php文件,但是您提到tcpdf库位于文件夹中,因此您需要更改rquiere语句以指向文件的位置在tcpdf文件夹中,例如:

require_once 'path/to/tcpdf_include/within/tcpdf/folder';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读