doulun1939 2014-12-24 12:58
浏览 267

致命错误:找不到类'TCPDF'

I am generating the PDF file but facing the trouble. Can anybody tell me the solution of this error. Below is the code that I used for that. I include the tcpdf for this but there is a fatal error that saying that tcpdf file in not available or we can say not found.

<?php
    $tcpdf_include_dirs = array(realpath('tcpdf.php'), '/usr/share/php/tcpdf/tcpdf.php', '/usr/share/tcpdf/tcpdf.php', '/usr/share/php-tcpdf/tcpdf.php', '/var/www/tcpdf/tcpdf.php', '/var/www/html/tcpdf/tcpdf.php', '/usr/local/apache2/htdocs/tcpdf/tcpdf.php');
    foreach ($tcpdf_include_dirs as $tcpdf_include_path) {
        if (@file_exists($tcpdf_include_path)) {
            require_once($tcpdf_include_path);
            break;
        }
    }

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // Create New PDF Doc
    $pdf->SetCreator(PDF_CREATOR); //Setup a document information

    include("db_connection.php");       

    $isql = mysqli_query($con, "SELECT * FROM `cpdf`") OR die("Data Select problem: ".mysqli_error($con));
    $num = mysqli_num_rows($isql);

    $pdf->AddPage(); //Add new page

    while($row = mysqli_fetch_array($isql)){
        $firstname = $row['fname'];
        $lastname = $row['lname'];
        $fullname = $firstname ." ".$lastname;
        ?>
<html>
    <head>
        <title>PDF Page</title>
    </head>
    <body>
        <form>
            <div>
                <div><img style="width: 100%; height: 20%" src="image/FlZJRBAXRlweb design.idevtechnolabs.socialsigna.l.JPG"/></div>
                <div style="width: 100%; height: 30%">
                    <table style="float: right; border: 2;">
                        <tr style="width: 10%;"><td style="text-align: left;"><?php echo $fullname; ?></td></tr>
                        <tr style="width: 20%;"><td style="text-align: left;"><?php echo $row['add1']; ?></td></tr>
                        <tr style="width: 20%;"><td style="text-align: left;"><?php echo $row['add2']; ?></td></tr>
                        <tr style="width: 20%;"><td style="text-align: left;"><?php echo $row['city']; ?></td></tr>
                        <tr style="width: 20%;"><td style="text-align: left;"><?php echo $row['state']; ?></td></tr>
                        <tr style="width: 20%;"><td style="text-align: left;"><?php echo $row['date']; ?></td></tr>
                    </table>
                </div>
                <div style="float: left; height: 10%;">
                    <b>Subject:</b> <?php echo $row['subject']; ?>
                </div>
                <div style="height: 40%; width: 100%;">
                    <p style="text-align: justify;">Hey, <br /><br /> Mr. <?php echo $fullname; ?>. This is to inform you that a day after tomorrow is the last date of your invoice payment. This is a reminder notice to pay your <?php echo $row['bill']; ?> invoice amount our nearest store and takes advantage of our services.</p>
                    <p style="text-align: justify; text-indent: 4em;">We request you to pay your <?php echo $row['bill']; ?> Bill as soon as possible.</p>
                    <span style="float: right;">Thank you,<br /><img src="#"/></span>
                </div><?php $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); 
                } 
                $pdf->Output('example_002.pdf', 'I'); ?>
            </div>
        </form>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • douni1396 2015-01-02 03:01
    关注

    As a first step, comment out the first seven lines of code and add one new line of code that includes tcpdf.php using the full path to the file. If that doesn't work then you should check the contents of the tcpdf.php file to make sure that it hasn't been corrupted somewhere along the way. That is, make sure it still contains the code that declares the TCPDF class.

    If that works then comment out the hard-coded include statement, uncomment the seven lines that were commented out earlier and add an echo statement to print out the $tcpdf_include_path variable during each iteration of that loop. As long as one of those paths match the hard-coded path that presumably worked earlier, then your code should work fine.

    Finally, and I highly doubt this is the case, but if you happened to have a case-sensitive file system and you happened to have the tcpdf.php file saved as TCPDF.PHP, for example, then that might contribute to the problem. I'm only mentioning that possibility for completeness to the answer, but it is highly unlikely, especially based on the information you provided, that this is the problem in your case.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂