Good morning. I need to create a dynamic pdf that includes also tables. For that I set up my project with FPDF, then I added EasyTable. So my first working demo looks like that:
include 'FPDF/fpdf.php';
include 'FPDF/exfpdf.php';
include 'FPDF/easyTable.php';
$pdf=new exFPDF();
$pdf->AddPage();
.... something ...
$table=new easyTable($pdf, 3, 'border:1;font-size:12;');
... table content ...
$table->printRow();
$table->endTable(4);
$pdf->Output();
My problem is adding the Fpdi library to embed some pages from another PDF. I did it long time ago with an older version of Fpdi, but something big has changed.
Following the official guide https://github.com/Setasign/FPDI I modified the my script like that:
// --- NEW LINES---
use setasign\Fpdi\Fpdi;
require_once('FPDF/Fpdi/autoload.php');
include 'FPDF/fpdf.php';
include 'FPDF/exfpdf.php';
include 'FPDF/easyTable.php';
$pdf = new exFPDF();
$pdf->AddPage();
.... something ...
$table=new easyTable($pdf, 3, 'border:1;font-size:12;');
... table content ...
$table->printRow();
$table->endTable(4);
$pdf->Output();
As you can see, I'm still creating the $pdf object via exPDF (it worked with the old version), but I modified my exfpdf.php file changing the class declaration from
class exFPDF extends FPDF {...}
to
class exFPDF extends setasign\Fpdi\Fpdi{...}
because Pfdi extends FPDF itself.
This is the error I receive:
Fatal error: Uncaught setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException: This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details) in /var/www/html/DEVELOP/testpdf/FPDF/Fpdi/PdfParser/CrossReference/CrossReference.php:257
I'm stuck! Any brilliant idea?
I'm using fpdf v1.8.6, fpdf-easytable v2.0 and fpdi v2.0
Thanks!
----SOLVED----- It was an issue with the pdf file I was trying to embed. I don't know why, but it works fine with other PDFs.
Bye!