I am trying to generate a pdf( using FPDI_Protection) in CI 4 but i keep getting this error
"
Class 'FPDF' not found
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#1 {main}"
Quote:In my client controller i have
Code:
namespace App\Controllers;
use CodeIgniter\Controller;
use App\Libraries\pdf\fpdf;
use App\Libraries\pdf\fpdi;
use App\Libraries\pdf\FPDI_Protection;
class Client extends Controller{
protected $pdf;
function __construct(){
helper('url');
$this->pdf = new FPDI_Protection();
}
public function download_invoice($client_code){
$this->pdf->SetProtection(array('print'),'12345','');
$this->pdf->AddPage();
$this->pdf->SetFont('Arial');
$this->pdf->Write(10,'blah blah blah blah blah blah blah.');
$this->pdf->Output('D', 'test_invoice.pdf', true);
}
}
Quote:FPDI_Protection.php file link here
PHP Code:
namespace App\Libraries\pdf; //I included this namespace
use App\Libraries\pdf\fpdf; // but this class cannot be found
use App\Libraries\pdf\fpdi;
/*****************************************************************************
* Software: FPDI_Protection *
* Version: 1.0.6 *
* Date: 2016/01/04 *
* Author: Klemen VODOPIVEC, Jan Slabon *
* License: Freeware *
* *
* You may use and modify this software as you wish as stated in original *
* FPDF package. *
* *
* Infos (by Jan Slabon): *
* This class extends the FPDI-class available at https://www.setasign.com *
* so that you can import pages and create new protected pdf files. *
* *
****************************************************************************/
class FPDI_Protection extends FPDI
{
//Never mind the code inside i excluded it for this thread
}
Quote:fpdi.php file
PHP Code:
<?php
namespace App\Libraries\pdf; //I included this namespace
/**
* This file is part of FPDI
*
* @package FPDI
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
* @license http://opensource.org/licenses/mit-license The MIT License
* @version 1.6.2
*/
if (!class_exists('FPDF_TPL')) {
require_once('fpdf_tpl.php');
}
/**
* Class FPDI
*/
class FPDI extends FPDF_TPL
{
//Never mind the code inside i excluded it for this thread
}
Quote:fpdf.php file
PHP Code:
<?php
namespace App\Libraries\pdf;
/*******************************************************************************
* FPDF *
* *
* Version: 1.81 *
* Date: 2015-12-20 *
* Author: Olivier PLATHEY *
*******************************************************************************/
define('FPDF_VERSION','1.81');
class FPDF
{
////Never mind the code inside i excluded it for this thread
}
Error when generating the pdf file is as follows:
"
Class 'FPDF' not found
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#1 {main}"