Using TCPDF and FPDI with php cake

I started the TCPDF setup in my cake setup program and now I'm trying to use FPDI as well, because I need to add a PDF to the beginning of the created PDF file.

When I try to do this, I use 3 classes

XTCPDF that contains my FPDI header data - TCPDF FPDI class - TCPDF class

and it is configured like this:

XTCPDF extends FPDI FPDI extends TCPDF

When I try to generate a PDF using commands from the FPDI classes, 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

I think this may be a problem with the scope, but I'm not too sure, I also tested it by changing it to not include the XTCPDF class, but the same error occurs,

EDIT: The code I use to access the FPDI class:

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

Thanks in advance for your help: D

+3
1

, FPDI TCPDF . , - . , , TCPDF, FPDI, XTCPDF FPDI.

, xtcpdf.php, :

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

class XTCPDF  extends FPDI {

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

#other custom methods...

?>

FPDI TCPDF, TCPDF, FPDI...

, TCPDF StartTransaction, CommitTransaction rollbackTransaction . , , ( , , ) , , , .

+3

Source: https://habr.com/ru/post/1734989/


All Articles