FPDF MulticellTag Add-On with PHP 7.0
Added by Kevin JEANSON almost 6 years ago
Hi all,
My name is Kevin and i’m a web developer. I use your FPDF Add On MultiCellTag and it works well. But now i have a problem with your add On : i upgrade my server from PHP 5.3 to PHP 7.0, and the add-on doesn’t work well anymore.
Indeed, when I print the same document with these two php version, I’ve got different result (see files in attachment).
I noticed 2 problems :
- When the width is fixed (ex: $pdf->MultiCellTag(90,5,"Nom : JEANSON") ) the text has the full width (see example in attachment)
- When there’s a tabulation with line break in the text, the method FPDF_MULTICELLTAG::MakeLine() add new line in the end without the first letter of the last line (see example in attachment)
My code is :
<?php
//Tag Based Multicell Class
require_once("fpdf/class.multicelltag.php");
$pdf = new FPDF_MULTICELLTAG();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetStyle("b",'Arial',"b",10, "0,0,0");
$pdf->SetStyle("i",'Arial',"i",10, "0,0,0");
$array_docs = array();
$array_docs[] = 'La fiche de renseignement';
$array_docs[] = 'Les présentes conditions générales de formation';
$array_docs[] = 'Le dossier financier';
$array_docs[] = 'Le règlement intérieur';
$array_docs[] = 'La décharge photographique';
$array_docs[] = 'La caution solidaire (sauf si règlement des frais de scolarité comptant)';
$pdf->MultiCellTag(90,5,"Nom : XXXXXX");
$pdf->MultiCellTag(90,5,'Prenom : XXXXX');
foreach($array_docs as $nb => $lib)
$pdf->MultiCellTag(0,5,utf8_decode(($nb+1).'. '.$lib.'.'),0,'L',0);
$pdf->Ln(1);
$pdf->Output();
?>
Can you please help me to fix it ?
Best regards,
Kevin
pdftest_php5.6.pdf | View pdftest_php5.6.pdf | 1.36 KB | PHP 5.6 (Work well) | ||
pdftest_php7.0.pdf | View pdftest_php7.0.pdf | 1.44 KB | PHP 7.0 |
Replies (7)
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Kevin JEANSON almost 6 years ago
Thanks for your reply Andrei.
I'm using FPDF_MULTICELLTAG class wich extends to FPDF
My FPDF is 1.81 (latest) and FPDF_MULTICELLTAG is 1.3 (Date:2005/12/08 / Last Modification: 2006/09/18)
If i download the latest version on your website (Fpdf Advanced Multicell(Utf8) 2.5.1), it will be compatible with PHP 7.X ?
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Andrei Bintintan almost 6 years ago
Yes, do the update. It works with PHP 7.x
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Kevin JEANSON almost 6 years ago
Dear Andrei,
I downloaded the lastest version Fpdf Advanced Multicell(Utf8) 2.5.1.
Now it works, but i have another problem with multiCell method. When i call multiCell in a foreach, the text doesn't start in the same X position for each text (please see the example file in attachment).
And here is my PHP file :
require_once( "script/fpdf/tfpdf.php" );
// Include the Advanced Multicell Class
require_once( "script/fpdf/classes/pdfmulticell.php" );
// create new PDF document
$pdf = new tFPDF();
/**
- Create the Advanced Multicell Object and pass the PDF object as a parameter to the constructor */ $oMulticell = new PdfMulticell( $pdf );
$pdf->AddPage();
$oMulticell->SetStyle("b",'Arial',"b",10, "0,0,0");
$array_docs = array();
$array_docs[] = 'La fiche de renseignement';
$array_docs[] = 'Les présentes conditions générales de formation';
$array_docs[] = 'Le dossier financier';
$array_docs[] = 'Le règlement intérieur';
$array_docs[] = 'La décharge photographique';
$array_docs[] = 'La caution solidaire (sauf si règlement des frais de scolarité comptant)';
$oMulticell->multiCell(90,5,"Nom : JEANSON");
$oMulticell->multiCell(90,5,'Prenom : Kevin');
foreach($array_docs as $nb => $lib) {
$oMulticell->multiCell(150,5,utf8_decode(($nb+1).'. '.$lib.'.'),0,'L',0);
}
$pdf->Output();
When i dump $pdf->getX() in the foreach, i've got always the same X position. So, where is the problem ?
Thanks in advance.
Regards,
Kevin
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Andrei Bintintan almost 6 years ago
Hi Kevin,
For the tfpdf you have to load a font-file. Otherwise it will not work cause font-metrics are missing.
See attached example.
$oMulticell = new PdfMulticell( $pdf );
$pdf->AddPage();
$pdf->AddFont( 'dejavusans', '', 'DejaVuSans.ttf', true );
$pdf->AddFont( 'dejavusans', '', 'DejaVuSans.ttf', true );
$pdf->AddFont( 'dejavusans', 'B', 'DejaVuSans-Bold.ttf', true );
$oMulticell->SetStyle("b",'dejavusans',"b",10, "0,0,0");
$array_docs = array();
PS: I see there is a problem in the zip I provided and UTF8 font generated files, please go into tfpdf_multicell\font\unifont* directory and delete all dejavusans..php files. They will be re-generated on the first call.
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Andrei Bintintan almost 6 years ago
Just as a side-note: I see you use the fpdf utf8 library(tfpdf). That is based on a very old fpdf version add-on script.
If you need UTF8 I do recommend switching to tcpdf instead of tfpdf, or for simple ISO chars, stick to the normal fpdf.
If you want to change, just purchase the one you need, I will refund the old lib.
RE: FPDF MulticellTag Add-On with PHP 7.0 - Added by Kevin JEANSON almost 6 years ago
Thanks for help Andrei.
I'll buy Tcpdf Advanced Multicell