Auto PageBreak ehancement with linebreaks anticipation
This commit is contained in:
parent
b156875843
commit
95068050b0
@ -320,8 +320,8 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
if($i < ($nblignes - 1)){
|
if($i < ($nblignes - 1)){
|
||||||
//on récupère la description du produit suivant
|
//on récupère la description du produit suivant
|
||||||
$follow_descproduitservice = $com->lignes[$i+1]->desc;
|
$follow_descproduitservice = $com->lignes[$i+1]->desc;
|
||||||
//on compte le nombre de ligne afin de vérifier la place disponible
|
//on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres)
|
||||||
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
|
$nblineFollowDesc = (num_lines($follow_descproduitservice,52)*4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$nblineFollowDesc = 0;
|
$nblineFollowDesc = 0;
|
||||||
|
|||||||
@ -338,8 +338,8 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
if($i < ($nblignes - 1)){
|
if($i < ($nblignes - 1)){
|
||||||
//on récupère la description du produit suivant
|
//on récupère la description du produit suivant
|
||||||
$follow_descproduitservice = $fac->lignes[$i+1]->desc;
|
$follow_descproduitservice = $fac->lignes[$i+1]->desc;
|
||||||
//on compte le nombre de ligne afin de vérifier la place disponible
|
//on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres)
|
||||||
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
|
$nblineFollowDesc = (num_lines($follow_descproduitservice,52)*4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$nblineFollowDesc = 0;
|
$nblineFollowDesc = 0;
|
||||||
|
|||||||
@ -324,11 +324,19 @@ class pdf_propale_azur extends ModelePDFPropales
|
|||||||
|
|
||||||
$nexY+=2; // Passe espace entre les lignes
|
$nexY+=2; // Passe espace entre les lignes
|
||||||
|
|
||||||
//on récupère la description du produit suivant
|
|
||||||
$follow_descproduitservice = $propale->lignes[$i+1]->desc;
|
|
||||||
//on compte le nombre de ligne afin de vérifier la place disponible
|
//on compte le nombre de ligne afin de vérifier la place disponible
|
||||||
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
|
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
|
||||||
|
// cherche nombre de lignes a venir pour savoir si place suffisante
|
||||||
|
if($i < ($nblignes - 1)){
|
||||||
|
//on récupère la description du produit suivant
|
||||||
|
$follow_descproduitservice = $propale->lignes[$i+1]->desc;
|
||||||
|
//on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres)
|
||||||
|
$nblineFollowDesc = (num_lines($follow_descproduitservice,52)*4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$nblineFollowDesc = 0;
|
||||||
|
|
||||||
|
// test si besoin nouvelle page
|
||||||
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
|
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
|
||||||
{
|
{
|
||||||
if ($pagenb == 1)
|
if ($pagenb == 1)
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -2779,13 +2780,30 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
|||||||
\param texte Texte
|
\param texte Texte
|
||||||
\return nblines Nombre de lignes
|
\return nblines Nombre de lignes
|
||||||
*/
|
*/
|
||||||
function num_lines($texte)
|
function num_lines($texte,$maxlinesize=0)
|
||||||
{
|
{
|
||||||
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
||||||
$texte = strtr($texte, $repTable);
|
$texte = strtr($texte, $repTable);
|
||||||
$pattern = '/(<[^>]+>)/Uu';
|
$pattern = '/(<[^>]+>)/Uu';
|
||||||
$a = preg_split($pattern, $texte, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$a = preg_split($pattern, $texte, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
$nblines = ((count($a)+1)/2);
|
$nblines = ((count($a)+1)/2);
|
||||||
|
// count possible auto line breaks
|
||||||
|
if($maxlinesize)
|
||||||
|
{
|
||||||
|
foreach ($a as $line)
|
||||||
|
{
|
||||||
|
if (strlen($line)>$maxlinesize)
|
||||||
|
{
|
||||||
|
//$line_dec = html_entity_decode(strip_tags($line));
|
||||||
|
$line_dec = html_entity_decode($line);
|
||||||
|
if(strlen($line_dec)>$maxlinesize)
|
||||||
|
{
|
||||||
|
$line_dec=wordwrap($line_dec,$maxlinesize,'\n',true);
|
||||||
|
$nblines+=substr_count($line_dec,'\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $nblines;
|
return $nblines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user