我想在我的代码中使用 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
//============================================================+
----------
最佳答案
您的代码正在 index.php 文件所在的同一文件夹中查找 tcpdf_include.php 文件,但是您提到 tcpdf 库在一个文件夹中,因此您需要更改 rquiere 语句以指向该位置tcpdf 文件夹中的文件,例如:
require_once 'path/to/tcpdf_include/within/tcpdf/folder';
关于php - 我不需要 tcpdf 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31501037/