首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我不能要求tcpdf库

我不能要求tcpdf库
EN

Stack Overflow用户
提问于 2015-07-19 12:10:01
回答 1查看 3.3K关注 0票数 4

我想在我的代码中使用tcpdf库。这只是一个样本,我用它做测试。在我的笔记本电脑里我用的是wamp服务器。我的项目名叫"mysite“。在这个项目中,我有一个名为: tcpdf的文件夹,其中包含我刚下载的库。还有另一个php文件: index.php,它包含我的主要代码。就这样!在我的浏览器中,当我输入: loclhost/mysite时,它会给我一个错误,这个错误不能给出文件tcpdf_include。我相信这是一个简单的问题,但我不能汉德尔!请帮帮我。这是紧急情况。<>

代码语言:javascript
复制
    <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
//============================================================+


----------
EN

回答 1

Stack Overflow用户

发布于 2015-07-19 12:21:00

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

代码语言:javascript
复制
require_once 'path/to/tcpdf_include/within/tcpdf/folder';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31501037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档