Welcome Guest, Not a member yet? Register   Sign In
how to call class FPDF in CI4
#1

Hi guys .. please give some suggestion for my problem ..
i want to make some report using FPDF with CI4
 ==== it s my controller =====
<?php namespace App\Controllers;

use App\ThirdParty\FPDF;

public function laporan(){
$pdf=new UMUM('P','mm','Legal');

$pdf->SetMargins(5,7,5);
$pdf->SetAutoPageBreak(true,20);
$pdf->AliasNbPages('{pages}');
$pdf->AddPage();
$this->response->setHeader('Content-Type','application/pdf');


the problem is how to call class UMUM in CI 4  ... i tried it in CI 3 and it work but it doesn't work in CI 4
Reply
#2

is this about PDf ? i got results with Spipu\Html2Pdf\Html2Pdf; for producing pdf
CMS CI4     I use Arch Linux by the way 

Reply
#3

(This post was last modified: 11-07-2021, 03:53 PM by ghete.)

yes ..its about PDF &  i'm using FPDF to make report in CI 4..
theres's some problem when i'm make a report FPDF.. i've made UMUM class (header, footer, pages) but i dont know how to call those class in CI 4 ??
Reply
#4

When we install CodeIgniter 4, we have env file at root. To use the environment variables means using variables at global scope we need to do env to .env
Open project in terminal
$ cp env .env
Above command will create a copy of env file to .env file. Now we are ready to use environment variables.
CodeIgniter starts up in production mode by default. Let’s do it in development mode. So that while working if we get any error then error will show up.
# CI_ENVIRONMENT = production
// Do it to
CI_ENVIRONMENT = development
Now application is in development mode.
Reply
#5

(11-06-2021, 03:58 PM)ghete Wrote: Hi guys .. please give some suggestion for my problem ..
i want to make some report using FPDF with CI4
 ==== it s my controller =====
<?php namespace App\Controllers;

use App\ThirdParty\FPDF;

public function laporan(){
$pdf=new UMUM('P','mm','Legal');

$pdf->SetMargins(5,7,5);
$pdf->SetAutoPageBreak(true,20);
$pdf->AliasNbPages('{pages}');
$pdf->AddPage();
$this->response->setHeader('Content-Type','application/pdf');


the problem is how to call class UMUM in CI 4  ... i tried it in CI 3 and it work but it doesn't work in CI 4

CI3 uses autoload by default, In CI4 you should show where use App\ThirdParty\FPDF; is located by name.
I solve this problem 
1) by going into App directory, 
2) if there none Create ThirdParty directory. 
3) then entered compose init, 
4) after some initialization entered by you enter  "composer require twig/twig" (as an example) 
once the composer sets up all the folders for you, 
5) download the FPDF zip file unzip to into vendor directory by the name fpdf
6) add the following  to the app\thirdparty\vendor\composer\autoload_psr4.php file
return array(
            ....
            ....
            'FPDF\\' => array($vendorDir . '/fpdf'),
);

or you can add the same thing into App\Config\Autoload.php file.. make sure you show the link of the file correctly.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB