Welcome Guest, Not a member yet? Register   Sign In
fpdf custom header
#1

hi , sorry for english , i want extend fdpf ,  i create in library a new file :

PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

require (
'fpdf/fpdf.php');

class 
PDF_print_a4 extends FPDF {

    private 
$intestazione;

    function __construct($orientation 'P'$unit 'mm'$size 'A4',$intestazione) {
        parent::__construct($orientation$unit$size);
        $CI = & get_instance();
        $this->intestazione $intestazione;
    }

    
// Page header
    
function Header()
    {    
        if(
$this->intestazione->logo!=''){

        
    $logo'./uploads/'.$_SESSION['user_id'].'/'.$intestazione->logo ;

        }else{


        
    $logo'./assets/assets_client/img/no_image.jpg';
        }

    
    // Logo
    
    $this->Image($logo,10,6,30);
    
    // Arial bold 15
    
    $this->SetFont('Arial','B',15);
    
    // Move to the right
    
    $this->Cell(80);
    
    // Title
    
    $this->Cell(30,10,'Title',1,0,'C');
    
    // Line break
    
    $this->Ln(20);
    }

    
// Page footer
    
function Footer()
    {
    
    // Position at 1.5 cm from bottom
    
    $this->SetY(-15);
    
    // Arial italic 8
    
    $this->SetFont('Arial','I',8);
    
    // Page number
    
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
    

    
// Colored table
    
function FancyTable($header$data)
    {
    
    // Colors, line width and bold font
    
    $this->SetFillColor(255,0,0);
    
    $this->SetTextColor(255);
    
    $this->SetDrawColor(128,0,0);
    
    $this->SetLineWidth(.3);
    
    $this->SetFont('','B');
    
    // Header
    
    $w = array(40354045);
    
    for($i=0;$i<count($header);$i++)
    
        $this->Cell($w[$i],7,$header[$i],1,0,'C',true);
    
    $this->Ln();
    
    // Color and font restoration
    
    $this->SetFillColor(224,235,255);
    
    $this->SetTextColor(0);
    
    $this->SetFont('');
    
    // Data
    
    $fill false;
    
    foreach($data as $row)
    
    {
    
        $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
    
        $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
    
        $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);
    
        $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);
    
        $this->Ln();
    
        $fill = !$fill;
    
    }
    
    // Closing line
    
    $this->Cell(array_sum($w),0,'','T');
    }



in my controller i call the library :

PHP Code:
      $this->load->library('PDF_print_a4');

      $intestazione =  $this->user_model->get_user($_SESSION['user_id']);

      $pdf = new PDF_print_a4('L','mm','a4',$intestazione);

      $pdf->AliasNbPages();
      $pdf->AddPage();

      $pdf->header();



      $pdf->output(); 


but i have this error :

Too few arguments to function PDF_print_a4::__construct(), 0 passed

Why ?
Reply
#2

(This post was last modified: 05-02-2020, 08:05 AM by rmilecki.)

(05-01-2020, 09:24 AM)pippuccio76 Wrote:
PHP Code:
    function __construct($orientation 'P'$unit 'mm'$size 'A4',$intestazione) { 
FWIW this constructor doesn't make sense. If 4th argument is mandatory, there is no point in specifying default values for arguments 1-3. You have to pass them anyway.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB