4

I'm stuck with an error that is apparently caused by TCPDF not being included by Composer mechanism.

Here's the situation:

Fatal error: Class 'FPDF' not found in /var/www/r0byn/web/vendor/setasign/fpdi/fpdi_bridge.php on line 24

Line 24:

if (!class_exists('TCPDF', false)) {

(I could workaround by changing the second parameter to: true. But everytime the class is updated by composer one would have to remember to do this workaround. Not good.)

composer.json:

{
    "name": "i510c/tools510",
    "type": "project",
    "description": "",
    "license": "MIT",
    "require-dev": {
        "php": ">=5.5.0",
        "phpmailer/phpmailer": "~5.2",
        "gregwar/captcha": "~1.0.12",
        "phpunit/phpunit": "~4.5",
        "stefangabos/zebra_form": "2.9.8",
        "tecnickcom/tcpdf": "6.2.12",
        "setasign/fpdi": "1.6.1",
        "facebook/php-sdk-v4": "~5.0"
    },
    "autoload": {
        "psr-4": { "": ["application/core/", 
                        "application/model/",
                        "application/core/DAO/",
                        "application/core/Plugin/",
                        "application/core/Traits/",
                        "application/core/Exceptions"] }
    }
}

The autoload_classmap.php which is generated by composer contains TCPDF entries. All files of the TCPDF class exist where they should exist.

I have no clue why the TCPDF class is not being detected by class_exists(). Any idea?

R0byn
  • 363
  • 5
  • 15
  • Sounds like a bug regarding autoload functions. If you use your workaround it just indicates that class_exists verifies whether TCPDF has been included via autoload. According to the composer.json file it is. – Andre Jul 14 '16 at 06:21

1 Answers1

0

you dont have fpdf , which is another library helps you import a pdf document in to tcpdf / fpdi and write on it and produces a new pdf. They usually needs to be used togetr in this order fpdf, fpdf, TCPDF

Display name
  • 420
  • 5
  • 20
  • No, actually TCPDF does the PDF import with the only help of FPDI, no need for FPDF. – R0byn Sep 12 '16 at 05:35
  • the error clearly states "Class 'FPDF' not found". so you do need FPDF. This is how it works , With FPDF you can import a PDF page in to TCPDF and with the help of FPDI , you can write on imported PDF document. FPDI parser helps you write TCPDF over the PDF. Also if you want to import PDF pages over version 1.4 you need the commercial version of FPDI, I have been workin on this combination for last 3 years and yes you do need all three of them work together if you want to write on existing PDF document – Display name Sep 12 '16 at 10:19
  • I surely do not question your longtime experience. The facts I see: * no FPDF installed * by changing the second parameter to true it works now * my script imports PDF and writes on it and that's the desired result. – R0byn Sep 13 '16 at 05:15