• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to integrate TCPDF on CI4 as Library

#1
Photo 
I am trying to integrate TCPDF on CI4. while integrating, it throws 

What I have done so far is 
1) Pasted tcpdf folder in library folder
2) Created "Tpdf.php" in library folder (code below)

Code:
<?php

namespace App\Libraries;

require_once APPPATH.'/libraries/tcpdf/tcpdf.php';

class Tpdf extends TCPDF
{
    public function __construct()
    {
        parent::__construct();
    }
}

3) I called TCPDF in "home controller" (code below)

Code:
<?php
namespace App\Controllers;

use App\Models\UserModel;
use App\Libraries\Tpdf;

class Home extends BaseController
{
    public $tcpdf;
    function __construct()
    {
        $this->userModel = new UserModel();
        $this->tpdf = new Tpdf();
    }

After that I am getting error as shown in attached image

Please suggest the solution.


Attached Files Thumbnail(s)
   
Reply

#2
On the example page they say to include tcpdf_include.php:

PHP Code:
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php'); 

Also, it’s not what cause this error, but you declared a $tcpdf variable but you assign the new object to $tpdf.
Test your translation files with Translation Tester
Reply

#3
I corrected the wrong like you mentioned and still it throws the same error
Reply

#4
Thumbs Up 
(03-09-2020, 11:32 PM)msjagan Wrote: I corrected the wrong like you mentioned and still it throws the same error
The correct way to use the library was mentioned in https://forum.codeigniter.com/thread-75463.html
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.