views:

635

answers:

1

Hi Guys,

I have go TCPDF setup in my cake php install and am now trying to also use FPDI with it as i need to add a PDF to the start of the PDF that is being generated.

WHen trying to do this i am using 3 classes

XTCPDF which holds my header data FPDI - FPDI class TCPDF - TCPDF class

and it is setup as so:

XTCPDF extends FPDI FPDI extends TCPDF

When i try and generate a PDF with this using commands from teh FPDI classs i get the following error:

Fatal error: Cannot access protected property XTCPDF::$PDFVersion in C:\Program Files\XAMPP\xampp\htdocs\quote\app\vendors\fpdi\fpdi_pdf_parser.php on line 388

Im thinking this may be a scope problem but im not too sure, i have also tested by changing it around to not include XTCPDF class but the same error occurs,

EDIT: The code that i am using that accesses the FPDI class is:

    $tcpdf->setSourceFile(APP.'webroot'.DS.'img'.DS.'pdf'.DS.'front_cover.pdf');
$frontCover = $tcpdf->importPage(1); 
$tcpdf->useTemplate($frontCover);

Thanks in advance for any help :D

+3  A: 

I am not sure how you added the FPDI and TCPDF to your cake app. I had some problems when I was doing something similar. I realized what you need to do is import TCPDF then FPDI and then make XTCPDF extend FPDI.

So, in my vendors folder I have a a xtcpdf.php file, which looks like the following:

<?php
App::import('Vendor','tcpdf/tcpdf');
App::import('Vendor','fpdi/fpdi');

class XTCPDF  extends FPDI {

function header() {}
function footer() {}

#other custom methods...

?>

Because FPDI already extends TCPDF you gain access to TCPDF by including FPDI...

I did notice that when trying to use the TCPDF's StartTransaction, CommitTransaction and rollbackTransaction, it caused errors. I have not found out why this is, but I would get an error about accessing private methods, (I think, it was a little while ago I tried) anyway, everything else seems to work great.

ryan
Thanks, this really helped me.
Tomba