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

Hello everyone, I need suggestions for creating a report using FPDF with CI4.

Here is 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 issue I'm facing is how to call the UMUM class in CI4. I had tried it in CI3 and it worked, but in CI4, it doesn't seem to work.
Reply
#2

(This post was last modified: 07-05-2023, 08:40 AM by JustJohnQ. Edit Reason: add parameters for page size )

My fpdf (version 1.85) folder is in App\ThirdParty.
I added the following to autoload.php in config:
PHP Code:
public $classmap = [
        "FPDF"          => APPPATH "ThirdParty/fpdf/fpdf.php",
    ]; 

My test method looks like this:
PHP Code:
public function fpdfTest()
{
$this->pdf = new FPDF('P''mm''A4');
$this->pdf->AddPage();
$this->pdf->SetTextColor(42,80,125);
$this->pdf->SetFont('Helvetica','B',18);
$this->pdf->Text(15,12.5,"test");
$this->pdf->SetFont('Helvetica','B',14);
$this->response->setHeader('Content-Type','application/pdf');
$this->pdf->Output('D''Invoice_test.pdf');


A PDF is created and automatically saved/opened (depending on browser settings)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB