我不能要求tcpdf库

时间:2015-07-19 12:10:02

标签: php html tcpdf

我想在我的代码中使用tcpdf库。它只是一个样本,我用它进行测试。 我在笔记本电脑中使用wamp服务器。我的项目名称是" mysite" 。在项目中我有一个名为:tcpdf的文件夹,其中包含我刚刚下载的库。和另一个php文件:index.php,其中包含我的主要代码。只是它 ! 在我的浏览器中,当我输入:loclhost / mysite时,它会给我一个错误,该错误无法对文件进行处理:tcpdf_include。 我相信这是一个简单的问题,但我无法解决它!请帮我。这是紧急情况。 <>

    <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, '', 0, 'C', true, 0, false, false, 0);

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

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

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


----------

1 个答案:

答案 0 :(得分:0)

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

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