From 9d44590980d02f7725c5328a4e2c184aa5688a5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Oct 2012 11:17:49 +0100 Subject: [PATCH] Fix: Using a more precise function to calculate free texts height avoid having few pixels offset on free texts. --- htdocs/core/lib/pdf.lib.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 7cbcdb4854d..e710dae2cf0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -658,21 +658,25 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $pdf->SetDrawColor(224,224,224); // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output); - //print 'nbofline='.$nbofline; exit; - //print 'e'.$line.'t'.dol_nboflines($line);exit; - $marginwithfooter=$marge_basse + ($nbofline*3) + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); + if ($line) // Free text + { + $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. + if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { + $width=200; $align='C'; + } + $freetextheight=$pdf->getStringHeight($width,$line); + } + + $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); $posy=$marginwithfooter+0; if ($line) // Free text { $pdf->SetXY($dims['lm'],-$posy); - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { $width=200; $align='C'; } $pdf->MultiCell($width, 3, $line, 0, $align, 0); - $posy-=($nbofline*3); // 6 of ligne + 3 of MultiCell + $posy-=$freetextheight; } - + $pdf->SetY(-$posy); $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); $posy--;