Jack
Jack

Reputation: 29

FPDF, FPDFI Classes and functions

I'm using FPDF (with some added functions from the FPDF scripts) and FPDI to import PDF files, so I have code in the beginning of my PHP file that looks like this:

use \setasign\Fpdi\Fpdi;

require_once('fpdf/fpdf.php');

require_once('fpdfi/src/autoload.php');

class PDF extends FPDF

{ //Cell with horizontal scaling if text is too wide

function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true)
{ ..... }

}

then I initiate a new pdf with $pdf = new Fpdi();

The problem is, once I use "new Fpdi()" instead of "new FPDF" the CellFit function no longer works, and I get errors with the function not being found. I realize this is probably a OOP question, and I am just beginning to try to learn about Objects and classes, but I'm really lost here. So, if someone could steer me in the right direction to get me going, I'd appreciate it. How do I include both FPDF and FPDFI and have access to all the functions?

Upvotes: 0

Views: 825

Answers (1)

Jack
Jack

Reputation: 29

Thank you Olivier and Jan for pointing me in the right direction. Using:

use \setasign\Fpdi\Fpdi;
require_once('fpdf/fpdf.php');
require_once('fpdi/src/autoload.php');
class PDF extends \setasign\Fpdi\Fpdi
{
    function YourOwnMethod()
    {......}
}

$pdf = new PDF();

Works and provides access to all the methods of FPDF, FPDI and additional methods

Upvotes: 0

Related Questions