Welcome Guest, Not a member yet? Register   Sign In
FPDF - Extending the Class
#3

[eluser]Jonathon Hill[/eluser]
I'm using TCPDF (based on FPDF) and I put my code in a view because the PDF is properly a view in my opinion. Here's an example:

pdf_view.php:

Code:
<?php


// Extend the TCPDF class to create custom Header and Footer
class Mypdf extends Tcpdf {

    function __construct()
    {
        parent::__construct();
        $this->init();
    }


    function init()
    {
        $this->Open();
        
        # Margins
        $this->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $this->SetHeaderMargin(PDF_MARGIN_HEADER);
        $this->SetFooterMargin(PDF_MARGIN_FOOTER);
        
        # Auto page breaks
        $this->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        
        # Image scale factor
        $this->setImageScale(PDF_IMAGE_SCALE_RATIO);
        
        # Initialize document
        $this->AliasNbPages();
        
        $this->setPrintFooter(false);
    }


        //Page header
    public function Header()
    {
            //...
        }

}



$pdf = new Mypdf;


# Document information
$pdf->SetCreator(PDF_CREATOR);

// ...

At the end of the view I have this:

Code:
$pdf->Output('quote.pdf', 'I');


Controller:

Code:
$this->load->library('tcpdf');
$this->load->view('pdf_view', $data);


Messages In This Thread
FPDF - Extending the Class - by El Forum - 06-19-2008, 02:37 AM
FPDF - Extending the Class - by El Forum - 06-19-2008, 04:28 AM
FPDF - Extending the Class - by El Forum - 06-19-2008, 10:20 AM
FPDF - Extending the Class - by El Forum - 06-19-2008, 11:09 AM
FPDF - Extending the Class - by El Forum - 06-19-2008, 12:09 PM
FPDF - Extending the Class - by El Forum - 06-19-2008, 12:24 PM
FPDF - Extending the Class - by El Forum - 06-19-2008, 02:30 PM
FPDF - Extending the Class - by El Forum - 06-20-2008, 01:24 AM
FPDF - Extending the Class - by El Forum - 09-15-2008, 04:24 PM
FPDF - Extending the Class - by El Forum - 09-15-2008, 05:44 PM
FPDF - Extending the Class - by El Forum - 09-15-2008, 06:13 PM
FPDF - Extending the Class - by El Forum - 09-15-2008, 06:44 PM
FPDF - Extending the Class - by El Forum - 10-17-2008, 12:02 PM
FPDF - Extending the Class - by El Forum - 10-19-2008, 05:39 PM
FPDF - Extending the Class - by El Forum - 07-11-2009, 02:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB