5 * Convertisseur HTML => PDF, utilise FPDF
6 * Distribué sous la licence LGPL.
8 * @author Laurent MINGUET <webmaster@html2pdf.fr>
12 if (!defined('__CLASS_HTML2PDF__'))
14 define('__CLASS_HTML2PDF__', '3.31');
16 require_once(dirname(__FILE__
).'/_mypdf/mypdf.class.php'); // classe mypdf
17 require_once(dirname(__FILE__
).'/parsingHTML.class.php'); // classe de parsing HTML
18 require_once(dirname(__FILE__
).'/styleHTML.class.php'); // classe de gestion des styles
20 global $HTML2PDF_TABLEAU; $HTML2PDF_TABLEAU = array(); // tableau global necessaire à la gestion des tables imbriquées
21 global $HTML2PDF_TEXTES; $HTML2PDF_TEXTES = array(); // tableau comprennant le fichier de langue
25 var $pdf = null; // objet PDF
26 var $style = null; // objet de style
27 var $parsing = null; // objet de parsing
29 var $langue = 'fr'; // langue des messages
30 var $sens = 'P'; // sens d'affichage Portrait ou Landscape
31 var $format = 'A4'; // format de la page : A4, A3, ...
32 var $encoding = ''; // charset encoding
34 var $background = array(); // informations sur le background
35 var $testTDin1page = true; // activer le test de TD ne devant pas depasser une page
36 var $testIsImage = true; // test si les images existes ou non
37 var $testIsDeprecated = false; // test si certaines fonctions sont deprecated
38 var $isSubPart = false; // indique que le convertisseur courant est un sous html
40 var $parse_pos = 0; // position du parsing
41 var $temp_pos = 0; // position temporaire pour multi tableau
42 var $page = 0; // numero de la page courante
44 var $sub_html = null; // sous html
45 var $sub_part = false; // indicateur de sous html
47 var $maxX = 0; // zone maxi X
48 var $maxY = 0; // zone maxi Y
49 var $maxE = 0; // nomre d'elements dans la zone
50 var $maxH = 0; // plus grande hauteur dans la ligne, pour saut de ligne à corriger
51 var $maxSave = array(); // tableau de sauvegarde des maximaux
52 var $currentH = 0; // hauteur de la ligne courante
54 var $firstPage = true; // premier page
56 var $defaultLeft = 0; // marges par default de la page
58 var $defaultRight = 0;
59 var $defaultBottom = 0;
61 var $margeLeft = 0; //marges réelles de la page
65 var $marges = array(); // tableau de sauvegarde des differents etats des marges de la page courante
67 var $inLink = ''; // indique si on est à l'interieur d'un lien
68 var $lstAncre = array(); // liste des ancres détectées ou créées
69 var $subHEADER = array(); // tableau des sous commandes pour faire l'HEADER
70 var $subFOOTER = array(); // tableau des sous commandes pour faire le FOOTER
71 var $subSTATES = array(); // tableau de sauvegarde de certains paramètres
72 var $defLIST = array(); // tableau de sauvegarde de l'etat des UL et OL
74 var $lstChamps = array(); // liste des champs
75 var $lstSelect = array(); // options du select en cours
76 var $previousCall = null; // dernier appel
77 var $pageMarges = array(); // marges spécifiques dues aux floats
78 var $isInThead = false; // indique si on est dans un thead
79 var $isInTfoot = false; // indique si on est dans un tfoot
80 var $isInOverflow = false; // indique si on est dans une div overflow
81 var $isInFooter = false; // indique si on est dans un footer ou non
82 var $isInDraw = null; // indique si on est en mode dessin
83 var $isAfterFloat = false; // indique si on est apres un float
84 var $forOneLine = false; // indique si on est dans un sous HTML ne servant qu'a calculer la taille de la prochaine ligne
85 var $isInForm = false; // indique si on est dans un formulaire. Contient dans ce cas là l'action de celui-ci
87 var $DEBUG_actif = false; // indique si on est en mode debug
88 var $DEBUG_ok_usage = false; // indique l'existance de la fonction memory_get_usage
89 var $DEBUG_ok_peak = false; // indique l'existance de la fonction memory_get_peak_usage
90 var $DEBUG_level = 0; // niveau du debug
91 var $DEBUG_start_time = 0; //
92 var $DEBUG_last_time = 0; //
93 var $defaultFont = null; // fonte par défaut si la fonte demandée n'existe pas
98 * @param string sens portrait ou landscape
99 * @param string format A4, A5, ...
100 * @param string langue : fr, en, it...
101 * @param array marges par defaut, dans l'ordre (left, top, right, bottom)
104 function HTML2PDF($sens = 'P', $format = 'A4', $langue='fr', $marges = array(5, 5, 5, 8))
106 // sauvegarde des paramètres
109 $this->format
= $format;
110 $this->encoding
= 'ISO-8859-15';
112 $this->firstPage
= true;
113 $this->langue
= strtolower($langue);
115 // chargement du fichier de langue
116 HTML2PDF
::textLOAD($this->langue
);
118 // création de l' objet PDF
119 $this->pdf
= new MyPDF($sens, 'mm', $format);
121 // initialisation des styles
122 $this->style
= new styleHTML($this->pdf
);
123 $this->style
->FontSet();
124 $this->defLIST
= array();
126 // initialisations diverses
127 $this->setTestTdInOnePage(true);
128 $this->setTestIsImage(true);
129 $this->setTestIsDeprecated(true);
130 $this->setDefaultFont(null);
132 // initialisation du parsing
133 $this->parsing
= new parsingHTML($this->encoding
);
134 $this->sub_html
= null;
135 $this->sub_part
= false;
137 // initialisation des marges
138 if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges);
139 $this->setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]);
141 $this->marges
= array();
143 // initialisation des champs de formulaire
144 $this->lstChamps
= array();
148 * activer le debug mode
152 function setModeDebug()
154 list($usec, $sec) = explode(' ', microtime());
156 $this->DEBUG_actif
= true;
157 $this->DEBUG_ok_usage
= function_exists('memory_get_usage');
158 $this->DEBUG_ok_peak
= function_exists('memory_get_peak_usage');
159 $this->DEBUG_start_time
= (float)$sec +
(float)$usec;
160 $this->DEBUG_last_time
= (float)$sec +
(float)$usec;
162 $this->DEBUG_stepline('step', 'time', 'delta', 'memory', 'peak');
163 $this->DEBUG_add('Init debug');
167 * rajouter une ligne de debug
169 * @param string nom de l'etape
170 * @param boolean true=monter d'un niveau, false=descendre d'un niveau, null : ne rien faire
173 function DEBUG_add($nom, $level=null)
175 list($usec, $sec) = explode(' ', microtime());
176 if ($level===true) $this->DEBUG_level++
;
178 $nom = str_repeat(' ',$this->DEBUG_level
). $nom.($level===true ?
' Begin' : ($level===false ?
' End' : ''));
179 $time = (float)$sec +
(float)$usec;
180 $usage = ($this->DEBUG_ok_usage ?
memory_get_usage() : 0);
181 $peak = ($this->DEBUG_ok_peak ?
memory_get_peak_usage() : 0);
183 $this->DEBUG_stepline(
185 number_format(($time - $this->DEBUG_start_time
)*1000, 1, '.', ' ').' ms',
186 number_format(($time - $this->DEBUG_last_time
)*1000, 1, '.', ' ').' ms',
187 number_format($usage/1024, 1, '.', ' ').' Ko',
188 number_format($peak/1024, 1, '.', ' ').' Ko');
190 $this->DEBUG_last_time
= $time;
191 if ($level===false) $this->DEBUG_level
--;
196 * affiche une ligne de debug
198 * @param string nom de l'etape
199 * @param string valeur 1
200 * @param string valeur 2
201 * @param string valeur 3
202 * @param string valeur 4
205 function DEBUG_stepline($nom, $val1, $val2, $val3, $val4)
207 $txt = str_pad($nom, 30, ' ', STR_PAD_RIGHT
).
208 str_pad($val1, 12, ' ', STR_PAD_LEFT
).
209 str_pad($val2, 12, ' ', STR_PAD_LEFT
).
210 str_pad($val3, 15, ' ', STR_PAD_LEFT
).
211 str_pad($val4, 15, ' ', STR_PAD_LEFT
);
213 echo '<pre style="padding:0; margin:0">'.$txt.'</pre>';
217 * renseigner l'encoding à utiliser
219 * @param string nouvel encoding
220 * @return string ancien encoding
222 function setEncoding($encoding = 'ISO-8859-15')
224 $old = $this->encoding
;
225 $this->encoding
= $encoding;
226 $this->parsing
->setEncoding($this->encoding
);
231 * activer ou desactiver le test de TD ne devant pas depasser une page
233 * @param boolean nouvel etat
234 * @return boolean ancien etat
236 function setTestTdInOnePage($mode = true)
238 $old = $this->testTDin1page
;
239 $this->testTDin1page
= $mode ?
true : false;
244 * activer ou desactiver le test sur la présence des images
246 * @param boolean nouvel etat
247 * @return boolean ancien etat
249 function setTestIsImage($mode = true)
251 $old = $this->testIsImage
;
252 $this->testIsImage
= $mode ?
true : false;
257 * activer ou desactiver le test sur les fonctions deprecated
259 * @param boolean nouvel etat
260 * @return boolean ancien etat
262 function setTestIsDeprecated($mode = true)
264 $old = $this->testIsDeprecated
;
265 $this->testIsDeprecated
= $mode ?
true : false;
270 * définit la fonte par défaut si aucun fonte n'est spécifiée, ou si la fonte demandée n'existe pas
272 * @param string nom de la fonte par defaut. si null : Arial pour fonte non spécifiée, et erreur pour fonte non existante
273 * @return string nom de l'ancienne fonte par defaut
275 function setDefaultFont($default = null)
277 $old = $this->defaultFont
;
278 $this->defaultFont
= $default;
279 $this->style
->setDefaultFont($default);
284 * définir les marges par défault
286 * @param int en mm, marge left
287 * @param int en mm, marge top
288 * @param int en mm, marge right. si null, left=right
289 * @param int en mm, marge bottom. si null, bottom=8
292 function setDefaultMargins($left, $top, $right = null, $bottom = null)
294 if ($right===null) $right = $left;
295 if ($bottom===null) $bottom = 8;
297 $this->defaultLeft
= $this->style
->ConvertToMM($left.'mm');
298 $this->defaultTop
= $this->style
->ConvertToMM($top.'mm');
299 $this->defaultRight
= $this->style
->ConvertToMM($right.'mm');
300 $this->defaultBottom
= $this->style
->ConvertToMM($bottom.'mm');
304 * définir les marges réelles, fonctions de la balise page
308 function setMargins()
310 $this->margeLeft
= $this->defaultLeft +
(isset($this->background
['left']) ?
$this->background
['left'] : 0);
311 $this->margeRight
= $this->defaultRight +
(isset($this->background
['right']) ?
$this->background
['right'] : 0);
312 $this->margeTop
= $this->defaultTop +
(isset($this->background
['top']) ?
$this->background
['top'] : 0);
313 $this->margeBottom
= $this->defaultBottom +
(isset($this->background
['bottom']) ?
$this->background
['bottom'] : 0);
315 $this->pdf
->SetMargins($this->margeLeft
, $this->margeTop
, $this->margeRight
);
316 $this->pdf
->setcMargin(0);
317 $this->pdf
->SetAutoPageBreak(false, $this->margeBottom
);
319 $this->pageMarges
= array();
320 $this->pageMarges
[floor($this->margeTop
*100)] = array($this->margeLeft
, $this->pdf
->getW()-$this->margeRight
);
324 * recuperer les positions x minimales et maximales en fonction d'une hauteur
327 * @return array(float, float)
329 function getMargins($y)
332 $x = array($this->pdf
->getlMargin(), $this->pdf
->getW()-$this->pdf
->getrMargin());
334 foreach($this->pageMarges
as $m_y => $m_x)
335 if ($m_y<=$y) $x = $m_x;
341 * ajouter une marge suite a un float
343 * @param string left ou right
350 function addMargins($float, $x1, $y1, $x2, $y2)
352 $old1 = $this->getMargins($y1);
353 $old2 = $this->getMargins($y2);
354 if ($float=='left') $old1[0] = $x2;
355 if ($float=='right') $old1[1] = $x1;
357 $y1 = floor($y1*100);
358 $y2 = floor($y2*100);
360 foreach($this->pageMarges
as $m_y => $m_x)
362 if ($m_y<$y1) continue;
364 if ($float=='left' && $this->pageMarges
[$m_y][0]<$x2) unset($this->pageMarges
[$m_y]);
365 if ($float=='right' && $this->pageMarges
[$m_y][1]>$x1) unset($this->pageMarges
[$m_y]);
368 $this->pageMarges
[$y1] = $old1;
369 $this->pageMarges
[$y2] = $old2;
371 ksort($this->pageMarges
);
373 $this->isAfterFloat
= true;
377 * définir des nouvelles marges et sauvegarder les anciennes
379 * @param float marge left
380 * @param float marge top
381 * @param float marge right
384 function saveMargin($ml, $mt, $mr)
386 $this->marges
[] = array('l' => $this->pdf
->getlMargin(), 't' => $this->pdf
->gettMargin(), 'r' => $this->pdf
->getrMargin(), 'page' => $this->pageMarges
);
387 $this->pdf
->SetMargins($ml, $mt, $mr);
389 $this->pageMarges
= array();
390 $this->pageMarges
[floor($mt*100)] = array($ml, $this->pdf
->getW()-$mr);
394 * récuperer les dernières marches sauvées
398 function loadMargin()
400 $old = array_pop($this->marges
);
410 $ml = $this->margeLeft
;
412 $mr = $this->margeRight
;
413 $mP = array($mt => array($ml, $this->pdf
->getW()-$mr));
416 $this->pdf
->SetMargins($ml, $mt, $mr);
417 $this->pageMarges
= $mP;
421 * permet d'ajouter une fonte.
423 * @param string nom de la fonte
424 * @param string style de la fonte
425 * @param string fichier de la fonte
428 function addFont($family, $style='', $file='')
430 $this->pdf
->AddFont($family, $style, $file);
434 * sauvegarder l'état actuelle des maximums
440 $this->maxSave
[] = array($this->maxX
, $this->maxY
, $this->maxH
, $this->maxE
);
444 * charger le dernier état sauvé des maximums
450 $old = array_pop($this->maxSave
);
454 $this->maxX
= $old[0];
455 $this->maxY
= $old[1];
456 $this->maxH
= $old[2];
457 $this->maxE
= $old[3];
469 * afficher l'header contenu dans page_header
473 function setPageHeader()
475 if (!count($this->subHEADER
)) return false;
477 $OLD_parse_pos = $this->parse_pos
;
478 $OLD_parse_code = $this->parsing
->code
;
480 $this->parse_pos
= 0;
481 $this->parsing
->code
= $this->subHEADER
;
482 $this->makeHTMLcode();
484 $this->parse_pos
= $OLD_parse_pos;
485 $this->parsing
->code
= $OLD_parse_code;
489 * afficher le footer contenu dans page_footer
493 function setPageFooter()
495 if (!count($this->subFOOTER
)) return false;
497 $OLD_parse_pos = $this->parse_pos
;
498 $OLD_parse_code = $this->parsing
->code
;
500 $this->parse_pos
= 0;
501 $this->parsing
->code
= $this->subFOOTER
;
502 $this->isInFooter
= true;
503 $this->makeHTMLcode();
504 $this->isInFooter
= false;
506 $this->parse_pos
= $OLD_parse_pos;
507 $this->parsing
->code
= $OLD_parse_code;
511 * saut de ligne avec une hauteur spécifique
513 * @param float hauteur de la ligne
514 * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
517 function setNewLine($h, $curr = null)
521 $this->setNewPositionForNewLine($curr);
525 * création d'une nouvelle page avec le format et l'orientation spécifies
527 * @param mixed format de la page : A5, A4, array(width, height)
528 * @param string sens P=portrait ou L=landscape
529 * @param array tableau des propriétés du fond de la page
530 * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
533 function setNewPage($format = null, $orientation = '', $background = null, $curr = null)
535 $this->firstPage
= false;
537 $this->format
= $format ?
$format : $this->format
;
538 $this->sens
= $orientation ?
$orientation : $this->sens
;
539 $this->background
= $background!==null ?
$background : $this->background
;
544 $this->pdf
->SetMargins($this->defaultLeft
, $this->defaultTop
, $this->defaultRight
);
545 $this->pdf
->AddPage($this->sens
, $this->format
);
548 if (!$this->sub_part
&& !$this->isSubPart
)
550 if (is_array($this->background
))
552 if (isset($this->background
['color']) && $this->background
['color'])
554 $this->pdf
->setMyFillColor($this->background
['color']);
555 $this->pdf
->Rect(0, 0, $this->pdf
->getW(), $this->pdf
->getH(), 'F');
558 if (isset($this->background
['img']) && $this->background
['img'])
559 $this->pdf
->Image($this->background
['img'], $this->background
['posX'], $this->background
['posY'], $this->background
['width']);
562 $this->setPageHeader();
563 $this->setPageFooter();
567 $this->pdf
->setY($this->margeTop
);
569 $this->setNewPositionForNewLine($curr);
574 * calcul de la position de debut de la prochaine ligne en fonction de l'alignement voulu
576 * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
579 function setNewPositionForNewLine($curr = null)
581 list($lx, $rx) = $this->getMargins($this->pdf
->getY());
582 $this->pdf
->setX($lx);
586 if ($this->sub_part ||
$this->isSubPart ||
$this->forOneLine
)
588 // $this->pdf->setWordSpacing(0);
593 $this->style->value['text-align']!='right' &&
594 $this->style->value['text-align']!='center' &&
595 $this->style->value['text-align']!='justify'
598 // $this->pdf->setWordSpacing(0);
603 $this->createSubHTML($sub);
604 $sub->saveMargin(0, 0, $sub->pdf
->getW()-$wMax);
605 $sub->forOneLine
= true;
606 $sub->parse_pos
= $this->parse_pos
;
607 $sub->parsing
->code
= $this->parsing
->code
;
609 if ($curr!==null && $sub->parsing
->code
[$this->parse_pos
]['name']=='write')
611 $txt = $sub->parsing
->code
[$this->parse_pos
]['param']['txt'];
612 $txt = str_replace('[[page_cu]]', $sub->page
, $txt);
613 $sub->parsing
->code
[$this->parse_pos
]['param']['txt'] = substr($txt, $curr);
618 // pour chaque element identifié par le parsing
620 for($sub->parse_pos
; $sub->parse_pos
<count($sub->parsing
->code
); $sub->parse_pos++
)
622 $todo = $sub->parsing
->code
[$sub->parse_pos
];
623 $res = $sub->loadAction($todo);
627 $w = $sub->maxX
; // largeur maximale
628 $h = $sub->maxH
; // hauteur maximale
629 $e = ($res===null ?
$sub->maxE
: 0); // nombre d'éléments maximal
630 $this->destroySubHTML($sub);
632 if ($this->style
->value
['text-align']=='center')
633 $this->pdf
->setX(($rx+
$this->pdf
->getX()-$w)*0.5-0.01);
634 elseif ($this->style
->value
['text-align']=='right')
635 $this->pdf
->setX($rx-$w-0.01);
637 $this->pdf
->setX($lx);
639 $this->currentH
= $h;
641 if ($this->style->value['text-align']=='justify' && $e>1)
642 $this->pdf->setWordSpacing(($wMax-$w)/($e-1));
644 $this->pdf->setWordSpacing(0);
649 * récupération du PDF
651 * @param string nom du fichier PDF
652 * @param boolean destination
653 * @return string contenu éventuel du pdf
656 * Destination où envoyer le document. Le paramètre peut prendre les valeurs suivantes :
657 * true : equivalent à I
658 * false : equivalent à S
659 * I : envoyer en inline au navigateur. Le plug-in est utilisé s'il est installé. Le nom indiqué dans name est utilisé lorsque l'on sélectionne "Enregistrer sous" sur le lien générant le PDF.
660 * D : envoyer au navigateur en forçant le téléchargement, avec le nom indiqué dans name.
661 * F : sauver dans un fichier local, avec le nom indiqué dans name (peut inclure un répertoire).
662 * S : renvoyer le document sous forme de chaîne. name est ignoré.
664 function Output($name = '', $dest = false)
667 global $HTML2PDF_TABLEAU; $HTML2PDF_TABLEAU = array();
669 if ($this->DEBUG_actif
)
671 $this->DEBUG_add('Before output');
676 // interpretation des paramètres
677 if ($dest===false) $dest = 'I';
678 if ($dest===true) $dest = 'S';
679 if ($dest==='') $dest = 'I';
680 if ($name=='') $name='document.pdf';
682 // verification de la destination
683 $dest = strtoupper($dest);
684 if (!in_array($dest, array('I', 'D', 'F', 'S'))) $dest = 'I';
686 // verification du nom
687 if (strtolower(substr($name, -4))!='.pdf')
689 echo 'ERROR : The output document name "'.$name.'" is not a PDF name';
693 return $this->pdf
->Output($name, $dest);
697 * création d'un sous HTML2PDF pour la gestion des tableaux imbriqués
699 * @param HTML2PDF futur sous HTML2PDF passé en référence pour création
700 * @param integer marge eventuelle de l'objet si simulation d'un TD
703 function createSubHTML(&$sub_html, $cellmargin=0)
705 // calcul de la largueur
706 if ($this->style
->value
['width'])
708 $marge = $cellmargin*2;
709 $marge+
= $this->style
->value
['padding']['l'] +
$this->style
->value
['padding']['r'];
710 $marge+
= $this->style
->value
['border']['l']['width'] +
$this->style
->value
['border']['r']['width'];
711 $marge = $this->pdf
->getW() - $this->style
->value
['width'] +
$marge;
714 $marge = $this->margeLeft+
$this->margeRight
;
717 $sub_html = new HTML2PDF(
721 array($this->defaultLeft
,$this->defaultTop
,$this->defaultRight
,$this->defaultBottom
)
723 $sub_html->setIsSubPart();
724 $sub_html->setEncoding($this->encoding
);
725 $sub_html->setTestTdInOnePage($this->testTDin1page
);
726 $sub_html->setTestIsImage($this->testIsImage
);
727 $sub_html->setTestIsDeprecated($this->testIsDeprecated
);
728 $sub_html->setDefaultFont($this->defaultFont
);
729 $sub_html->style
->css
= $this->style
->css
;
730 $sub_html->style
->css_keys
= $this->style
->css_keys
;
731 $sub_html->pdf
->cloneFontFrom($this->pdf
);
733 $sub_html->style
->table
= $this->style
->table
;
734 $sub_html->style
->value
= $this->style
->value
;
735 $sub_html->style
->setOnlyLeft();
736 $sub_html->setNewPage($this->format
, $this->sens
);
737 $sub_html->initSubHtml($marge, $this->page
, $this->defLIST
);
739 // initialisation des positions et autre
743 $sub_html->pdf
->setXY(0, 0);
747 * initialise le sous HTML2PDF. Ne pas utiliser directement. seul la fonction createSubHTML doit l'utiliser
751 function initSubHtml($marge, $page, $defLIST)
753 $this->saveMargin(0, 0, $marge);
754 $this->defLIST
= $defLIST;
757 $this->pdf
->setXY(0, 0);
758 $this->style
->FontSet();
761 function setIsSubPart()
763 $this->isSubPart
= true;
767 * destruction d'un sous HTML2PDF pour la gestion des tableaux imbriqués
771 function destroySubHTML(&$sub_html)
778 * Convertir un nombre arabe en nombre romain
780 * @param integer nombre à convertir
781 * @return string nombre converti
783 function listeArab2Rom($nb_ar)
785 $nb_b10 = array('I','X','C','M');
786 $nb_b5 = array('V','L','D');
789 if ($nb_ar<1) return $nb_ar;
790 if ($nb_ar>3999) return $nb_ar;
792 for($i=3; $i>=0 ; $i--)
794 $chiffre=floor($nb_ar/pow(10,$i));
797 $nb_ar=$nb_ar-$chiffre*pow(10,$i);
800 for($j=$chiffre; $j>=1; $j--)
802 $nb_ro=$nb_ro.$nb_b10[$i];
807 $nb_ro=$nb_ro.$nb_b10[$i].$nb_b10[$i+
1];
811 $nb_ro=$nb_ro.$nb_b10[$i].$nb_b5[$i];
815 $nb_ro=$nb_ro.$nb_b5[$i];
816 for($j=$chiffre-5; $j>=1; $j--)
818 $nb_ro=$nb_ro.$nb_b10[$i];
827 * Ajouter un LI au niveau actuel
831 function listeAddLi()
833 $this->defLIST
[count($this->defLIST
)-1]['nb']++
;
836 function listeGetWidth() { return '7mm'; }
837 function listeGetPadding() { return '1mm'; }
840 * Recuperer le LI du niveau actuel
842 * @return string chaine à afficher
844 function listeGetLi()
846 $im = $this->defLIST
[count($this->defLIST
)-1]['img'];
847 $st = $this->defLIST
[count($this->defLIST
)-1]['style'];
848 $nb = $this->defLIST
[count($this->defLIST
)-1]['nb'];
849 $up = (substr($st, 0, 6)=='upper-');
851 if ($im) return array(false, false, $im);
856 return array('helvetica', true, ' ');
863 $str = chr(96+
$nb%26
).$str;
866 $str = chr(96+
$nb).$str;
868 return array('helvetica', false, ($up ?
strtoupper($str) : $str).'.');
872 $str = $this->listeArab2Rom($nb);
874 return array('helvetica', false, ($up ?
strtoupper($str) : $str).'.');
877 return array('helvetica', false, $nb.'.');
880 return array('zapfdingbats', true, chr(110));
883 return array('zapfdingbats', true, chr(109));
887 return array('zapfdingbats', true, chr(108));
892 * Ajouter un niveau de liste
894 * @param string type de liste : ul, ol
895 * @param string style de la liste
898 function listeAddLevel($type = 'ul', $style = '', $img = null)
902 if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match))
910 if (!in_array($type, array('ul', 'ol'))) $type = 'ul';
911 if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
915 if ($type=='ul') $style = 'disc';
916 else $style = 'decimal';
918 $this->defLIST
[count($this->defLIST
)] = array('style' => $style, 'nb' => 0, 'img' => $img);
922 * Supprimer un niveau de liste
926 function listeDelLevel()
928 if (count($this->defLIST
))
930 unset($this->defLIST
[count($this->defLIST
)-1]);
931 $this->defLIST
= array_values($this->defLIST
);
936 * traitement d'un code HTML fait pour HTML2PDF
938 * @param string code HTML à convertir
939 * @param boolean afficher en pdf (false) ou en html adapté (true)
942 function writeHTML($html, $vue = false)
944 // si c'est une vrai page HTML, une conversion s'impose
945 if (preg_match('/<body/isU', $html))
946 $html = $this->getHtmlFromPage($html);
948 $html = str_replace('[[page_nb]]', '{nb}', $html);
950 $html = str_replace('[[date_y]]', date('Y'), $html);
951 $html = str_replace('[[date_m]]', date('m'), $html);
952 $html = str_replace('[[date_d]]', date('d'), $html);
954 $html = str_replace('[[date_h]]', date('H'), $html);
955 $html = str_replace('[[date_i]]', date('i'), $html);
956 $html = str_replace('[[date_s]]', date('s'), $html);
958 // si on veut voir le résultat en HTML => on appelle la fonction
959 if ($vue) $this->vueHTML($html);
961 // sinon, traitement pour conversion en PDF :
963 $this->sub_pdf
= false;
964 $this->style
->readStyle($html);
965 $this->parsing
->setHTML($html);
966 $this->parsing
->parse();
967 $this->makeHTMLcode();
971 * traitement du code d'une vrai page HTML pour l'adapter à HTML2PDF
973 * @param string code HTML à adapter
974 * @return string code HTML adapté
976 function getHtmlFromPage($html)
978 $html = str_replace('<BODY', '<body', $html);
979 $html = str_replace('</BODY', '</body', $html);
981 // extraction du contenu
982 $res = explode('<body', $html);
983 if (count($res)<2) return $html;
984 $content = '<page'.$res[1];
985 $content = explode('</body', $content);
986 $content = $content[0].'</page>';
988 // extraction des balises link
989 preg_match_all('/<link([^>]*)>/isU', $html, $match);
990 foreach($match[0] as $src)
991 $content = $src.'</link>'.$content;
993 // extraction des balises style
994 preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
995 foreach($match[0] as $src)
996 $content = $src.$content;
1002 * execute les différentes actions du code HTML
1006 function makeHTMLcode()
1008 // pour chaque element identifié par le parsing
1009 for($this->parse_pos
=0; $this->parse_pos
<count($this->parsing
->code
); $this->parse_pos++
)
1011 // récupération de l'élément
1012 $todo = $this->parsing
->code
[$this->parse_pos
];
1014 // si c'est une ouverture de tableau
1015 if (in_array($todo['name'], array('table', 'ul', 'ol')) && !$todo['close'])
1017 // on va créer un sous HTML, et on va travailler sur une position temporaire
1018 $tag_open = $todo['name'];
1020 $this->sub_part
= true;
1021 $this->temp_pos
= $this->parse_pos
;
1023 // pour tous les éléments jusqu'à la fermeture de la table afin de préparer les dimensions
1024 while(isset($this->parsing
->code
[$this->temp_pos
]) && !($this->parsing
->code
[$this->temp_pos
]['name']==$tag_open && $this->parsing
->code
[$this->temp_pos
]['close']))
1026 $this->loadAction($this->parsing
->code
[$this->temp_pos
]);
1029 if (isset($this->parsing
->code
[$this->temp_pos
])) $this->loadAction($this->parsing
->code
[$this->temp_pos
]);
1030 $this->sub_part
= false;
1033 // chargement de l'action correspondant à l'élément
1034 $this->loadAction($todo);
1041 * affichage en mode HTML du contenu
1043 * @param string contenu
1046 function vueHTML($content)
1048 $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF
::textGET('vue01').' : $1<hr><div$1>', $content);
1049 $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF
::textGET('vue02').' : $1<hr><div$1>', $content);
1050 $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF
::textGET('vue03').' : $1<hr><div$1>', $content);
1051 $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content);
1052 $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content);
1053 $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content);
1054 $content = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $content);
1055 $content = preg_replace('/<\/barcode([^>]*)>/isU', '', $content);
1056 $content = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $content);
1057 $content = preg_replace('/<\/qrcode([^>]*)>/isU', '', $content);
1059 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1062 <title>'.HTML2PDF
::textGET('vue04').' HTML</title>
1063 <meta http-equiv="Content-Type" content="text/html; charset='.$this->encoding
.'" >
1065 <body style="padding: 10px; font-size: 10pt;font-family: Verdana;">
1073 * chargement de l'action correspondante à un element de parsing
1075 * @param array élément de parsing
1078 function loadAction($row)
1081 $fnc = ($row['close'] ?
'c_' : 'o_').strtoupper($row['name']);
1083 // parametres de l'action
1084 $param = $row['param'];
1086 // si aucune page n'est créé, on la créé
1087 if ($fnc!='o_PAGE' && $this->firstPage
)
1089 $this->setNewPage();
1092 // lancement de l'action
1093 if (is_callable(array(&$this, $fnc)))
1095 $res = $this->{$fnc}($param);
1096 $this->previousCall
= $fnc;
1101 HTML2PDF
::makeError(1, __FILE__
, __LINE__
, strtoupper($row['name']), $this->parsing
->getHtmlErrorCode($row['html_pos']));
1110 * @param array paramètres de l'élément de parsing
1113 function o_PAGE($param)
1115 if ($this->forOneLine
) return false;
1116 if ($this->DEBUG_actif
) $this->DEBUG_add('PAGE n°'.($this->page+
1), true);
1118 $newPageSet= (!isset($param['pageset']) ||
$param['pageset']!='old');
1123 $this->subHEADER
= array();
1124 $this->subFOOTER
= array();
1126 // identification de l'orientation demandée
1128 if (isset($param['orientation']))
1130 $param['orientation'] = strtolower($param['orientation']);
1131 if ($param['orientation']=='p') $orientation = 'P';
1132 if ($param['orientation']=='portrait') $orientation = 'P';
1134 if ($param['orientation']=='l') $orientation = 'L';
1135 if ($param['orientation']=='paysage') $orientation = 'L';
1136 if ($param['orientation']=='landscape') $orientation = 'L';
1139 // identification de l'orientation demandée
1141 if (isset($param['format']))
1143 $format = strtolower($param['format']);
1144 if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match))
1146 $format = array(intval($match[1]), intval($match[2]));
1150 // identification des propriétés du background
1151 $background = array();
1152 if (isset($param['backimg']))
1154 $background['img'] = isset($param['backimg']) ?
$param['backimg'] : ''; // nom de l'image
1155 $background['posX'] = isset($param['backimgx']) ?
$param['backimgx'] : 'center'; // position horizontale de l'image
1156 $background['posY'] = isset($param['backimgy']) ?
$param['backimgy'] : 'middle'; // position verticale de l'image
1157 $background['width'] = isset($param['backimgw']) ?
$param['backimgw'] : '100%'; // taille de l'image (100% = largueur de la feuille)
1159 // conversion du nom de l'image, en cas de paramètres en _GET
1160 $background['img'] = str_replace('&', '&', $background['img']);
1161 // conversion des positions
1162 if ($background['posX']=='left') $background['posX'] = '0%';
1163 if ($background['posX']=='center') $background['posX'] = '50%';
1164 if ($background['posX']=='right') $background['posX'] = '100%';
1165 if ($background['posY']=='top') $background['posY'] = '0%';
1166 if ($background['posY']=='middle') $background['posY'] = '50%';
1167 if ($background['posY']=='bottom') $background['posY'] = '100%';
1170 // si il y a une image de précisé
1171 if ($background['img'])
1173 // est-ce que c'est une image ?
1174 $infos=@GetImageSize
($background['img']);
1175 if (count($infos)>1)
1177 // taille de l'image, en fonction de la taille spécifiée.
1178 $Wi = $this->style
->ConvertToMM($background['width'], $this->pdf
->getW());
1179 $Hi = $Wi*$infos[1]/$infos[0];
1181 // récupération des dimensions et positions de l'image
1182 $background['width'] = $Wi;
1183 $background['posX'] = $this->style
->ConvertToMM($background['posX'], $this->pdf
->getW() - $Wi);
1184 $background['posY'] = $this->style
->ConvertToMM($background['posY'], $this->pdf
->getH() - $Hi);
1187 $background = array();
1190 $background = array();
1193 // marges TOP et BOTTOM pour le texte.
1194 $background['top'] = isset($param['backtop']) ?
$param['backtop'] : '0';
1195 $background['bottom'] = isset($param['backbottom']) ?
$param['backbottom'] : '0';
1196 $background['left'] = isset($param['backleft']) ?
$param['backleft'] : '0';
1197 $background['right'] = isset($param['backright']) ?
$param['backright'] : '0';
1199 if (preg_match('/^([0-9]*)$/isU', $background['top'])) $background['top'] .= 'mm';
1200 if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm';
1201 if (preg_match('/^([0-9]*)$/isU', $background['left'])) $background['left'] .= 'mm';
1202 if (preg_match('/^([0-9]*)$/isU', $background['right'])) $background['right'] .= 'mm';
1204 $background['top'] = $this->style
->ConvertToMM($background['top'], $this->pdf
->getH());
1205 $background['bottom'] = $this->style
->ConvertToMM($background['bottom'], $this->pdf
->getH());
1206 $background['left'] = $this->style
->ConvertToMM($background['left'], $this->pdf
->getW());
1207 $background['right'] = $this->style
->ConvertToMM($background['right'], $this->pdf
->getW());
1210 $background['color'] = isset($param['backcolor']) ?
$this->style
->ConvertToColor($param['backcolor'], $res) : null;
1211 if (!$res) $background['color'] = null;
1213 $this->style
->save();
1214 $this->style
->analyse('PAGE', $param);
1215 $this->style
->setPosition();
1216 $this->style
->FontSet();
1219 $this->setNewPage($format, $orientation, $background);
1221 // footer automatique
1222 if (isset($param['footer']))
1224 $lst = explode(';', $param['footer']);
1225 foreach($lst as $key => $val) $lst[$key] = trim(strtolower($val));
1226 $page = in_array('page', $lst);
1227 $date = in_array('date', $lst);
1228 $heure = in_array('heure', $lst);
1229 $form = in_array('form', $lst);
1238 $this->pdf
->SetMyFooter($page, $date, $heure, $form);
1242 $this->style
->save();
1243 $this->style
->analyse('PAGE', $param);
1244 $this->style
->setPosition();
1245 $this->style
->FontSet();
1247 $this->setNewPage();
1257 * @param array paramètres de l'élément de parsing
1260 function c_PAGE($param)
1262 if ($this->forOneLine
) return false;
1266 $this->style
->load();
1267 $this->style
->FontSet();
1269 if ($this->DEBUG_actif
) $this->DEBUG_add('PAGE n°'.$this->page
, false);
1275 function o_PAGE_HEADER($param)
1277 if ($this->forOneLine
) return false;
1279 $this->subHEADER
= array();
1280 for($this->parse_pos
; $this->parse_pos
<count($this->parsing
->code
); $this->parse_pos++
)
1282 $todo = $this->parsing
->code
[$this->parse_pos
];
1283 if ($todo['name']=='page_header') $todo['name']='page_header_sub';
1284 $this->subHEADER
[] = $todo;
1285 if (strtolower($todo['name'])=='page_header_sub' && $todo['close']) break;
1288 $this->setPageHeader();
1293 function o_PAGE_FOOTER($param)
1295 if ($this->forOneLine
) return false;
1297 $this->subFOOTER
= array();
1298 for($this->parse_pos
; $this->parse_pos
<count($this->parsing
->code
); $this->parse_pos++
)
1300 $todo = $this->parsing
->code
[$this->parse_pos
];
1301 if ($todo['name']=='page_footer') $todo['name']='page_footer_sub';
1302 $this->subFOOTER
[] = $todo;
1303 if (strtolower($todo['name'])=='page_footer_sub' && $todo['close']) break;
1306 $this->setPageFooter();
1311 function o_PAGE_HEADER_SUB($param)
1313 if ($this->forOneLine
) return false;
1315 // sauvegarde de l'état
1316 $this->subSTATES
= array();
1317 $this->subSTATES
['x'] = $this->pdf
->getX();
1318 $this->subSTATES
['y'] = $this->pdf
->getY();
1319 $this->subSTATES
['s'] = $this->style
->value
;
1320 $this->subSTATES
['t'] = $this->style
->table
;
1321 $this->subSTATES
['ml'] = $this->margeLeft
;
1322 $this->subSTATES
['mr'] = $this->margeRight
;
1323 $this->subSTATES
['mt'] = $this->margeTop
;
1324 $this->subSTATES
['mb'] = $this->margeBottom
;
1325 $this->subSTATES
['mp'] = $this->pageMarges
;
1327 // nouvel etat pour le footer
1328 $this->pageMarges
= array();
1329 $this->margeLeft
= $this->defaultLeft
;
1330 $this->margeRight
= $this->defaultRight
;
1331 $this->margeTop
= $this->defaultTop
;
1332 $this->margeBottom
= $this->defaultBottom
;
1333 $this->pdf
->SetMargins($this->margeLeft
, $this->margeTop
, $this->margeRight
);
1334 $this->pdf
->SetAutoPageBreak(false, $this->margeBottom
);
1335 $this->pdf
->setXY($this->defaultLeft
, $this->defaultTop
);
1337 $this->style
->initStyle();
1338 $this->style
->resetStyle();
1339 $this->style
->value
['width'] = $this->pdf
->getW() - $this->defaultLeft
- $this->defaultRight
;
1340 $this->style
->table
= array();
1342 $this->style
->save();
1343 $this->style
->analyse('page_header_sub', $param);
1344 $this->style
->setPosition();
1345 $this->style
->FontSet();
1346 $this->setNewPositionForNewLine();
1350 function c_PAGE_HEADER_SUB($param)
1352 if ($this->forOneLine
) return false;
1354 $this->style
->load();
1356 // retablissement de l'etat
1357 $this->style
->value
= $this->subSTATES
['s'];
1358 $this->style
->table
= $this->subSTATES
['t'];
1359 $this->pageMarges
= $this->subSTATES
['mp'];
1360 $this->margeLeft
= $this->subSTATES
['ml'];
1361 $this->margeRight
= $this->subSTATES
['mr'];
1362 $this->margeTop
= $this->subSTATES
['mt'];
1363 $this->margeBottom
= $this->subSTATES
['mb'];
1364 $this->pdf
->SetMargins($this->margeLeft
, $this->margeTop
, $this->margeRight
);
1365 $this->pdf
->setbMargin($this->margeBottom
);
1366 $this->pdf
->SetAutoPageBreak(false, $this->margeBottom
);
1367 $this->pdf
->setXY($this->subSTATES
['x'], $this->subSTATES
['y']);
1369 $this->style
->FontSet();
1375 function o_PAGE_FOOTER_SUB($param)
1377 if ($this->forOneLine
) return false;
1379 $this->subSTATES
= array();
1380 $this->subSTATES
['x'] = $this->pdf
->getX();
1381 $this->subSTATES
['y'] = $this->pdf
->getY();
1382 $this->subSTATES
['s'] = $this->style
->value
;
1383 $this->subSTATES
['t'] = $this->style
->table
;
1384 $this->subSTATES
['ml'] = $this->margeLeft
;
1385 $this->subSTATES
['mr'] = $this->margeRight
;
1386 $this->subSTATES
['mt'] = $this->margeTop
;
1387 $this->subSTATES
['mb'] = $this->margeBottom
;
1388 $this->subSTATES
['mp'] = $this->pageMarges
;
1390 // nouvel etat pour le footer
1391 $this->pageMarges
= array();
1392 $this->margeLeft
= $this->defaultLeft
;
1393 $this->margeRight
= $this->defaultRight
;
1394 $this->margeTop
= $this->defaultTop
;
1395 $this->margeBottom
= $this->defaultBottom
;
1396 $this->pdf
->SetMargins($this->margeLeft
, $this->margeTop
, $this->margeRight
);
1397 $this->pdf
->SetAutoPageBreak(false, $this->margeBottom
);
1398 $this->pdf
->setXY($this->defaultLeft
, $this->defaultTop
);
1401 $this->style
->initStyle();
1402 $this->style
->resetStyle();
1403 $this->style
->value
['width'] = $this->pdf
->getW() - $this->defaultLeft
- $this->defaultRight
;
1404 $this->style
->table
= array();
1406 // on en créé un sous HTML que l'on transforme en PDF
1407 // pour récupérer la hauteur
1408 // on extrait tout ce qui est contenu dans le FOOTER
1410 $this->CreateSubHTML($sub);
1411 $sub->parsing
->code
= $this->parsing
->getLevel($this->parse_pos
);
1412 $sub->MakeHTMLcode();
1413 $this->pdf
->setY($this->pdf
->getH() - $sub->maxY
- $this->defaultBottom
- 0.01);
1414 $this->destroySubHTML($sub);
1416 $this->style
->save();
1417 $this->style
->analyse('page_footer_sub', $param);
1418 $this->style
->setPosition();
1419 $this->style
->FontSet();
1420 $this->setNewPositionForNewLine();
1425 function c_PAGE_FOOTER_SUB($param)
1427 if ($this->forOneLine
) return false;
1429 $this->style
->load();
1431 $this->style
->value
= $this->subSTATES
['s'];
1432 $this->style
->table
= $this->subSTATES
['t'];
1433 $this->pageMarges
= $this->subSTATES
['mp'];
1434 $this->margeLeft
= $this->subSTATES
['ml'];
1435 $this->margeRight
= $this->subSTATES
['mr'];
1436 $this->margeTop
= $this->subSTATES
['mt'];
1437 $this->margeBottom
= $this->subSTATES
['mb'];
1438 $this->pdf
->SetMargins($this->margeLeft
, $this->margeTop
, $this->margeRight
);
1439 $this->pdf
->SetAutoPageBreak(false, $this->margeBottom
);
1440 $this->pdf
->setXY($this->subSTATES
['x'], $this->subSTATES
['y']);
1442 $this->style
->FontSet();
1452 * @param array paramètres de l'élément de parsing
1455 function o_NOBREAK($param)
1457 if ($this->forOneLine
) return false;
1461 // on en créé un sous HTML que l'on transforme en PDF
1462 // pour analyse les dimensions
1463 // et voir si ca rentre
1465 $this->CreateSubHTML($sub);
1466 $sub->parsing
->code
= $this->parsing
->getLevel($this->parse_pos
);
1467 $sub->MakeHTMLcode();
1469 $y = $this->pdf
->getY();
1471 $sub->maxY
< ($this->pdf
->getH() - $this->pdf
->gettMargin()-$this->pdf
->getbMargin()) &&
1472 $y +
$sub->maxY
>=($this->pdf
->getH() - $this->pdf
->getbMargin())
1474 $this->setNewPage();
1475 $this->destroySubHTML($sub);
1485 * @param array paramètres de l'élément de parsing
1488 function c_NOBREAK($param)
1490 if ($this->forOneLine
) return false;
1501 * @param array paramètres de l'élément de parsing
1504 function o_DIV($param, $other = 'div')
1506 if ($this->forOneLine
) return false;
1507 if ($this->DEBUG_actif
) $this->DEBUG_add(strtoupper($other), true);
1509 $this->style
->save();
1510 $this->style
->analyse($other, $param);
1511 $this->style
->FontSet();
1513 // gestion specifique a la balise legend pour l'afficher au bon endroit
1514 if (in_array($other, array('fieldset', 'legend')))
1516 if (isset($param['moveTop'])) $this->style
->value
['margin']['t'] +
= $param['moveTop'];
1517 if (isset($param['moveLeft'])) $this->style
->value
['margin']['l'] +
= $param['moveLeft'];
1518 if (isset($param['moveDown'])) $this->style
->value
['margin']['b'] +
= $param['moveDown'];
1521 $align_object = null;
1522 if ($this->style
->value
['margin-auto']) $align_object = 'center';
1525 $marge['l'] = $this->style
->value
['border']['l']['width'] +
$this->style
->value
['padding']['l']+
0.03;
1526 $marge['r'] = $this->style
->value
['border']['r']['width'] +
$this->style
->value
['padding']['r']+
0.03;
1527 $marge['t'] = $this->style
->value
['border']['t']['width'] +
$this->style
->value
['padding']['t']+
0.03;
1528 $marge['b'] = $this->style
->value
['border']['b']['width'] +
$this->style
->value
['padding']['b']+
0.03;
1530 // on extrait tout ce qui est contenu dans la DIV
1531 $level = $this->parsing
->getLevel($this->parse_pos
);
1533 // on en créé un sous HTML que l'on transforme en PDF
1534 // pour analyse les dimensions
1539 $this->CreateSubHTML($sub);
1540 $sub->parsing
->code
= $level;
1541 $sub->MakeHTMLcode();
1544 $this->destroySubHTML($sub);
1549 // if (($w==0 && $this->style->value['width']==0) || ($w>$this->style->value['width']) || $this->style->value['position']=='absolute')
1550 $w+
= $marge['l']+
$marge['r']+
0.001;
1552 $h+
= $marge['t']+
$marge['b']+
0.001;
1554 if ($this->style
->value
['overflow']=='hidden')
1556 $over_w = max($w, $this->style
->value
['width']);
1557 $over_h = max($h, $this->style
->value
['height']);
1559 $this->style
->value
['old_maxX'] = $this->maxX
;
1560 $this->style
->value
['old_maxY'] = $this->maxY
;
1561 $this->style
->value
['old_maxH'] = $this->maxH
;
1562 $this->style
->value
['old_overflow'] = $this->isInOverflow
;
1563 $this->isInOverflow
= true;
1570 $this->style
->value
['width'] = max($w, $this->style
->value
['width']);
1571 $this->style
->value
['height'] = max($h, $this->style
->value
['height']);
1574 switch($this->style
->value
['rotate'])
1577 $tmp = $over_h; $over_h = $over_w; $over_w = $tmp;
1578 $tmp = $h_reel; $h_reel = $w_reel; $w_reel = $tmp;
1580 $w = $this->style
->value
['height'];
1581 $h = $this->style
->value
['width'];
1587 $w = $this->style
->value
['width'];
1588 $h = $this->style
->value
['height'];
1594 $tmp = $over_h; $over_h = $over_w; $over_w = $tmp;
1595 $tmp = $h_reel; $h_reel = $w_reel; $w_reel = $tmp;
1597 $w = $this->style
->value
['height'];
1598 $h = $this->style
->value
['width'];
1604 $w = $this->style
->value
['width'];
1605 $h = $this->style
->value
['height'];
1611 if (!$this->style
->value
['position'])
1614 $w < ($this->pdf
->getW() - $this->pdf
->getlMargin()-$this->pdf
->getrMargin()) &&
1615 $this->pdf
->getX() +
$w>=($this->pdf
->getW() - $this->pdf
->getrMargin())
1617 $this->o_BR(array());
1620 ($h < ($this->pdf
->getH() - $this->pdf
->gettMargin()-$this->pdf
->getbMargin())) &&
1621 ($this->pdf
->getY() +
$h>=($this->pdf
->getH() - $this->pdf
->getbMargin())) &&
1622 !$this->isInOverflow
1624 $this->setNewPage();
1626 // en cas d'alignement => correction
1627 $old = $this->style
->getOldValues();
1628 $parent_w = $old['width'] ?
$old['width'] : $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
1632 if ($align_object=='center') $this->pdf
->setX($this->pdf
->getX() +
($parent_w-$w)*0.5);
1633 else if ($align_object=='right') $this->pdf
->setX($this->pdf
->getX() +
$parent_w-$w);
1636 $this->style
->setPosition();
1640 // en cas d'alignement => correction
1641 $old = $this->style
->getOldValues();
1642 $parent_w = $old['width'] ?
$old['width'] : $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
1646 if ($align_object=='center') $this->pdf
->setX($this->pdf
->getX() +
($parent_w-$w)*0.5);
1647 else if ($align_object=='right') $this->pdf
->setX($this->pdf
->getX() +
$parent_w-$w);
1650 $this->style
->setPosition();
1658 if ($this->style
->value
['rotate'])
1660 $this->pdf
->startTransform();
1661 $this->pdf
->setRotation($this->style
->value
['rotate']);
1662 $this->pdf
->setTranslate($t_x, $t_y);
1665 // initialisation du style des bordures de la div
1666 $this->drawRectangle(
1667 $this->style
->value
['x'],
1668 $this->style
->value
['y'],
1669 $this->style
->value
['width'],
1670 $this->style
->value
['height'],
1671 $this->style
->value
['border'],
1672 $this->style
->value
['padding'],
1674 $this->style
->value
['background']
1678 $marge['l'] = $this->style
->value
['border']['l']['width'] +
$this->style
->value
['padding']['l']+
0.03;
1679 $marge['r'] = $this->style
->value
['border']['r']['width'] +
$this->style
->value
['padding']['r']+
0.03;
1680 $marge['t'] = $this->style
->value
['border']['t']['width'] +
$this->style
->value
['padding']['t']+
0.03;
1681 $marge['b'] = $this->style
->value
['border']['b']['width'] +
$this->style
->value
['padding']['b']+
0.03;
1683 $this->style
->value
['width'] -= $marge['l']+
$marge['r'];
1684 $this->style
->value
['height']-= $marge['t']+
$marge['b'];
1686 // positionnement en fonction des alignements
1689 if (!$this->sub_part
&& !$this->isSubPart
)
1691 switch($this->style
->value
['text-align'])
1693 case 'right': $x_corr = ($this->style
->value
['width']-$w_reel); break;
1694 case 'center': $x_corr = ($this->style
->value
['width']-$w_reel)*0.5; break;
1696 if ($x_corr>0) $x_corr=0;
1697 switch($this->style
->value
['vertical-align'])
1699 case 'bottom': $y_corr = ($this->style
->value
['height']-$h_reel); break;
1700 case 'middle': $y_corr = ($this->style
->value
['height']-$h_reel)*0.5; break;
1706 $over_w-= $marge['l']+
$marge['r'];
1707 $over_h-= $marge['t']+
$marge['b'];
1708 $this->pdf
->clippingPathOpen(
1709 $this->style
->value
['x']+
$marge['l'],
1710 $this->style
->value
['y']+
$marge['t'],
1711 $this->style
->value
['width'],
1712 $this->style
->value
['height']
1715 $this->style
->value
['x']+
= $x_corr;
1716 // limitation des marges aux dimensions du contenu
1717 $mL = $this->style
->value
['x']+
$marge['l'];
1718 $mR = $this->pdf
->getW() - $mL - $over_w;
1722 // limitation des marges aux dimensions de la div
1723 $mL = $this->style
->value
['x']+
$marge['l'];
1724 $mR = $this->pdf
->getW() - $mL - $this->style
->value
['width'];
1727 $x = $this->style
->value
['x']+
$marge['l'];
1728 $y = $this->style
->value
['y']+
$marge['t']+
$y_corr;
1729 $this->saveMargin($mL, 0, $mR);
1730 $this->pdf
->setXY($x, $y);
1732 $this->setNewPositionForNewLine();
1736 function o_BLOCKQUOTE($param) { return $this->o_DIV($param, 'blockquote'); }
1737 function o_LEGEND($param) { return $this->o_DIV($param, 'legend'); }
1742 * ecrite par Pavel Kochman
1744 * @param array paramètres de l'élément de parsing
1747 function o_FIELDSET($param)
1750 $this->style
->save();
1751 $this->style
->analyse('fieldset', $param);
1753 // get height of LEGEND element and make fieldset corrections
1754 for($temp_pos = $this->parse_pos +
1; $temp_pos<count($this->parsing
->code
); $temp_pos++
)
1756 $todo = $this->parsing
->code
[$temp_pos];
1757 if($todo['name'] == 'fieldset') break;
1758 if($todo['name'] == 'legend' && !$todo['close'])
1760 $legend_open_pos = $temp_pos;
1763 $this->CreateSubHTML($sub);
1764 $sub->parsing
->code
= $this->parsing
->getLevel($temp_pos - 1);
1766 // pour chaque element identifié par le parsing
1768 for($sub->parse_pos
= 0; $sub->parse_pos
<count($sub->parsing
->code
); $sub->parse_pos++
)
1770 $todo = $sub->parsing
->code
[$sub->parse_pos
];
1771 $sub->loadAction($todo);
1773 if ($todo['name'] == 'legend' && $todo['close'])
1777 $legendH = $sub->maxY
;
1778 $this->destroySubHTML($sub);
1780 $move = $this->style
->value
['padding']['t'] +
$this->style
->value
['border']['t']['width'] +
0.03;
1782 $param['moveTop'] = $legendH / 2;
1784 $this->parsing
->code
[$legend_open_pos]['param']['moveTop'] = - ($legendH / 2 +
$move);
1785 $this->parsing
->code
[$legend_open_pos]['param']['moveLeft'] = 2 - $this->style
->value
['border']['l']['width'] - $this->style
->value
['padding']['l'];
1786 $this->parsing
->code
[$legend_open_pos]['param']['moveDown'] = $move;
1790 $this->style
->load();
1792 return $this->o_DIV($param, 'fieldset');
1799 * @param array paramètres de l'élément de parsing
1802 function c_DIV($param, $other='div')
1804 if ($this->forOneLine
) return false;
1806 if ($this->style
->value
['overflow']=='hidden')
1808 $this->maxX
= $this->style
->value
['old_maxX'];
1809 $this->maxY
= $this->style
->value
['old_maxY'];
1810 $this->maxH
= $this->style
->value
['old_maxH'];
1811 $this->isInOverflow
= $this->style
->value
['old_overflow'];
1812 $this->pdf
->clippingPathClose();
1815 if ($this->style
->value
['rotate'])
1816 $this->pdf
->stopTransform();
1819 $marge['l'] = $this->style
->value
['border']['l']['width'] +
$this->style
->value
['padding']['l']+
0.03;
1820 $marge['r'] = $this->style
->value
['border']['r']['width'] +
$this->style
->value
['padding']['r']+
0.03;
1821 $marge['t'] = $this->style
->value
['border']['t']['width'] +
$this->style
->value
['padding']['t']+
0.03;
1822 $marge['b'] = $this->style
->value
['border']['b']['width'] +
$this->style
->value
['padding']['b']+
0.03;
1824 $x = $this->style
->value
['x'];
1825 $y = $this->style
->value
['y'];
1826 $w = $this->style
->value
['width']+
$marge['l']+
$marge['r']+
$this->style
->value
['margin']['r'];
1827 $h = $this->style
->value
['height']+
$marge['t']+
$marge['b']+
$this->style
->value
['margin']['b'];
1829 switch($this->style
->value
['rotate'])
1832 $t = $w; $w = $h; $h = $t;
1836 $t = $w; $w = $h; $h = $t;
1844 if ($this->style
->value
['position']!='absolute')
1847 $this->pdf
->setXY($x+
$w, $y);
1850 $this->maxX
= max($this->maxX
, $x+
$w);
1851 $this->maxY
= max($this->maxY
, $y+
$h);
1852 $this->maxH
= max($this->maxH
, $h);
1857 $this->pdf
->setXY($this->style
->value
['xc'], $this->style
->value
['yc']);
1862 $block = ($this->style
->value
['display']!='inline' && $this->style
->value
['position']!='absolute');
1864 $this->style
->load();
1865 $this->style
->FontSet();
1866 $this->loadMargin();
1868 if ($block) $this->o_BR(array());
1869 if ($this->DEBUG_actif
) $this->DEBUG_add(strtoupper($other), false);
1873 function c_BLOCKQUOTE($param) { return $this->c_DIV($param, 'blockquote'); }
1874 function c_FIELDSET($param) { return $this->c_DIV($param, 'fieldset'); }
1875 function c_LEGEND($param) { return $this->c_DIV($param, 'legend'); }
1881 * @param array paramètres de l'élément de parsing
1884 function o_BARCODE($param)
1886 if (!isset($param['type'])) $param['type'] = '';
1887 if (!isset($param['value'])) $param['value'] = 0;
1888 if (!isset($param['label'])) $param['label'] = 'label';
1890 if ($this->testIsDeprecated
&& (isset($param['bar_h']) ||
isset($param['bar_w'])))
1891 HTML2PDF
::makeError(9, __FILE__
, __LINE__
, array('BARCODE', 'bar_h, bar_w'));
1893 // les différents types de barcode
1894 $lst_barcode = array();
1895 $lst_barcode['EAN13'] = 'EAN13';
1896 $lst_barcode['UPCA'] = 'UPC_A';
1897 $lst_barcode['C39'] = 'CODE39';
1899 // pour compatibilité < 3.29
1900 $lst_barcode['UPC_A'] = 'UPC_A';
1901 $lst_barcode['CODE39'] = 'CODE39';
1903 $param['type'] = strtoupper($param['type']);
1904 if (!isset($lst_barcode[$param['type']])) $param['type']=='C39';
1905 $param['type'] = $lst_barcode[$param['type']];
1907 if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
1908 $param['style']['background-color'] = $param['style']['color'];
1910 $this->style
->save();
1911 $this->style
->analyse('barcode', $param);
1912 $this->style
->setPosition();
1913 $this->style
->FontSet();
1915 $x = $this->pdf
->getX();
1916 $y = $this->pdf
->getY();
1917 $w = $this->style
->value
['width']; if (!$w) $w = $this->style
->ConvertToMM('50mm');
1918 $h = $this->style
->value
['height']; if (!$h) $h = $this->style
->ConvertToMM('10mm');
1919 $txt = ($param['label']!=='none');
1920 $infos = $this->pdf
->{'BARCODE_'.$param['type']}($x, $y, $w, $h, $param['value'], $txt);
1922 // position maximale globale
1923 $this->maxX
= max($this->maxX
, $x+
$infos[0]);
1924 $this->maxY
= max($this->maxY
, $y+
$infos[1]);
1925 $this->maxH
= max($this->maxH
, $infos[1]);
1928 $this->pdf
->setXY($x+
$infos[0], $y);
1930 $this->style
->load();
1931 $this->style
->FontSet();
1940 * @param array paramètres de l'élément de parsing
1943 function c_BARCODE($param)
1945 // completement inutile
1955 * @param array paramètres de l'élément de parsing
1958 function o_QRCODE($param)
1960 if ($this->testIsDeprecated
&& (isset($param['size']) ||
isset($param['noborder'])))
1961 HTML2PDF
::makeError(9, __FILE__
, __LINE__
, array('QRCODE', 'size, noborder'));
1967 Vous devez télécharger la librairie "QR-code generator >=0.99" (sous licence LGPL)
1968 a cette adresse : <a href="http://prgm.spipu.net/php_qrcode" target="_blank">http://prgm.spipu.net/php_qrcode</a>
1969 et mettre tout son contenu dans ce repertoire : '.str_replace('\\', '/', dirname(__FILE__
)).'/qrcode
1972 You have to download the librairy "QR-code generator >=0.99" (under LGPL licence)
1973 at this url : <a href="http://prgm.spipu.net/php_qrcode" target="_blank">http://prgm.spipu.net/php_qrcode</a>
1974 and to put all his contents in this folder '.str_replace('\\', '/', dirname(__FILE__
)).'/qrcode
1977 $file_class = dirname(__FILE__
).'/qrcode/qrcode.class.php';
1978 if (!is_file($file_class)) { echo $msg; exit; }
1979 require_once($file_class);
1980 if (__CLASS_QRCODE__
<'0.99') { echo $msg; exit; }
1982 if ($this->DEBUG_actif
) $this->DEBUG_add('QRCODE', true);
1983 if (!isset($param['value'])) $param['value'] = '';
1984 if (!isset($param['ec'])) $param['ec'] = 'H';
1985 if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
1986 if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF';
1987 if (isset($param['style']['border']))
1989 $borders = $param['style']['border']!='none';
1990 unset($param['style']['border']);
1995 if ($param['value']==='') return true;
1996 if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H';
1998 $this->style
->save();
1999 $this->style
->analyse('qrcode', $param);
2000 $this->style
->setPosition();
2001 $this->style
->FontSet();
2003 $x = $this->pdf
->getX();
2004 $y = $this->pdf
->getY();
2005 $w = $this->style
->value
['width'];
2006 $h = $this->style
->value
['height'];
2007 $size = max($w, $h); if (!$size) $size = $this->style
->ConvertToMM('50mm');
2009 $color = $this->style
->value
['color'];
2010 if (count($color)==4) $color = array(0, 0, 0);
2011 $color[0] = floor($color[0]*255.);
2012 $color[1] = floor($color[1]*255.);
2013 $color[2] = floor($color[2]*255.);
2015 $background = $this->style
->value
['background']['color'];
2016 if (count($background)==4) $background = array(0, 0, 0);
2017 $background[0] = floor($background[0]*255.);
2018 $background[1] = floor($background[1]*255.);
2019 $background[2] = floor($background[2]*255.);
2021 if (!$this->sub_part
&& !$this->isSubPart
)
2023 $qrcode = new QRcode($param['value'], $param['ec']);
2024 if (!$borders) $qrcode->disableBorder();
2025 $qrcode->displayFPDF($this->pdf
, $x, $y, $size, $background, $color);
2029 // position maximale globale
2030 $this->maxX
= max($this->maxX
, $x+
$size);
2031 $this->maxY
= max($this->maxY
, $y+
$size);
2032 $this->maxH
= max($this->maxH
, $size);
2034 $this->pdf
->setX($x+
$size);
2036 $this->style
->load();
2037 $this->style
->FontSet();
2046 * @param array paramètres de l'élément de parsing
2049 function c_QRCODE($param)
2051 if ($this->DEBUG_actif
) $this->DEBUG_add('QRCODE', false);
2052 // completement inutile
2060 * @param array paramètres de l'élément de parsing
2063 function o_BOOKMARK($param)
2065 $titre = isset($param['title']) ?
trim($param['title']) : '';
2066 $level = isset($param['level']) ?
floor($param['level']) : 0;
2068 if ($level<0) $level = 0;
2069 if ($titre) $this->pdf
->Bookmark($titre, $level, -1);
2078 * @param array paramètres de l'élément de parsing
2081 function c_BOOKMARK($param)
2083 // completement inutile
2088 function getElementY($h)
2090 if ($this->sub_part ||
$this->isSubPart ||
!$this->currentH ||
$this->currentH
<$h)
2093 return ($this->currentH
-$h)*0.8;
2100 * @param array paramètres de l'élément de parsing
2103 function o_WRITE($param)
2105 $fill = ($this->style
->value
['background']['color']!==null && $this->style
->value
['background']['image']===null);
2106 if (in_array($this->style
->value
['id_balise'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th')))
2109 // récupération du texte à écrire, et conversion
2110 $txt = $param['txt'];
2112 if ($this->isAfterFloat
)
2115 $this->isAfterFloat
= false;
2118 $txt = str_replace('[[page_cu]]', $this->page
, $txt);
2120 if ($this->style
->value
['text-transform']!='none')
2122 if ($this->style
->value
['text-transform']=='capitalize')
2123 $txt = ucwords($txt);
2124 else if ($this->style
->value
['text-transform']=='uppercase')
2125 $txt = strtoupper($txt);
2126 else if ($this->style
->value
['text-transform']=='lowercase')
2127 $txt = strtolower($txt);
2131 $h = 1.08*$this->style
->value
['font-size'];
2132 $dh = $h*$this->style
->value
['mini-decal'];
2133 $lh = $this->style
->getLineHeight();
2135 // identification de l'alignement
2137 if ($this->style
->value
['text-align']=='li_right')
2139 $w = $this->style
->value
['width'];
2143 // pré calcul de la taille de chaque mot et de la phrase complete
2145 $words = explode(' ', $txt);
2146 foreach($words as $k => $word)
2148 $words[$k] = array($word, $this->pdf
->GetStringWidth($word));
2151 $space = $this->pdf
->GetStringWidth(' ');
2152 $w+
= $space*(count($words)-1);
2154 $curr_pos = 0; // position dans le texte
2155 $curr_max = strlen($txt); // taille maxi du texte
2156 $maxX = 0; // plus grande largeur du texte apres retour à la ligne
2157 $x = $this->pdf
->getX(); // position du texte
2158 $y = $this->pdf
->getY();
2159 $dy = $this->getElementY($lh);
2161 list($left, $right) = $this->getMargins($y); // marges autorisees
2162 $nb = 0; // nbr de lignes découpées
2164 // tant que ca ne rentre pas sur la ligne et qu'on a du texte => on découpe
2165 while($x+
$w>$right && $x<$right && count($words))
2167 // trouver une phrase qui rentre dans la largeur, en ajoutant les mots 1 à 1
2169 $old = array('', 0);
2172 while(($x+
$str[1])<$right)
2177 array_shift($words);
2180 if (!count($words)) break;
2181 $str[0].= ' '.$words[0][0];
2182 $str[1]+
= $space+
$words[0][1];
2186 // si rien de rentre, et que le premier mot ne rentre de toute facon pas dans une ligne, on le force...
2187 if ($i==0 && (($left+
$words[0][1])>=$right))
2190 array_shift($words);
2194 $curr_pos+
= ($curr_pos ?
1 : 0)+
strlen($str[0]);
2196 // ecriture du bout de phrase extrait et qui rentre
2197 $wc = ($align=='L' ?
$str[1] : $this->style
->value
['width']);
2198 if ($right - $left<$wc) $wc = $right - $left;
2202 $oldSpace = $this->pdf->CurrentFont['cw'][' '];
2203 $this->pdf->CurrentFont['cw'][' ']*=(1.+$this->pdf->ws);
2205 $this->pdf->CurrentFont['cw'][' '] = $oldSpace;
2208 if (strlen($str[0]))
2210 $this->pdf
->setXY($this->pdf
->getX(), $y+
$dh+
$dy);
2211 $this->pdf
->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->inLink
);
2212 $this->pdf
->setXY($this->pdf
->getX(), $y);
2214 $this->maxH
= max($this->maxH
, $lh);
2216 // détermination de la largeur max
2217 $maxX = max($maxX, $this->pdf
->getX());
2219 // nouvelle position et nouvelle largeur pour la boucle
2221 $y = $this->pdf
->getY();
2222 $x = $this->pdf
->getX();
2223 $dy = $this->getElementY($lh);
2225 // si il reste du text à afficher
2228 if ($add) $w-= $space;
2229 if ($this->forOneLine
)
2232 $this->maxX
= max($this->maxX
, $maxX);
2236 // retour à la ligne
2237 $this->o_BR(array('style' => ''), $curr_pos);
2239 $y = $this->pdf
->getY();
2240 $x = $this->pdf
->getX();
2241 $dy = $this->getElementY($lh);
2243 // si la prochaine ligne ne rentre pas dans la page => nouvelle page
2244 if ($y +
$h>=$this->pdf
->getH() - $this->pdf
->getbMargin())
2246 if (!$this->isInOverflow
&& !$this->isInFooter
)
2248 $this->setNewPage(null, '', null, $curr_pos);
2249 $y = $this->pdf
->getY();
2250 $x = $this->pdf
->getX();
2251 $dy = $this->getElementY($lh);
2255 // ligne suplémentaire. au bout de 1000 : trop long => erreur
2259 $txt = ''; foreach($words as $k => $word) $txt.= ($k ?
' ' : '').$word[0];
2260 HTML2PDF
::makeError(2, __FILE__
, __LINE__
, array($txt, $right-$left, $w));
2263 list($left, $right) = $this->getMargins($y); // marges autorisees
2267 // si il reste du text apres découpe, c'est qu'il rentre direct => on l'affiche
2270 $txt = ''; foreach($words as $k => $word) $txt.= ($k ?
' ' : '').$word[0];
2274 $oldSpace = $this->pdf->CurrentFont['cw'][' '];
2275 $this->pdf->CurrentFont['cw'][' ']*=(1.+$this->pdf->ws);
2276 $w = $this->pdf->GetStringWidth($txt);
2277 $this->pdf->CurrentFont['cw'][' '] = $oldSpace;
2280 $this->pdf
->setXY($this->pdf
->getX(), $y+
$dh+
$dy);
2281 $this->pdf
->Cell(($align=='L' ?
$w : $this->style
->value
['width']), $h, $txt, 0, 0, $align, $fill, $this->inLink
);
2282 $this->pdf
->setXY($this->pdf
->getX(), $y);
2283 $this->maxH
= max($this->maxH
, $lh);
2284 $this->maxE+
= count($words);
2287 // détermination des positions MAX
2288 $maxX = max($maxX, $this->pdf
->getX());
2289 $maxY = $this->pdf
->getY()+
$h;
2291 // position maximale globale
2292 $this->maxX
= max($this->maxX
, $maxX);
2293 $this->maxY
= max($this->maxY
, $maxY);
2301 * @param string nom du fichier source
2304 function Image($src, $sub_li=false)
2306 // est-ce que c'est une image ?
2307 $infos=@GetImageSize
($src);
2309 if (count($infos)<2)
2311 if ($this->testIsImage
)
2313 HTML2PDF
::makeError(6, __FILE__
, __LINE__
, $src);
2317 $infos = array(16, 16);
2320 // récupération des dimensions dans l'unité du PDF
2321 $wi = $infos[0]/$this->pdf
->getK();
2322 $hi = $infos[1]/$this->pdf
->getK();
2324 // détermination des dimensions d'affichage en fonction du style
2325 if ($this->style
->value
['width'] && $this->style
->value
['height'])
2327 $w = $this->style
->value
['width'];
2328 $h = $this->style
->value
['height'];
2330 else if ($this->style
->value
['width'])
2332 $w = $this->style
->value
['width'];
2336 else if ($this->style
->value
['height'])
2338 $h = $this->style
->value
['height'];
2347 // detection du float
2348 $float = $this->style
->getFloat();
2349 if ($float && $this->maxH
)
2350 if (!$this->o_BR(array()))
2353 // position d'affichage
2354 $x = $this->pdf
->getX();
2355 $y = $this->pdf
->getY();
2357 // si l'image ne rentre pas dans la ligne => nouvelle ligne
2358 if (!$float && ($x +
$w>$this->pdf
->getW() - $this->pdf
->getrMargin()) && $this->maxH
)
2360 if ($this->forOneLine
) return null;
2362 $hnl = max($this->maxH
, $this->style
->getLineHeight());
2363 $this->setNewLine($hnl);
2364 $x = $this->pdf
->getX();
2365 $y = $this->pdf
->getY();
2368 // si l'image ne rentre pas dans la page => nouvelle page
2370 ($y +
$h>$this->pdf
->getH() - $this->pdf
->getbMargin()) &&
2371 !$this->isInOverflow
2374 $this->setNewPage();
2375 $x = $this->pdf
->getX();
2376 $y = $this->pdf
->getY();
2379 // correction pour l'affichage d'une puce image
2380 $hT = 0.80*$this->style
->value
['font-size'];
2381 if ($sub_li && $h<$hT)
2386 $yc = $y-$this->style
->value
['margin']['t'];
2388 // détermination de la position réelle d'affichage en fonction du text-align du parent
2389 $old = $this->style
->getOldValues();
2393 $parent_w = $old['width'];
2398 $parent_w = $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
2399 $parent_x = $this->pdf
->getlMargin();
2404 list($lx, $rx) = $this->getMargins($yc);
2406 $parent_w = $rx-$lx;
2409 if ($parent_w>$w && $float!='left')
2411 if ($float=='right' ||
$this->style
->value
['text-align']=='li_right') $x = $parent_x +
$parent_w - $w-$this->style
->value
['margin']['r']-$this->style
->value
['margin']['l'];
2414 // affichage de l'image, et positionnement à la suite
2415 if (!$this->sub_part
&& !$this->isSubPart
)
2417 if ($src) $this->pdf
->Image($src, $x, $y, $w, $h, '', $this->inLink
);
2420 $this->pdf
->setMyFillColor(array(0.94, 0.86, 0.86));
2421 $this->pdf
->Rect($x, $y, $w, $h, 'F');
2425 $x-= $this->style
->value
['margin']['l'];
2426 $y-= $this->style
->value
['margin']['t'];
2427 $w+
= $this->style
->value
['margin']['l'] +
$this->style
->value
['margin']['r'];
2428 $h+
= $this->style
->value
['margin']['t'] +
$this->style
->value
['margin']['b'];
2432 $this->maxX
= max($this->maxX
, $x+
$w);
2433 $this->maxY
= max($this->maxY
, $y+
$h);
2435 $this->addMargins($float, $x, $y, $x+
$w, $y+
$h);
2437 list($lx, $rx) = $this->getMargins($yc);
2438 $this->pdf
->setXY($lx, $yc);
2440 else if ($float=='right')
2442 // $this->maxX = max($this->maxX, $x+$w);
2443 $this->maxY
= max($this->maxY
, $y+
$h);
2445 $this->addMargins($float, $x, $y, $x+
$w, $y+
$h);
2447 list($lx, $rx) = $this->getMargins($yc);
2448 $this->pdf
->setXY($lx, $yc);
2452 $this->pdf
->setX($x+
$w);
2453 $this->maxX
= max($this->maxX
, $x+
$w);
2454 $this->maxY
= max($this->maxY
, $y+
$h);
2455 $this->maxH
= max($this->maxH
, $h);
2461 * Tracer un rectanble
2463 * @param float position X
2464 * @param float position Y
2465 * @param float Largeur
2466 * @param float Hauteur
2467 * @param array Tableau de style de définition des borders
2468 * @param float padding - marge intérieur au rectangle => non utile mais on le passe en paramètre
2469 * @param float margin - marge exterieur au rectangle
2470 * @param array Tableau de style de définition du background
2473 function drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
2475 if ($this->sub_part ||
$this->isSubPart
) return false;
2476 if ($h===null) return false;
2483 // récupération des radius
2484 $out_TL = $border['radius']['tl'];
2485 $out_TR = $border['radius']['tr'];
2486 $out_BR = $border['radius']['br'];
2487 $out_BL = $border['radius']['bl'];
2489 // verification des coins en radius
2490 $out_TL = ($out_TL[0] && $out_TL[1]) ?
$out_TL : null;
2491 $out_TR = ($out_TR[0] && $out_TR[1]) ?
$out_TR : null;
2492 $out_BR = ($out_BR[0] && $out_BR[1]) ?
$out_BR : null;
2493 $out_BL = ($out_BL[0] && $out_BL[1]) ?
$out_BL : null;
2501 if (is_array($in_TL)) { $in_TL[0]-= $border['l']['width']; $in_TL[1]-= $border['t']['width']; }
2502 if (is_array($in_TR)) { $in_TR[0]-= $border['r']['width']; $in_TR[1]-= $border['t']['width']; }
2503 if (is_array($in_BR)) { $in_BR[0]-= $border['r']['width']; $in_BR[1]-= $border['b']['width']; }
2504 if (is_array($in_BL)) { $in_BL[0]-= $border['l']['width']; $in_BL[1]-= $border['b']['width']; }
2506 if ($in_TL[0]<=0 ||
$in_TL[1]<=0) $in_TL = null;
2507 if ($in_TR[0]<=0 ||
$in_TR[1]<=0) $in_TR = null;
2508 if ($in_BR[0]<=0 ||
$in_BR[1]<=0) $in_BR = null;
2509 if ($in_BL[0]<=0 ||
$in_BL[1]<=0) $in_BL = null;
2511 // traitement de la couleur de fond
2513 if ($background['color'])
2515 $this->pdf
->setMyFillColor($background['color']);
2521 $this->pdf
->clippingPathOpen($x, $y, $w, $h, $out_TL,$out_TR, $out_BL, $out_BR);
2522 $this->pdf
->Rect($x, $y, $w, $h, $STYLE);
2523 $this->pdf
->clippingPathClose();
2526 // traitement de l'image de fond
2527 if ($background['image'])
2529 $i_name = $background['image'];
2530 $i_position = $background['position']!==null ?
$background['position'] : array(0, 0);
2531 $i_repeat = $background['repeat']!==null ?
$background['repeat'] : array(true, true);
2533 // taile du fond (il faut retirer les borders
2539 if ($border['b']['width']) { $b_h-= $border['b']['width']; }
2540 if ($border['l']['width']) { $b_w-= $border['l']['width']; $b_x+
= $border['l']['width']; }
2541 if ($border['t']['width']) { $b_h-= $border['t']['width']; $b_y+
= $border['t']['width']; }
2542 if ($border['r']['width']) { $b_w-= $border['r']['width']; }
2544 // est-ce que c'est une image ?
2545 $i_infos=@GetImageSize
($i_name);
2547 if (count($i_infos)<2)
2549 if ($this->testIsImage
)
2551 HTML2PDF
::makeError(6, __FILE__
, __LINE__
, $i_name);
2557 // récupération des dimensions dans l'unité du PDF
2558 $i_width = 72./96.*$i_infos[0]/$this->pdf
->getK();
2559 $i_height = 72./96.*$i_infos[1]/$this->pdf
->getK();
2561 if ($i_repeat[0]) $i_position[0] = $b_x;
2562 else if(preg_match('/^([-]?[0-9\.]+)%/isU', $i_position[0], $match)) $i_position[0] = $b_x +
$match[1]*($b_w-$i_width)/100;
2563 else $i_position[0] = $b_x+
$i_position[0];
2565 if ($i_repeat[1]) $i_position[1] = $b_y;
2566 else if(preg_match('/^([-]?[0-9\.]+)%/isU', $i_position[1], $match)) $i_position[1] = $b_y +
$match[1]*($b_h-$i_height)/100;
2567 else $i_position[1] = $b_y+
$i_position[1];
2570 $i_x_max = $b_x+
$b_w;
2572 $i_y_max = $b_y+
$b_h;
2574 if (!$i_repeat[0] && !$i_repeat[1])
2576 $i_x_min = $i_position[0]; $i_x_max = $i_position[0]+
$i_width;
2577 $i_y_min = $i_position[1]; $i_y_max = $i_position[1]+
$i_height;
2579 else if ($i_repeat[0] && !$i_repeat[1])
2581 $i_y_min = $i_position[1]; $i_y_max = $i_position[1]+
$i_height;
2583 elseif (!$i_repeat[0] && $i_repeat[1])
2585 $i_x_min = $i_position[0]; $i_x_max = $i_position[0]+
$i_width;
2588 $this->pdf
->clippingPathOpen($b_x, $b_y, $b_w, $b_h, $in_TL, $in_TR, $in_BL, $in_BR);
2589 for ($i_y=$i_y_min; $i_y<$i_y_max; $i_y+
=$i_height)
2591 for ($i_x=$i_x_min; $i_x<$i_x_max; $i_x+
=$i_width)
2597 if ($i_y_max-$i_y<$i_height)
2601 $c_h = $i_y_max-$i_y;
2603 if ($i_x_max-$i_x<$i_width)
2607 $c_w = $i_x_max-$i_x;
2610 $this->pdf
->Image($i_name, $i_x, $i_y, $i_width, $i_height, '', '');
2613 $this->pdf
->clippingPathClose();
2621 if ($border['l']['width']) $border['l']['width']+
= 0.02;
2622 if ($border['t']['width']) $border['t']['width']+
= 0.02;
2623 if ($border['r']['width']) $border['r']['width']+
= 0.02;
2624 if ($border['b']['width']) $border['b']['width']+
= 0.02;
2626 $Bl = ($border['l']['width'] && $border['l']['color'][0]!==null);
2627 $Bt = ($border['t']['width'] && $border['t']['color'][0]!==null);
2628 $Br = ($border['r']['width'] && $border['r']['color'][0]!==null);
2629 $Bb = ($border['b']['width'] && $border['b']['color'][0]!==null);
2631 if (is_array($out_BL) && ($Bb ||
$Bl))
2636 $courbe[] = $x+
$out_BL[0]; $courbe[] = $y+
$h;
2637 $courbe[] = $x; $courbe[] = $y+
$h-$out_BL[1];
2638 $courbe[] = $x+
$out_BL[0]; $courbe[] = $y+
$h-$border['b']['width'];
2639 $courbe[] = $x+
$border['l']['width']; $courbe[] = $y+
$h-$out_BL[1];
2640 $courbe[] = $x+
$out_BL[0]; $courbe[] = $y+
$h-$out_BL[1];
2645 $courbe[] = $x+
$out_BL[0]; $courbe[] = $y+
$h;
2646 $courbe[] = $x; $courbe[] = $y+
$h-$out_BL[1];
2647 $courbe[] = $x+
$border['l']['width']; $courbe[] = $y+
$h-$border['b']['width'];
2648 $courbe[] = $x+
$out_BL[0]; $courbe[] = $y+
$h-$out_BL[1];
2650 $this->drawCourbe($courbe, $border['l']['color']);
2654 if (is_array($out_TL) && ($Bt ||
$Bl))
2659 $courbe[] = $x; $courbe[] = $y+
$out_TL[1];
2660 $courbe[] = $x+
$out_TL[0]; $courbe[] = $y;
2661 $courbe[] = $x+
$border['l']['width']; $courbe[] = $y+
$out_TL[1];
2662 $courbe[] = $x+
$out_TL[0]; $courbe[] = $y+
$border['t']['width'];
2663 $courbe[] = $x+
$out_TL[0]; $courbe[] = $y+
$out_TL[1];
2668 $courbe[] = $x; $courbe[] = $y+
$out_TL[1];
2669 $courbe[] = $x+
$out_TL[0]; $courbe[] = $y;
2670 $courbe[] = $x+
$border['l']['width']; $courbe[] = $y+
$border['t']['width'];
2671 $courbe[] = $x+
$out_TL[0]; $courbe[] = $y+
$out_TL[1];
2673 $this->drawCourbe($courbe, $border['t']['color']);
2676 if (is_array($out_TR) && ($Bt ||
$Br))
2681 $courbe[] = $x+
$w-$out_TR[0]; $courbe[] = $y;
2682 $courbe[] = $x+
$w; $courbe[] = $y+
$out_TR[1];
2683 $courbe[] = $x+
$w-$out_TR[0]; $courbe[] = $y+
$border['t']['width'];
2684 $courbe[] = $x+
$w-$border['r']['width']; $courbe[] = $y+
$out_TR[1];
2685 $courbe[] = $x+
$w-$out_TR[0]; $courbe[] = $y+
$out_TR[1];
2690 $courbe[] = $x+
$w-$out_TR[0]; $courbe[] = $y;
2691 $courbe[] = $x+
$w; $courbe[] = $y+
$out_TR[1];
2692 $courbe[] = $x+
$w-$border['r']['width']; $courbe[] = $y+
$border['t']['width'];
2693 $courbe[] = $x+
$w-$out_TR[0]; $courbe[] = $y+
$out_TR[1];
2695 $this->drawCourbe($courbe, $border['r']['color']);
2698 if (is_array($out_BR) && ($Bb ||
$Br))
2703 $courbe[] = $x+
$w; $courbe[] = $y+
$h-$out_BR[1];
2704 $courbe[] = $x+
$w-$out_BR[0]; $courbe[] = $y+
$h;
2705 $courbe[] = $x+
$w-$border['r']['width']; $courbe[] = $y+
$h-$out_BR[1];
2706 $courbe[] = $x+
$w-$out_BR[0]; $courbe[] = $y+
$h-$border['b']['width'];
2707 $courbe[] = $x+
$w-$out_BR[0]; $courbe[] = $y+
$h-$out_BR[1];
2712 $courbe[] = $x+
$w; $courbe[] = $y+
$h-$out_BR[1];
2713 $courbe[] = $x+
$w-$out_BR[0]; $courbe[] = $y+
$h;
2714 $courbe[] = $x+
$w-$border['r']['width']; $courbe[] = $y+
$h-$border['b']['width'];
2715 $courbe[] = $x+
$w-$out_BR[0]; $courbe[] = $y+
$h-$out_BR[1];
2717 $this->drawCourbe($courbe, $border['b']['color']);
2723 $pt[] = $x; $pt[] = $y+
$h;
2724 $pt[] = $x; $pt[] = $y+
$h-$border['b']['width'];
2725 $pt[] = $x; $pt[] = $y+
$border['t']['width'];
2726 $pt[] = $x; $pt[] = $y;
2727 $pt[] = $x+
$border['l']['width']; $pt[] = $y+
$border['t']['width'];
2728 $pt[] = $x+
$border['l']['width']; $pt[] = $y+
$h-$border['b']['width'];
2731 if (is_array($out_BL))
2734 $pt[3] -= $out_BL[1] - $border['b']['width'];
2735 if ($in_BL) $pt[11]-= $in_BL[1];
2736 unset($pt[0]);unset($pt[1]);
2738 if (is_array($out_TL))
2741 $pt[5] +
= $out_TL[1]-$border['t']['width'];
2742 if ($in_TL) $pt[9] +
= $in_TL[1];
2743 unset($pt[6]);unset($pt[7]);
2746 $pt = array_values($pt);
2747 $this->drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord);
2753 $pt[] = $x; $pt[] = $y;
2754 $pt[] = $x+
$border['l']['width']; $pt[] = $y;
2755 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y;
2756 $pt[] = $x+
$w; $pt[] = $y;
2757 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y+
$border['t']['width'];
2758 $pt[] = $x+
$border['l']['width']; $pt[] = $y+
$border['t']['width'];
2761 if (is_array($out_TL))
2764 $pt[2] +
= $out_TL[0] - $border['l']['width'];
2765 if ($in_TL) $pt[10]+
= $in_TL[0];
2766 unset($pt[0]);unset($pt[1]);
2768 if (is_array($out_TR))
2771 $pt[4] -= $out_TR[0] - $border['r']['width'];
2772 if ($in_TR) $pt[8] -= $in_TR[0];
2773 unset($pt[6]);unset($pt[7]);
2776 $pt = array_values($pt);
2777 $this->drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord);
2783 $pt[] = $x+
$w; $pt[] = $y;
2784 $pt[] = $x+
$w; $pt[] = $y+
$border['t']['width'];
2785 $pt[] = $x+
$w; $pt[] = $y+
$h-$border['b']['width'];
2786 $pt[] = $x+
$w; $pt[] = $y+
$h;
2787 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y+
$h-$border['b']['width'];
2788 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y+
$border['t']['width'];
2791 if (is_array($out_TR))
2794 $pt[3] +
= $out_TR[1] - $border['t']['width'];
2795 if ($in_TR) $pt[11]+
= $in_TR[1];
2796 unset($pt[0]);unset($pt[1]);
2798 if (is_array($out_BR))
2801 $pt[5] -= $out_BR[1] - $border['b']['width'];
2802 if ($in_BR) $pt[9] -= $in_BR[1];
2803 unset($pt[6]);unset($pt[7]);
2806 $pt = array_values($pt);
2807 $this->drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord);
2813 $pt[] = $x+
$w; $pt[] = $y+
$h;
2814 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y+
$h;
2815 $pt[] = $x+
$border['l']['width']; $pt[] = $y+
$h;
2816 $pt[] = $x; $pt[] = $y+
$h;
2817 $pt[] = $x+
$border['l']['width']; $pt[] = $y+
$h-$border['b']['width'];
2818 $pt[] = $x+
$w-$border['r']['width']; $pt[] = $y+
$h-$border['b']['width'];
2821 if (is_array($out_BL))
2824 $pt[4] +
= $out_BL[0] - $border['l']['width'];
2825 if ($in_BL) $pt[8] +
= $in_BL[0];
2826 unset($pt[6]);unset($pt[7]);
2828 if (is_array($out_BR))
2831 $pt[2] -= $out_BR[0] - $border['r']['width'];
2832 if ($in_BR) $pt[10]-= $in_BR[0];
2833 unset($pt[0]);unset($pt[1]);
2837 $pt = array_values($pt);
2838 $this->drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord);
2841 if ($background['color'])
2843 $this->pdf
->setMyFillColor($background['color']);
2847 function drawCourbe($pt, $color)
2849 $this->pdf
->setMyFillColor($color);
2852 $this->pdf
->drawCourbe($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
2854 $this->pdf
->drawCoin($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
2858 * Tracer une ligne epaisse défini par ses points avec des extreminites en biseau
2860 * @param array liste des points definissant le tour de la ligne
2861 * @param float couleur RVB
2862 * @param string type de ligne
2863 * @param float largeur de la ligne
2866 function drawLine($pt, $color, $type, $width, $bord=3)
2868 $this->pdf
->setMyFillColor($color);
2869 if ($type=='dashed' ||
$type=='dotted')
2873 $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
2874 $this->pdf
->Polygon($tmp, 'F');
2876 $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
2881 $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7];
2882 $this->pdf
->Polygon($tmp, 'F');
2884 $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
2889 $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
2890 $this->pdf
->Polygon($tmp, 'F');
2892 $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
2893 $this->pdf
->Polygon($tmp, 'F');
2895 $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
2901 $l = abs(($pt[3]-$pt[1])*0.5);
2904 $x1 = $pt[0]; $y1 = ($pt[3]+
$pt[1])*0.5;
2905 $x2 = $pt[6]; $y2 = ($pt[7]+
$pt[5])*0.5;
2909 $l = abs(($pt[2]-$pt[0])*0.5);
2912 $x1 = ($pt[2]+
$pt[0])*0.5; $y1 = $pt[1];
2913 $x2 = ($pt[6]+
$pt[4])*0.5; $y2 = $pt[7];
2915 if ($type=='dashed')
2920 $mode = ($l/($px+
$py)<.5);
2922 for($i=0; $l-($px+
$py)*($i-0.5)>0; $i++
)
2927 $lx1 = $px*($j); if ($lx1<-$l) $lx1 =-$l;
2928 $ly1 = $py*($j); if ($ly1<-$l) $ly1 =-$l;
2929 $lx2 = $px*($j+
1); if ($lx2>$l) $lx2 = $l;
2930 $ly2 = $py*($j+
1); if ($ly2>$l) $ly2 = $l;
2933 $tmp[] = $x1+
$lx1; $tmp[] = $y1+
$ly1;
2934 $tmp[] = $x1+
$lx2; $tmp[] = $y1+
$ly2;
2935 $tmp[] = $x2+
$lx2; $tmp[] = $y2+
$ly2;
2936 $tmp[] = $x2+
$lx1; $tmp[] = $y2+
$ly1;
2937 $this->pdf
->Polygon($tmp, 'F');
2942 $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1;
2943 $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2;
2944 $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2;
2945 $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1;
2946 $this->pdf
->Polygon($tmp, 'F');
2951 else if ($type=='double')
2958 $pt1[0] = ($pt[0]-$pt[10])*0.33 +
$pt[10];
2959 $pt1[1] = ($pt[1]-$pt[11])*0.33 +
$pt[11];
2960 $pt1[2] = ($pt[2]-$pt[10])*0.33 +
$pt[10];
2961 $pt1[3] = ($pt[3]-$pt[11])*0.33 +
$pt[11];
2962 $pt1[4] = ($pt[4]-$pt[8])*0.33 +
$pt[8];
2963 $pt1[5] = ($pt[5]-$pt[9])*0.33 +
$pt[9];
2964 $pt1[6] = ($pt[6]-$pt[8])*0.33 +
$pt[8];
2965 $pt1[7] = ($pt[7]-$pt[9])*0.33 +
$pt[9];
2966 $pt2[10]= ($pt[10]-$pt[0])*0.33 +
$pt[0];
2967 $pt2[11]= ($pt[11]-$pt[1])*0.33 +
$pt[1];
2968 $pt2[2] = ($pt[2] -$pt[0])*0.33 +
$pt[0];
2969 $pt2[3] = ($pt[3] -$pt[1])*0.33 +
$pt[1];
2970 $pt2[4] = ($pt[4] -$pt[6])*0.33 +
$pt[6];
2971 $pt2[5] = ($pt[5] -$pt[7])*0.33 +
$pt[7];
2972 $pt2[8] = ($pt[8] -$pt[6])*0.33 +
$pt[6];
2973 $pt2[9] = ($pt[9] -$pt[7])*0.33 +
$pt[7];
2977 $pt1[0] = ($pt[0]-$pt[6])*0.33 +
$pt[6];
2978 $pt1[1] = ($pt[1]-$pt[7])*0.33 +
$pt[7];
2979 $pt1[2] = ($pt[2]-$pt[4])*0.33 +
$pt[4];
2980 $pt1[3] = ($pt[3]-$pt[5])*0.33 +
$pt[5];
2981 $pt2[6] = ($pt[6]-$pt[0])*0.33 +
$pt[0];
2982 $pt2[7] = ($pt[7]-$pt[1])*0.33 +
$pt[1];
2983 $pt2[4] = ($pt[4]-$pt[2])*0.33 +
$pt[2];
2984 $pt2[5] = ($pt[5]-$pt[3])*0.33 +
$pt[3];
2986 $this->pdf
->Polygon($pt1, 'F');
2987 $this->pdf
->Polygon($pt2, 'F');
2989 else if ($type=='solid')
2991 $this->pdf
->Polygon($pt, 'F');
2999 * @param array paramètres de l'élément de parsing
3000 * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
3003 function o_BR($param, $curr = null)
3005 if ($this->forOneLine
) return false;
3007 $h = max($this->maxH
, $this->style
->getLineHeight());
3009 // si la ligne est vide, la position maximale n'a pas été mise à jour => on la met à jour
3010 if ($this->maxH
==0) $this->maxY
= max($this->maxY
, $this->pdf
->getY()+
$h);
3012 $this->makeBR($h, $curr);
3019 function makeBR($h, $curr = null)
3021 // si le saut de ligne rentre => on le prend en compte, sinon nouvelle page
3024 if (($this->pdf
->getY()+
$h<$this->pdf
->getH() - $this->pdf
->getbMargin()) ||
$this->isInOverflow ||
$this->isInFooter
)
3025 $this->setNewLine($h, $curr);
3027 $this->setNewPage(null, '', null, $curr);
3031 $this->setNewPositionForNewLine($curr);
3041 * @param array paramètres de l'élément de parsing
3044 function o_HR($param)
3046 if ($this->forOneLine
) return false;
3047 $old_align = $this->style
->value
['text-align'];
3048 $this->style
->value
['text-align'] = 'left';
3050 if ($this->maxH
) $this->o_BR($param);
3052 $f_size = $this->style
->value
['font-size'];
3053 $this->style
->value
['font-size']=$f_size*0.5; $this->o_BR($param);
3054 $this->style
->value
['font-size']=0;
3056 $param['style']['width'] = '100%';
3058 $this->style
->save();
3059 $this->style
->value
['height']=$this->style
->ConvertToMM('1mm');
3061 $this->style
->analyse('hr', $param);
3062 $this->style
->setPosition();
3063 $this->style
->FontSet();
3065 $h = $this->style
->value
['height'];
3066 if ($h) $h-= $this->style
->value
['border']['t']['width']+
$this->style
->value
['border']['b']['width'];
3067 if ($h<=0) $h = $this->style
->value
['border']['t']['width']+
$this->style
->value
['border']['b']['width'];
3069 $this->drawRectangle($this->pdf
->getX(), $this->pdf
->getY(), $this->style
->value
['width'], $h, $this->style
->value
['border'], 0, 0, $this->style
->value
['background']);
3072 $this->style
->load();
3073 $this->style
->FontSet();
3075 $this->o_BR($param);
3077 $this->style
->value
['font-size']=$f_size*0.5; $this->o_BR($param);
3078 $this->style
->value
['font-size']=$f_size;
3080 $this->style
->value
['text-align'] = $old_align;
3081 $this->setNewPositionForNewLine();
3090 * @param array paramètres de l'élément de parsing
3093 function o_B($param, $other = 'b')
3095 $this->style
->save();
3096 $this->style
->value
['font-bold'] = true;
3097 $this->style
->analyse($other, $param);
3098 $this->style
->setPosition();
3099 $this->style
->FontSet();
3103 function o_STRONG($param) { return $this->o_B($param, 'strong'); }
3109 * @param array paramètres de l'élément de parsing
3112 function c_B($param)
3114 $this->style
->load();
3115 $this->style
->FontSet();
3119 function c_STRONG($param) { return $this->c_B($param); }
3125 * @param array paramètres de l'élément de parsing
3128 function o_I($param, $other = 'i')
3130 $this->style
->save();
3131 $this->style
->value
['font-italic'] = true;
3132 $this->style
->analyse($other, $param);
3133 $this->style
->setPosition();
3134 $this->style
->FontSet();
3138 function o_ADDRESS($param) { return $this->o_I($param, 'address'); }
3139 function o_CITE($param) { return $this->o_I($param, 'cite'); }
3140 function o_EM($param) { return $this->o_I($param, 'em'); }
3141 function o_SAMP($param) { return $this->o_I($param, 'samp'); }
3147 * @param array paramètres de l'élément de parsing
3150 function c_I($param)
3152 $this->style
->load();
3153 $this->style
->FontSet();
3157 function c_ADDRESS($param) { return $this->c_I($param); }
3158 function c_CITE($param) { return $this->c_I($param); }
3159 function c_EM($param) { return $this->c_I($param); }
3160 function c_SAMP($param) { return $this->c_I($param); }
3166 * @param array paramètres de l'élément de parsing
3169 function o_S($param, $other = 's')
3171 $this->style
->save();
3172 $this->style
->value
['font-linethrough'] = true;
3173 $this->style
->analyse($other, $param);
3174 $this->style
->setPosition();
3175 $this->style
->FontSet();
3179 function o_DEL($param) { return $this->o_S($param, 'del'); }
3185 * @param array paramètres de l'élément de parsing
3188 function c_S($param)
3190 $this->style
->load();
3191 $this->style
->FontSet();
3195 function c_DEL($param) { return $this->c_S($param); }
3201 * @param array paramètres de l'élément de parsing
3204 function o_U($param, $other='u')
3206 $this->style
->save();
3207 $this->style
->value
['font-underline'] = true;
3208 $this->style
->analyse($other, $param);
3209 $this->style
->setPosition();
3210 $this->style
->FontSet();
3214 function o_INS($param) { return $this->o_U($param, 'ins'); }
3220 * @param array paramètres de l'élément de parsing
3223 function c_U($param)
3225 $this->style
->load();
3226 $this->style
->FontSet();
3230 function c_INS($param) { return $this->c_U($param); }
3236 * @param array paramètres de l'élément de parsing
3239 function o_A($param)
3241 $this->inLink
= str_replace('&', '&', isset($param['href']) ?
$param['href'] : '');
3243 if (isset($param['name']))
3245 $nom = $param['name'];
3246 if (!isset($this->lstAncre
[$nom])) $this->lstAncre
[$nom] = array($this->pdf
->AddLink(), false);
3248 if (!$this->lstAncre
[$nom][1])
3250 $this->lstAncre
[$nom][1] = true;
3251 $this->pdf
->SetLink($this->lstAncre
[$nom][0], -1, -1);
3255 if (preg_match('/^#([^#]+)$/isU', $this->inLink
, $match))
3258 if (!isset($this->lstAncre
[$nom])) $this->lstAncre
[$nom] = array($this->pdf
->AddLink(), false);
3260 $this->inLink
= $this->lstAncre
[$nom][0];
3263 $this->style
->save();
3264 $this->style
->value
['font-underline'] = true;
3265 $this->style
->value
['color'] = array(0.08, 0.08, 0.98);
3266 $this->style
->analyse('a', $param);
3267 $this->style
->setPosition();
3268 $this->style
->FontSet();
3277 * @param array paramètres de l'élément de parsing
3280 function c_A($param)
3283 $this->style
->load();
3284 $this->style
->FontSet();
3293 * @param array paramètres de l'élément de parsing
3296 function o_H1($param, $other = 'h1')
3298 if ($this->forOneLine
) return false;
3300 if ($this->maxH
) $this->o_BR(array());
3301 $this->style
->save();
3302 $this->style
->value
['font-bold'] = true;
3304 $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px');
3305 $this->style
->value
['margin']['l'] = 0;
3306 $this->style
->value
['margin']['r'] = 0;
3307 $this->style
->value
['margin']['t'] = $this->style
->ConvertToMM('16px');
3308 $this->style
->value
['margin']['b'] = $this->style
->ConvertToMM('16px');
3309 $this->style
->value
['font-size'] = $this->style
->ConvertToMM($size[$other]);
3311 $this->style
->analyse($other, $param);
3312 $this->style
->setPosition();
3313 $this->style
->FontSet();
3314 $this->setNewPositionForNewLine();
3318 function o_H2($param) { return $this->o_H1($param, 'h2'); }
3319 function o_H3($param) { return $this->o_H1($param, 'h3'); }
3320 function o_H4($param) { return $this->o_H1($param, 'h4'); }
3321 function o_H5($param) { return $this->o_H1($param, 'h5'); }
3322 function o_H6($param) { return $this->o_H1($param, 'h6'); }
3329 * @param array paramètres de l'élément de parsing
3332 function c_H1($param)
3334 if ($this->forOneLine
) return false;
3337 $this->maxH+
= $this->style
->value
['margin']['b'];
3338 $h = max($this->maxH
, $this->style
->getLineHeight());
3340 $this->style
->load();
3341 $this->style
->FontSet();
3343 // saut de ligne et initialisation de la hauteur
3349 function c_H2($param) { return $this->c_H1($param); }
3350 function c_H3($param) { return $this->c_H1($param); }
3351 function c_H4($param) { return $this->c_H1($param); }
3352 function c_H5($param) { return $this->c_H1($param); }
3353 function c_H6($param) { return $this->c_H1($param); }
3359 * @param array paramètres de l'élément de parsing
3362 function o_SPAN($param, $other = 'span')
3364 $this->style
->save();
3365 $this->style
->analyse($other, $param);
3366 $this->style
->setPosition();
3367 $this->style
->FontSet();
3371 function o_FONT($param) { return $this->o_SPAN($param, 'font'); }
3372 function o_LABEL($param) { return $this->o_SPAN($param, 'label');}
3378 * @param array paramètres de l'élément de parsing
3381 function c_SPAN($param)
3383 $this->style
->restorePosition();
3384 $this->style
->load();
3385 $this->style
->FontSet();
3389 function c_FONT($param) { return $this->c_SPAN($param); }
3390 function c_LABEL($param) { return $this->c_SPAN($param); }
3397 * @param array paramètres de l'élément de parsing
3400 function o_P($param)
3402 if ($this->forOneLine
) return false;
3404 if (!in_array($this->previousCall
, array('c_P', 'c_UL')))
3406 if ($this->maxH
) $this->o_BR(array());
3409 $this->style
->save();
3410 $this->style
->analyse('p', $param);
3411 $this->style
->setPosition();
3412 $this->style
->FontSet();
3413 // annule les effets du setposition
3414 $this->pdf
->setXY($this->pdf
->getX()-$this->style
->value
['margin']['l'], $this->pdf
->getY()-$this->style
->value
['margin']['t']);
3416 list($mL, $mR) = $this->getMargins($this->pdf
->getY());
3417 $mR = $this->pdf
->getW()-$mR;
3418 $mL+
= $this->style
->value
['margin']['l']+
$this->style
->value
['padding']['l'];
3419 $mR+
= $this->style
->value
['margin']['r']+
$this->style
->value
['padding']['r'];
3420 $this->saveMargin($mL,0,$mR);
3422 if ($this->style
->value
['text-indent']>0)
3424 $y = $this->pdf
->getY()+
$this->style
->value
['margin']['t']+
$this->style
->value
['padding']['t'];
3425 $this->pageMarges
[floor($y*100)] = array($mL+
$this->style
->value
['text-indent'], $this->pdf
->getW()-$mR);
3426 $y+
= $this->style
->getLineHeight()*0.1;
3427 $this->pageMarges
[floor($y*100)] = array($mL, $this->pdf
->getW()-$mR);
3429 $this->makeBR($this->style
->value
['margin']['t']+
$this->style
->value
['padding']['t']);
3437 * @param array paramètres de l'élément de parsing
3440 function c_P($param)
3442 if ($this->forOneLine
) return false;
3444 if ($this->maxH
) $this->o_BR(array());
3445 $this->loadMargin();
3446 $h = $this->style
->value
['margin']['b']+
$this->style
->value
['padding']['b'];
3448 $this->style
->load();
3449 $this->style
->FontSet();
3459 * @param array paramètres de l'élément de parsing
3462 function o_PRE($param, $other = 'pre')
3464 if ($other=='pre' && $this->maxH
) $this->o_BR(array());
3466 $this->style
->save();
3467 $this->style
->value
['font-family'] = 'courier';
3468 $this->style
->analyse($other, $param);
3469 $this->style
->setPosition();
3470 $this->style
->FontSet();
3472 if ($other=='pre') return $this->o_DIV($param, $other);
3476 function o_CODE($param) { return $this->o_PRE($param, 'code'); }
3482 * @param array paramètres de l'élément de parsing
3485 function c_PRE($param, $other = 'pre')
3489 if ($this->forOneLine
) return false;
3491 $this->c_DIV($param);
3492 $this->o_BR(array());
3494 $this->style
->load();
3495 $this->style
->FontSet();
3499 function c_CODE($param) { return $this->c_PRE($param, 'code'); }
3505 * @param array paramètres de l'élément de parsing
3508 function o_BIG($param)
3510 $this->style
->save();
3511 $this->style
->value
['mini-decal']-= $this->style
->value
['mini-size']*0.05;
3512 $this->style
->value
['mini-size'] *= 1.2;
3513 $this->style
->analyse('big', $param);
3514 $this->style
->setPosition();
3515 $this->style
->FontSet();
3523 * @param array paramètres de l'élément de parsing
3526 function c_BIG($param)
3528 $this->style
->load();
3529 $this->style
->FontSet();
3538 * @param array paramètres de l'élément de parsing
3541 function o_SMALL($param)
3543 $this->style
->save();
3544 $this->style
->value
['mini-decal']+
= $this->style
->value
['mini-size']*0.05;
3545 $this->style
->value
['mini-size'] *= 0.82;
3546 $this->style
->analyse('small', $param);
3547 $this->style
->setPosition();
3548 $this->style
->FontSet();
3556 * @param array paramètres de l'élément de parsing
3559 function c_SMALL($param)
3561 $this->style
->load();
3562 $this->style
->FontSet();
3572 * @param array paramètres de l'élément de parsing
3575 function o_SUP($param)
3577 $this->style
->save();
3578 $this->style
->value
['mini-decal']-= $this->style
->value
['mini-size']*0.15;
3579 $this->style
->value
['mini-size'] *= 0.75;
3580 $this->style
->analyse('sup', $param);
3581 $this->style
->setPosition();
3582 $this->style
->FontSet();
3591 * @param array paramètres de l'élément de parsing
3594 function c_SUP($param)
3596 $this->style
->load();
3597 $this->style
->FontSet();
3606 * @param array paramètres de l'élément de parsing
3609 function o_SUB($param)
3611 $this->style
->save();
3612 $this->style
->value
['mini-decal']+
= $this->style
->value
['mini-size']*0.15;
3613 $this->style
->value
['mini-size'] *= 0.75;
3614 $this->style
->analyse('sub', $param);
3615 $this->style
->setPosition();
3616 $this->style
->FontSet();
3624 * @param array paramètres de l'élément de parsing
3627 function c_SUB($param)
3629 $this->style
->load();
3630 $this->style
->FontSet();
3639 * @param array paramètres de l'élément de parsing
3642 function o_UL($param, $other = 'ul')
3644 if ($this->forOneLine
) return false;
3646 if (!in_array($this->previousCall
, array('c_P', 'c_UL')))
3648 if ($this->maxH
) $this->o_BR(array());
3649 if (!count($this->defLIST
)) $this->o_BR(array());
3652 if (!isset($param['style']['width'])) $param['allwidth'] = true;
3653 $param['cellspacing'] = 0;
3655 // une liste est traitée comme un tableau
3656 $this->o_TABLE($param, $other);
3658 // ajouter un niveau de liste
3659 $this->listeAddLevel($other, $this->style
->value
['list-style-type'], $this->style
->value
['list-style-image']);
3663 function o_OL($param) { return $this->o_UL($param, 'ol'); }
3669 * @param array paramètres de l'élément de parsing
3672 function c_UL($param)
3674 if ($this->forOneLine
) return false;
3677 $this->c_TABLE($param);
3679 // enlever un niveau de liste
3680 $this->listeDelLevel();
3682 if (!$this->sub_part
)
3684 if (!count($this->defLIST
)) $this->o_BR(array());
3689 function c_OL($param) { return $this->c_UL($param); }
3695 * @param array paramètres de l'élément de parsing
3698 function o_LI($param)
3700 if ($this->forOneLine
) return false;
3702 // ajouter une puce au niveau actuel
3703 $this->listeAddLi();
3705 if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
3707 // preparation du style de la puce
3708 $paramPUCE = $param;
3710 $inf = $this->listeGetLi();
3713 $paramPUCE['style']['font-family'] = $inf[0];
3714 $paramPUCE['style']['text-align'] = 'li_right';
3715 $paramPUCE['style']['vertical-align'] = 'top';
3716 $paramPUCE['style']['width'] = $this->listeGetWidth();
3717 $paramPUCE['style']['padding-right'] = $this->listeGetPadding();
3718 $paramPUCE['txt'] = $inf[2];
3722 $paramPUCE['style']['text-align'] = 'li_right';
3723 $paramPUCE['style']['vertical-align'] = 'top';
3724 $paramPUCE['style']['width'] = $this->listeGetWidth();
3725 $paramPUCE['style']['padding-right'] = $this->listeGetPadding();
3726 $paramPUCE['src'] = $inf[2];
3727 $paramPUCE['sub_li'] = true;
3731 $this->o_TR($param, 'li');
3733 $this->style
->save();
3735 if ($inf[1]) // small
3737 $this->style
->value
['mini-decal']+
= $this->style
->value
['mini-size']*0.045;
3738 $this->style
->value
['mini-size'] *= 0.75;
3741 // si on est dans un sub_html => preparation, sinon affichage classique
3742 if ($this->sub_part
)
3745 $tmp_pos = $this->temp_pos
;
3746 $tmp_lst1 = $this->parsing
->code
[$tmp_pos+
1];
3747 $tmp_lst2 = $this->parsing
->code
[$tmp_pos+
2];
3748 $this->parsing
->code
[$tmp_pos+
1] = array();
3749 $this->parsing
->code
[$tmp_pos+
1]['name'] = (isset($paramPUCE['src'])) ?
'img' : 'write';
3750 $this->parsing
->code
[$tmp_pos+
1]['param'] = $paramPUCE; unset($this->parsing
->code
[$tmp_pos+
1]['param']['style']['width']);
3751 $this->parsing
->code
[$tmp_pos+
1]['close'] = 0;
3752 $this->parsing
->code
[$tmp_pos+
2] = array();
3753 $this->parsing
->code
[$tmp_pos+
2]['name'] = 'li';
3754 $this->parsing
->code
[$tmp_pos+
2]['param'] = $paramPUCE;
3755 $this->parsing
->code
[$tmp_pos+
2]['close'] = 1;
3756 $this->o_TD($paramPUCE, 'li_sub');
3757 $this->c_TD($param);
3758 $this->temp_pos
= $tmp_pos;
3759 $this->parsing
->code
[$tmp_pos+
1] = $tmp_lst1;
3760 $this->parsing
->code
[$tmp_pos+
2] = $tmp_lst2;
3765 $this->o_TD($paramPUCE, 'li_sub');
3766 unset($paramPUCE['style']['width']);
3767 if (isset($paramPUCE['src'])) $this->o_IMG($paramPUCE);
3768 else $this->o_WRITE($paramPUCE);
3769 $this->c_TD($paramPUCE);
3771 $this->style
->load();
3774 // td pour le contenu
3775 $this->o_TD($param, 'li');
3784 * @param array paramètres de l'élément de parsing
3787 function c_LI($param)
3789 if ($this->forOneLine
) return false;
3792 $this->c_TD($param);
3795 $this->c_TR($param);
3804 * @param array paramètres de l'élément de parsing
3807 function o_TBODY($param)
3809 if ($this->forOneLine
) return false;
3811 $this->style
->save();
3812 $this->style
->analyse('tbody', $param);
3813 $this->style
->setPosition();
3814 $this->style
->FontSet();
3823 * @param array paramètres de l'élément de parsing
3826 function c_TBODY($param)
3828 if ($this->forOneLine
) return false;
3830 $this->style
->load();
3831 $this->style
->FontSet();
3840 * @param array paramètres de l'élément de parsing
3843 function o_THEAD($param)
3845 if ($this->forOneLine
) return false;
3847 global $HTML2PDF_TABLEAU;
3849 $this->style
->save();
3850 $this->style
->analyse('thead', $param);
3851 $this->style
->setPosition();
3852 $this->style
->FontSet();
3854 // si on est en mode sub_html : sauvegarde du numéro du TR
3855 if ($this->sub_part
)
3857 $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0] = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
3858 $HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array();
3859 for($pos=$this->temp_pos
; $pos<count($this->parsing
->code
); $pos++
)
3861 $todo = $this->parsing
->code
[$pos];
3862 if (strtolower($todo['name'])=='thead') $todo['name'] = 'thead_sub';
3863 $HTML2PDF_TABLEAU[$param['num']]['thead']['code'][] = $todo;
3864 if (strtolower($todo['name'])=='thead_sub' && $todo['close']) break;
3869 $level = $this->parsing
->getLevel($this->parse_pos
);
3870 $this->parse_pos+
= count($level);
3871 $HTML2PDF_TABLEAU[$param['num']]['tr_curr']+
= count($HTML2PDF_TABLEAU[$param['num']]['thead']['tr']);
3881 * @param array paramètres de l'élément de parsing
3884 function c_THEAD($param)
3886 if ($this->forOneLine
) return false;
3888 $this->style
->load();
3889 $this->style
->FontSet();
3891 // si on est en mode sub_html : sauvegarde du numéro du TR
3892 if ($this->sub_part
)
3894 global $HTML2PDF_TABLEAU;
3895 $min = $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
3896 $max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
3897 $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = range($min, $max);
3907 * @param array paramètres de l'élément de parsing
3910 function o_TFOOT($param)
3912 if ($this->forOneLine
) return false;
3914 global $HTML2PDF_TABLEAU;
3916 $this->style
->save();
3917 $this->style
->analyse('tfoot', $param);
3918 $this->style
->setPosition();
3919 $this->style
->FontSet();
3921 // si on est en mode sub_html : sauvegarde du numéro du TR
3922 if ($this->sub_part
)
3924 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0] = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
3925 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array();
3926 for($pos=$this->temp_pos
; $pos<count($this->parsing
->code
); $pos++
)
3928 $todo = $this->parsing
->code
[$pos];
3929 if (strtolower($todo['name'])=='tfoot') $todo['name'] = 'tfoot_sub';
3930 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'][] = $todo;
3931 if (strtolower($todo['name'])=='tfoot_sub' && $todo['close']) break;
3936 $level = $this->parsing
->getLevel($this->parse_pos
);
3937 $this->parse_pos+
= count($level);
3938 $HTML2PDF_TABLEAU[$param['num']]['tr_curr']+
= count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr']);
3948 * @param array paramètres de l'élément de parsing
3951 function c_TFOOT($param)
3953 if ($this->forOneLine
) return false;
3955 $this->style
->load();
3956 $this->style
->FontSet();
3958 // si on est en mode sub_html : sauvegarde du numéro du TR
3959 if ($this->sub_part
)
3961 global $HTML2PDF_TABLEAU;
3963 $min = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
3964 $max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
3965 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = range($min, $max);
3972 * balise : THEAD_SUB
3975 * @param array paramètres de l'élément de parsing
3978 function o_THEAD_SUB($param)
3980 if ($this->forOneLine
) return false;
3982 $this->style
->save();
3983 $this->style
->analyse('thead', $param);
3984 $this->style
->setPosition();
3985 $this->style
->FontSet();
3991 * balise : THEAD_SUB
3994 * @param array paramètres de l'élément de parsing
3997 function c_THEAD_SUB($param)
3999 if ($this->forOneLine
) return false;
4001 $this->style
->load();
4002 $this->style
->FontSet();
4008 * balise : TFOOT_SUB
4011 * @param array paramètres de l'élément de parsing
4014 function o_TFOOT_SUB($param)
4016 if ($this->forOneLine
) return false;
4018 $this->style
->save();
4019 $this->style
->analyse('tfoot', $param);
4020 $this->style
->setPosition();
4021 $this->style
->FontSet();
4027 * balise : TFOOT_SUB
4030 * @param array paramètres de l'élément de parsing
4033 function c_TFOOT_SUB($param)
4035 if ($this->forOneLine
) return false;
4037 $this->style
->load();
4038 $this->style
->FontSet();
4047 * @param array paramètres de l'élément de parsing
4050 function o_FORM($param)
4052 $this->style
->save();
4053 $this->style
->analyse('form', $param);
4054 $this->style
->setPosition();
4055 $this->style
->FontSet();
4057 $this->isInForm
= isset($param['action']) ?
$param['action'] : '';
4066 * @param array paramètres de l'élément de parsing
4069 function c_FORM($param)
4071 $this->isInForm
= false;
4072 $this->style
->load();
4073 $this->style
->FontSet();
4082 * @param array paramètres de l'élément de parsing
4085 function o_TABLE($param, $other = 'table')
4089 if ($this->forOneLine
) return false;
4090 $this->o_BR(array());
4093 if ($this->forOneLine
)
4096 $this->maxX
= $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
4101 // utilisation du tableau des paramétres des tables
4102 global $HTML2PDF_TABLEAU;
4104 $align_object = isset($param['align']) ?
strtolower($param['align']) : 'left';
4105 if (isset($param['align'])) unset($param['align']);
4106 if (!in_array($align_object, array('left', 'center', 'right'))) $align_object = 'left';
4108 // lecture et initialisation du style
4109 $this->style
->save();
4110 $this->style
->analyse($other, $param);
4111 $this->style
->setPosition();
4112 $this->style
->FontSet();
4114 if ($this->style
->value
['margin-auto']) $align_object = 'center';
4116 // est-on en collapse
4118 if ($other=='table')
4119 $collapse = isset($this->style
->value
['border']['collapse']) ?
$this->style
->value
['border']['collapse'] : false;
4121 // si oui il faut adapté les borders
4124 $param['style']['border'] = 'none';
4125 $param['cellspacing'] = 0;
4126 $none = $this->style
->readBorder('none');
4127 $this->style
->value
['border']['t'] = $none;
4128 $this->style
->value
['border']['r'] = $none;
4129 $this->style
->value
['border']['b'] = $none;
4130 $this->style
->value
['border']['l'] = $none;
4133 // si on est en mode sub_html : initialisation des dimensions et autres
4134 if ($this->sub_part
)
4136 if ($this->DEBUG_actif
) $this->DEBUG_add('Table n°'.$param['num'], true);
4137 $HTML2PDF_TABLEAU[$param['num']] = array();
4138 $HTML2PDF_TABLEAU[$param['num']]['border'] = isset($param['border']) ?
$this->style
->readBorder($param['border']) : null; // border spécifique si border precisé en paramètre
4139 $HTML2PDF_TABLEAU[$param['num']]['cellpadding'] = $this->style
->ConvertToMM(isset($param['cellpadding']) ?
$param['cellpadding'] : '1px'); // cellpadding du tableau
4140 $HTML2PDF_TABLEAU[$param['num']]['cellspacing'] = $this->style
->ConvertToMM(isset($param['cellspacing']) ?
$param['cellspacing'] : '2px'); // cellspacing du tableau
4141 $HTML2PDF_TABLEAU[$param['num']]['cases'] = array(); // liste des propriétés des cases
4142 $HTML2PDF_TABLEAU[$param['num']]['corr'] = array(); // tableau de correlation pour les colspan et rowspan
4143 $HTML2PDF_TABLEAU[$param['num']]['corr_x'] = 0; // position dans le tableau de correlation
4144 $HTML2PDF_TABLEAU[$param['num']]['corr_y'] = 0; // position dans le tableau de correlation
4145 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0; // colonne courante
4146 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0; // ligne courante
4147 $HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $this->pdf
->getX(); // position courante X
4148 $HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this->pdf
->getY(); // position courante Y
4149 $HTML2PDF_TABLEAU[$param['num']]['width'] = 0; // largeur globale
4150 $HTML2PDF_TABLEAU[$param['num']]['height'] = 0; // hauteur globale
4151 $HTML2PDF_TABLEAU[$param['num']]['align'] = $align_object;
4152 $HTML2PDF_TABLEAU[$param['num']]['marge'] = array();
4153 $HTML2PDF_TABLEAU[$param['num']]['marge']['t'] = $this->style
->value
['padding']['t']+
$this->style
->value
['border']['t']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
4154 $HTML2PDF_TABLEAU[$param['num']]['marge']['r'] = $this->style
->value
['padding']['r']+
$this->style
->value
['border']['r']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
4155 $HTML2PDF_TABLEAU[$param['num']]['marge']['b'] = $this->style
->value
['padding']['b']+
$this->style
->value
['border']['b']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
4156 $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] = $this->style
->value
['padding']['l']+
$this->style
->value
['border']['l']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
4157 $HTML2PDF_TABLEAU[$param['num']]['page'] = 0; // nombre de pages
4158 $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true; // nouvelle page pour le TR courant
4159 $HTML2PDF_TABLEAU[$param['num']]['style_value'] = null; // style du tableau
4160 $HTML2PDF_TABLEAU[$param['num']]['thead'] = array(); // infos sur le thead
4161 $HTML2PDF_TABLEAU[$param['num']]['tfoot'] = array(); // infos sur le tfoot
4162 $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = array(); // tr du thead
4163 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = array(); // tr du tfoot
4164 $HTML2PDF_TABLEAU[$param['num']]['thead']['height'] = 0; // hauteur du thead
4165 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'] = 0; // hauteur du tfoot
4166 $HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array(); // contenu HTML du thead
4167 $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array(); // contenu HTML du tfoot
4168 $HTML2PDF_TABLEAU[$param['num']]['cols'] = array(); // definition via les balises col
4169 $this->saveMargin($this->pdf
->getlMargin(), $this->pdf
->gettMargin(), $this->pdf
->getrMargin());
4171 // adaptation de la largeur en fonction des marges du tableau
4172 $this->style
->value
['width']-= $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] +
$HTML2PDF_TABLEAU[$param['num']]['marge']['r'];
4176 // on repart à la premiere page du tableau et à la premiere case
4177 $HTML2PDF_TABLEAU[$param['num']]['page'] = 0;
4178 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
4179 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0;
4180 $HTML2PDF_TABLEAU[$param['num']]['td_x'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['l']+
$HTML2PDF_TABLEAU[$param['num']]['curr_x'];
4181 $HTML2PDF_TABLEAU[$param['num']]['td_y'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['t']+
$HTML2PDF_TABLEAU[$param['num']]['curr_y'];
4183 // initialisation du style des bordures de la premiere partie de tableau
4184 $this->drawRectangle(
4185 $HTML2PDF_TABLEAU[$param['num']]['curr_x'],
4186 $HTML2PDF_TABLEAU[$param['num']]['curr_y'],
4187 $HTML2PDF_TABLEAU[$param['num']]['width'],
4188 isset($HTML2PDF_TABLEAU[$param['num']]['height'][0]) ?
$HTML2PDF_TABLEAU[$param['num']]['height'][0] : null,
4189 $this->style
->value
['border'],
4190 $this->style
->value
['padding'],
4192 $this->style
->value
['background']
4195 $HTML2PDF_TABLEAU[$param['num']]['style_value'] = $this->style
->value
;
4205 * @param array paramètres de l'élément de parsing
4208 function c_TABLE($param)
4210 if ($this->forOneLine
) return false;
4213 global $HTML2PDF_TABLEAU;
4215 // restauration du style
4216 $this->style
->load();
4217 $this->style
->FontSet();
4219 // si on est en mode sub_html : initialisation des dimensions et autres
4220 if ($this->sub_part
)
4222 // ajustement de la taille des cases
4223 $this->calculTailleCases($HTML2PDF_TABLEAU[$param['num']]['cases'], $HTML2PDF_TABLEAU[$param['num']]['corr']);
4225 // calcul de la hauteur du THEAD et du TFOOT
4226 $lst = array('thead', 'tfoot');
4227 foreach($lst as $mode)
4229 $HTML2PDF_TABLEAU[$param['num']][$mode]['height'] = 0;
4230 foreach($HTML2PDF_TABLEAU[$param['num']][$mode]['tr'] as $tr)
4232 // hauteur de la ligne tr
4234 for($i=0; $i<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$tr]); $i++
)
4235 if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$tr][$i]['rowspan']==1)
4236 $h = max($h, $HTML2PDF_TABLEAU[$param['num']]['cases'][$tr][$i]['h']);
4237 $HTML2PDF_TABLEAU[$param['num']][$mode]['height']+
= $h;
4241 // calcul des dimensions du tableau - Largeur
4242 $HTML2PDF_TABLEAU[$param['num']]['width'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] +
$HTML2PDF_TABLEAU[$param['num']]['marge']['r'];
4243 if (isset($HTML2PDF_TABLEAU[$param['num']]['cases'][0]))
4244 foreach($HTML2PDF_TABLEAU[$param['num']]['cases'][0] as $case)
4245 $HTML2PDF_TABLEAU[$param['num']]['width']+
= $case['w'];
4247 // positionnement du tableau horizontalement;
4248 $old = $this->style
->getOldValues();
4249 $parent_w = $old['width'] ?
$old['width'] : $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
4250 $x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'];
4251 $w = $HTML2PDF_TABLEAU[$param['num']]['width'];
4254 if ($HTML2PDF_TABLEAU[$param['num']]['align']=='center')
4255 $x = $x +
($parent_w-$w)*0.5;
4256 else if ($HTML2PDF_TABLEAU[$param['num']]['align']=='right')
4257 $x = $x +
$parent_w-$w;
4259 $HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $x;
4263 // calcul des dimensions du tableau - hauteur du tableau sur chaque page
4264 $HTML2PDF_TABLEAU[$param['num']]['height'] = array();
4266 $h0 = $HTML2PDF_TABLEAU[$param['num']]['marge']['t'] +
$HTML2PDF_TABLEAU[$param['num']]['marge']['b']; // minimum de hauteur à cause des marges
4267 $h0+
= $HTML2PDF_TABLEAU[$param['num']]['thead']['height'] +
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['height']; // et du tfoot et thead
4268 $max = $this->pdf
->getH() - $this->pdf
->getbMargin(); // max de hauteur par page
4269 $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']; // position Y actuelle
4272 // on va lire les hauteurs de chaque ligne, une à une, et voir si ca rentre sur la page.
4273 for($k=0; $k<count($HTML2PDF_TABLEAU[$param['num']]['cases']); $k++
)
4275 // si c'est des lignes du thead ou du tfoot : on passe
4276 if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'])) continue;
4277 if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'])) continue;
4279 // hauteur de la ligne $k
4282 for($i=0; $i<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$k]); $i++
)
4284 $h = max($h, $HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['h']);
4286 if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['rowspan']==1)
4287 $th = max($th, $HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['h']);
4290 // si la ligne ne rentre pas dans la page
4291 // => la hauteur sur cette page est trouvée, et on passe à la page d'apres
4292 if ($y+
$h+
$height>$max)
4294 if ($height==$h0) $height = null;
4295 $HTML2PDF_TABLEAU[$param['num']]['height'][] = $height;
4297 $y = $this->margeTop
;
4301 // rajout du reste de tableau (si il existe) à la derniere page
4302 if ($height!=$h0 ||
$k==0) $HTML2PDF_TABLEAU[$param['num']]['height'][] = $height;
4306 if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['code']))
4308 $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
4309 $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
4310 $OLD_parse_pos = $this->parse_pos
;
4311 $OLD_parse_code = $this->parsing
->code
;
4313 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
4314 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
4315 $this->parse_pos
= 0;
4316 $this->parsing
->code
= $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
4317 $this->makeHTMLcode();
4319 $this->parse_pos
= $OLD_parse_pos;
4320 $this->parsing
->code
= $OLD_parse_code;
4321 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
4322 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
4325 // determination des coordonnées de sortie du tableau
4326 $x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'] +
$HTML2PDF_TABLEAU[$param['num']]['width'];
4327 if (count($HTML2PDF_TABLEAU[$param['num']]['height'])>1)
4328 $y = $this->margeTop+
$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]['height'])-1];
4329 else if (count($HTML2PDF_TABLEAU[$param['num']]['height'])==1)
4330 $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']+
$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]['height'])-1];
4332 $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y'];
4334 // taille du tableau
4335 $this->maxX
= max($this->maxX
, $x);
4336 $this->maxY
= max($this->maxY
, $y);
4339 // nouvelle position apres le tableau
4340 $this->pdf
->setXY($this->pdf
->getlMargin(), $y);
4342 // restauration des marges
4343 $this->loadMargin();
4345 if ($this->DEBUG_actif
) $this->DEBUG_add('Table n°'.$param['num'], false);
4354 * mode : OUVERTURE (pas de fermeture)
4356 * @param array paramètres de l'élément de parsing
4359 function o_COL($param)
4361 global $HTML2PDF_TABLEAU;
4362 $span = isset($param['span']) ?
$param['span'] : 1;
4363 for($k=0; $k<$span; $k++
)
4364 $HTML2PDF_TABLEAU[$param['num']]['cols'][] = $param;
4371 * @param array paramètres de l'élément de parsing
4374 function o_TR($param, $other = 'tr')
4376 if ($this->forOneLine
) return false;
4379 global $HTML2PDF_TABLEAU;
4382 $this->style
->save();
4383 $this->style
->analyse($other, $param);
4384 $this->style
->setPosition();
4385 $this->style
->FontSet();
4387 // positionnement dans le tableau
4388 $HTML2PDF_TABLEAU[$param['num']]['tr_curr']++
;
4389 $HTML2PDF_TABLEAU[$param['num']]['td_curr']= 0;
4391 // si on est pas dans un sub_html
4392 if (!$this->sub_part
)
4394 // Y courant apres la ligne
4396 for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++
)
4397 $ty = max($ty, $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['h']);
4399 $hfoot = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'];
4401 // si la ligne ne rentre pas dans la page => nouvelle page
4402 if (!$this->isInTfoot
&& $HTML2PDF_TABLEAU[$param['num']]['td_y'] +
$HTML2PDF_TABLEAU[$param['num']]['marge']['b'] +
$ty +
$hfoot> $this->pdf
->getH() - $this->pdf
->getbMargin())
4404 if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['code']))
4406 $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
4407 $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
4408 $OLD_parse_pos = $this->parse_pos
;
4409 $OLD_parse_code = $this->parsing
->code
;
4411 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
4412 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
4413 $this->parse_pos
= 0;
4414 $this->parsing
->code
= $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
4415 $this->isInTfoot
= true;
4416 $this->makeHTMLcode();
4417 $this->isInTfoot
= false;
4419 $this->parse_pos
= $OLD_parse_pos;
4420 $this->parsing
->code
= $OLD_parse_code;
4421 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
4422 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
4425 $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
4426 $this->setNewPage();
4428 $HTML2PDF_TABLEAU[$param['num']]['page']++
;
4429 $HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this->pdf
->getY();
4430 $HTML2PDF_TABLEAU[$param['num']]['td_y'] = $HTML2PDF_TABLEAU[$param['num']]['curr_y']+
$HTML2PDF_TABLEAU[$param['num']]['marge']['t'];
4432 // si la hauteur de cette partie a bien été calculée, on trace le cadre
4433 if (isset($HTML2PDF_TABLEAU[$param['num']]['height'][$HTML2PDF_TABLEAU[$param['num']]['page']]))
4435 $old = $this->style
->value
;
4436 $this->style
->value
= $HTML2PDF_TABLEAU[$param['num']]['style_value'];
4438 // initialisation du style des bordures de la premiere partie de tableau
4439 $this->drawRectangle(
4440 $HTML2PDF_TABLEAU[$param['num']]['curr_x'],
4441 $HTML2PDF_TABLEAU[$param['num']]['curr_y'],
4442 $HTML2PDF_TABLEAU[$param['num']]['width'],
4443 $HTML2PDF_TABLEAU[$param['num']]['height'][$HTML2PDF_TABLEAU[$param['num']]['page']],
4444 $this->style
->value
['border'],
4445 $this->style
->value
['padding'],
4446 $HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5,
4447 $this->style
->value
['background']
4450 $this->style
->value
= $old;
4454 if ($HTML2PDF_TABLEAU[$param['num']]['new_page'] && count($HTML2PDF_TABLEAU[$param['num']]['thead']['code']))
4456 $HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
4457 $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
4458 $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
4459 $OLD_parse_pos = $this->parse_pos
;
4460 $OLD_parse_code = $this->parsing
->code
;
4462 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
4463 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
4464 $this->parse_pos
= 0;
4465 $this->parsing
->code
= $HTML2PDF_TABLEAU[$param['num']]['thead']['code'];
4466 $this->isInThead
= true;
4467 $this->makeHTMLcode();
4468 $this->isInThead
= false;
4470 $this->parse_pos
= $OLD_parse_pos;
4471 $this->parsing
->code
= $OLD_parse_code;
4472 $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
4473 $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
4474 $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
4479 $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1] = array();
4480 if (!isset($HTML2PDF_TABLEAU[$param['num']]['corr'][$HTML2PDF_TABLEAU[$param['num']]['corr_y']]))
4481 $HTML2PDF_TABLEAU[$param['num']]['corr'][$HTML2PDF_TABLEAU[$param['num']]['corr_y']] = array();
4483 $HTML2PDF_TABLEAU[$param['num']]['corr_x']=0;
4484 while(isset($HTML2PDF_TABLEAU[$param['num']]['corr'][$HTML2PDF_TABLEAU[$param['num']]['corr_y']][$HTML2PDF_TABLEAU[$param['num']]['corr_x']]))
4485 $HTML2PDF_TABLEAU[$param['num']]['corr_x']++
;
4495 * @param array paramètres de l'élément de parsing
4498 function c_TR($param)
4500 if ($this->forOneLine
) return false;
4503 global $HTML2PDF_TABLEAU;
4505 // restauration du style
4506 $this->style
->load();
4507 $this->style
->FontSet();
4509 // si on est pas dans un sub_html
4510 if (!$this->sub_part
)
4512 // Y courant apres la ligne
4514 for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++
)
4515 if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['rowspan']==1)
4516 $ty = $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['h'];
4518 // mise à jour des coordonnées courantes
4519 $HTML2PDF_TABLEAU[$param['num']]['td_x'] = $HTML2PDF_TABLEAU[$param['num']]['curr_x']+
$HTML2PDF_TABLEAU[$param['num']]['marge']['l'];
4520 $HTML2PDF_TABLEAU[$param['num']]['td_y']+
= $ty;
4521 $HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
4525 $HTML2PDF_TABLEAU[$param['num']]['corr_y']++
;
4535 * @param array paramètres de l'élément de parsing
4538 function o_TD($param, $other = 'td')
4540 if ($this->forOneLine
) return false;
4543 global $HTML2PDF_TABLEAU;
4545 $param['cellpadding'] = $HTML2PDF_TABLEAU[$param['num']]['cellpadding'].'mm';
4546 $param['cellspacing'] = $HTML2PDF_TABLEAU[$param['num']]['cellspacing'].'mm';
4554 $special_li = false;
4555 if ($other=='li_sub')
4557 $param['style']['border'] = 'none';
4558 $param['style']['background-color'] = 'transparent';
4559 $param['style']['background-image'] = 'none';
4560 $param['style']['background-position'] = '';
4561 $param['style']['background-repeat'] = '';
4566 // est-on en collapse, et egalement y-a-t'il des definitions de colonne
4567 $x = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
4568 $y = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
4569 $colspan = isset($param['colspan']) ?
$param['colspan'] : 1;
4570 $rowspan = isset($param['rowspan']) ?
$param['rowspan'] : 1;
4572 if (in_array($other, array('td', 'th')))
4574 $num_col = isset($HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Xr']) ?
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Xr'] : $HTML2PDF_TABLEAU[$param['num']]['corr_x'];
4576 // si une definition de colonne est presente
4577 if (isset($HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col]))
4580 $col_param = $HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col];
4582 // pour les colspan, on recupere toutes les largeurs
4583 $col_param['style']['width'] = array();
4584 for($k=0; $k<$colspan; $k++
)
4586 if (isset($HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col+
$k]['style']['width']))
4587 $col_param['style']['width'][] = $HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col+
$k]['style']['width'];
4592 $last = $this->style
->getLastWidth();
4593 if (count($col_param['style']['width']))
4595 $total = $col_param['style']['width'][0]; unset($col_param['style']['width'][0]);
4596 foreach($col_param['style']['width'] as $width)
4598 if (substr($total, -1)=='%' && substr($width, -1)=='%')
4599 $total = (str_replace('%', '', $total)+
str_replace('%', '', $width)).'%';
4601 $total = ($this->style
->ConvertToMM($total, $last) +
$this->style
->ConvertToMM($width, $last)).'mm';
4605 // et on recupere la largeur finale
4607 $col_param['style']['width'] = $total;
4609 unset($col_param['style']['width']);
4612 // on merge les 2 styles (col + td)
4613 $param['style'] = array_merge($col_param['style'], $param['style']);
4615 // si une classe est définie, on la merge egalement
4616 if (isset($col_param['class']))
4617 $param['class'] = $col_param['class'].(isset($param['class']) ?
' '.$param['class'] : '');
4620 $collapse = isset($this->style
->value
['border']['collapse']) ?
$this->style
->value
['border']['collapse'] : false;
4625 $this->style
->save();
4627 if (in_array($other, array('td', 'th')))
4629 $heritage = array();
4631 $old = $this->style
->getLastValue('background');
4632 if ($old && ($old['color'] ||
$old['image']))
4633 $heritage['background'] = $old;
4635 if ($HTML2PDF_TABLEAU[$param['num']]['border'])
4637 $heritage['border'] = array();
4638 $heritage['border']['l'] = $HTML2PDF_TABLEAU[$param['num']]['border'];
4639 $heritage['border']['t'] = $HTML2PDF_TABLEAU[$param['num']]['border'];
4640 $heritage['border']['r'] = $HTML2PDF_TABLEAU[$param['num']]['border'];
4641 $heritage['border']['b'] = $HTML2PDF_TABLEAU[$param['num']]['border'];
4644 $return = $this->style
->analyse($other, $param, $heritage);
4648 $this->style
->value
['width']-= $this->style
->ConvertToMM($this->listeGetWidth());
4649 $this->style
->value
['width']-= $this->style
->ConvertToMM($this->listeGetPadding());
4651 $this->style
->setPosition();
4652 $this->style
->FontSet();
4654 // si on est en collapse : modification du style
4657 if (!$this->sub_part
)
4660 ($HTML2PDF_TABLEAU[$param['num']]['tr_curr']>1 && !$HTML2PDF_TABLEAU[$param['num']]['new_page']) ||
4661 (!$this->isInThead
&& count($HTML2PDF_TABLEAU[$param['num']]['thead']['code']))
4664 $this->style
->value
['border']['t'] = $this->style
->readBorder('none');
4668 if ($HTML2PDF_TABLEAU[$param['num']]['td_curr']>0)
4670 if (!$return) $this->style
->value
['width']+
= $this->style
->value
['border']['l']['width'];
4671 $this->style
->value
['border']['l'] = $this->style
->readBorder('none');
4676 $marge['t'] = $this->style
->value
['padding']['t']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['t']['width'];
4677 $marge['r'] = $this->style
->value
['padding']['r']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['r']['width'];
4678 $marge['b'] = $this->style
->value
['padding']['b']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['b']['width'];
4679 $marge['l'] = $this->style
->value
['padding']['l']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['l']['width'];
4681 // si on est dans un sub_html
4682 if ($this->sub_part
)
4684 // on se positionne dans le tableau
4685 $HTML2PDF_TABLEAU[$param['num']]['td_curr']++
;
4686 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x] = array();
4687 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['w'] = 0;
4688 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['h'] = 0;
4689 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['dw'] = 0;
4690 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['colspan'] = $colspan;
4691 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan;
4692 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Xr'] = $HTML2PDF_TABLEAU[$param['num']]['corr_x'];
4693 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Yr'] = $HTML2PDF_TABLEAU[$param['num']]['corr_y'];
4695 for($j=0; $j<$rowspan; $j++
)
4697 for($i=0; $i<$colspan; $i++
)
4699 $HTML2PDF_TABLEAU[$param['num']]['corr']
4700 [$HTML2PDF_TABLEAU[$param['num']]['corr_y']+
$j]
4701 [$HTML2PDF_TABLEAU[$param['num']]['corr_x']+
$i] = ($i+
$j>0) ?
'' : array($x,$y,$colspan,$rowspan);
4704 $HTML2PDF_TABLEAU[$param['num']]['corr_x']+
= $colspan;
4705 while(isset($HTML2PDF_TABLEAU[$param['num']]['corr'][$HTML2PDF_TABLEAU[$param['num']]['corr_y']][$HTML2PDF_TABLEAU[$param['num']]['corr_x']]))
4706 $HTML2PDF_TABLEAU[$param['num']]['corr_x']++
;
4708 // on extrait tout ce qui est contenu dans le TD
4709 // on en créé un sous HTML que l'on transforme en PDF
4710 // pour analyse les dimensions
4711 // et les récupérer dans le tableau global.
4712 $level = $this->parsing
->getLevel($this->temp_pos
);
4713 $this->CreateSubHTML($this->sub_html
);
4714 $this->sub_html
->parsing
->code
= $level;
4715 $this->sub_html
->MakeHTMLcode();
4716 $this->temp_pos+
= count($level);
4720 // on se positionne dans le tableau
4721 $HTML2PDF_TABLEAU[$param['num']]['td_curr']++
;
4722 $HTML2PDF_TABLEAU[$param['num']]['td_x']+
= $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['dw'];
4724 // initialisation du style des bordures de la premiere partie de tableau
4725 $this->drawRectangle(
4726 $HTML2PDF_TABLEAU[$param['num']]['td_x'],
4727 $HTML2PDF_TABLEAU[$param['num']]['td_y'],
4728 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['w'],
4729 $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['h'],
4730 $this->style
->value
['border'],
4731 $this->style
->value
['padding'],
4732 $HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5,
4733 $this->style
->value
['background']
4737 $this->style
->value
['width'] = $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];
4739 // limitation des marges aux dimensions de la case
4740 $mL = $HTML2PDF_TABLEAU[$param['num']]['td_x']+
$marge['l'];
4741 $mR = $this->pdf
->getW() - $mL - $this->style
->value
['width'];
4742 $this->saveMargin($mL, 0, $mR);
4744 // positionnement en fonction
4745 $h_corr = $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['h'];
4746 $h_reel = $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['real_h'];
4747 switch($this->style
->value
['vertical-align'])
4750 $y_corr = $h_corr-$h_reel;
4754 $y_corr = ($h_corr-$h_reel)*0.5;
4763 $x = $HTML2PDF_TABLEAU[$param['num']]['td_x']+
$marge['l'];
4764 $y = $HTML2PDF_TABLEAU[$param['num']]['td_y']+
$marge['t']+
$y_corr;
4765 $this->pdf
->setXY($x, $y);
4766 $this->setNewPositionForNewLine();
4776 * @param array paramètres de l'élément de parsing
4779 function c_TD($param)
4781 if ($this->forOneLine
) return false;
4784 global $HTML2PDF_TABLEAU;
4786 // récupération de la marge
4788 $marge['t'] = $this->style
->value
['padding']['t']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['t']['width'];
4789 $marge['r'] = $this->style
->value
['padding']['r']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['r']['width'];
4790 $marge['b'] = $this->style
->value
['padding']['b']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['b']['width'];
4791 $marge['l'] = $this->style
->value
['padding']['l']+
0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+
$this->style
->value
['border']['l']['width'];
4792 $marge['t']+
= 0.001;
4793 $marge['r']+
= 0.001;
4794 $marge['b']+
= 0.001;
4795 $marge['l']+
= 0.001;
4797 // si on est dans un sub_html
4798 if ($this->sub_part
)
4800 if ($this->testTDin1page
&& $this->sub_html
->pdf
->getPage()>1) HTML2PDF
::makeError(7, __FILE__
, __LINE__
);
4802 // dimentions de cette case
4803 $w0 = $this->sub_html
->maxX +
$marge['l'] +
$marge['r'];
4804 $h0 = $this->sub_html
->maxY +
$marge['t'] +
$marge['b'];
4806 // dimensions imposées par le style
4807 $w2 = $this->style
->value
['width'] +
$marge['l'] +
$marge['r'];
4808 $h2 = $this->style
->value
['height'] +
$marge['t'] +
$marge['b'];
4810 // dimension finale de la case = max des 2 ci-dessus
4811 $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2));
4812 $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2));
4814 $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['real_w'] = $w0;
4815 $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['real_h'] = $h0;
4817 // suppresion du sous_html
4818 $this->destroySubHTML($this->sub_html
);
4822 $this->loadMargin();
4824 $HTML2PDF_TABLEAU[$param['num']]['td_x']+
= $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'];
4827 // restauration du style
4828 $this->style
->load();
4829 $this->style
->FontSet();
4834 function calculTailleCases(&$cases, &$corr)
4836 /* // construction d'un tableau de correlation
4839 // on fait correspondre chaque case d'un tableau normé aux cases réelles, en prennant en compte les colspan et rowspan
4841 for($y=0; $y<count($cases); $y++)
4843 $Xr=0; while(isset($corr[$Yr][$Xr])) $Xr++;
4845 for($x=0; $x<count($cases[$y]); $x++)
4847 for($j=0; $j<$cases[$y][$x]['rowspan']; $j++)
4849 for($i=0; $i<$cases[$y][$x]['colspan']; $i++)
4851 $corr[$Yr+$j][$Xr+$i] = ($i+$j>0) ? '' : array($x, $y, $cases[$y][$x]['colspan'], $cases[$y][$x]['rowspan']);
4854 $Xr+= $cases[$y][$x]['colspan'];
4855 while(isset($corr[$Yr][$Xr])) $Xr++;
4860 if (!isset($corr[0])) return true;
4862 // on détermine, pour les cases sans colspan, la largeur maximale de chaque colone
4864 for($x=0; $x<count($corr[0]); $x++
)
4867 for($y=0; $y<count($corr); $y++
)
4868 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1)
4869 $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']);
4873 // on vérifie que cette taille est valide avec les colones en colspan
4874 for($x=0; $x<count($corr[0]); $x++
)
4876 for($y=0; $y<count($corr); $y++
)
4878 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1)
4880 // somme des colonnes correspondant au colspan
4881 $s = 0; for($i=0; $i<$corr[$y][$x][2]; $i++
) $s+
= $sw[$x+
$i];
4883 // si la somme est inférieure à la taille necessaire => règle de 3 pour adapter
4884 if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'])
4885 for($i=0; $i<$corr[$y][$x][2]; $i++
)
4886 $sw[$x+
$i] = $sw[$x+
$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
4891 // on applique les nouvelles largeurs
4892 for($x=0; $x<count($corr[0]); $x++
)
4894 for($y=0; $y<count($corr); $y++
)
4896 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]))
4898 if ($corr[$y][$x][2]==1)
4900 $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x];
4904 // somme des colonnes correspondant au colspan
4905 $s = 0; for($i=0; $i<$corr[$y][$x][2]; $i++
) $s+
= $sw[$x+
$i];
4906 $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s;
4912 // on détermine, pour les cases sans rowspan, la hauteur maximale de chaque colone
4914 for($y=0; $y<count($corr); $y++
)
4917 for($x=0; $x<count($corr[0]); $x++
)
4918 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1)
4919 $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']);
4924 // on vérifie que cette taille est valide avec les lignes en rowspan
4925 for($y=0; $y<count($corr); $y++
)
4927 for($x=0; $x<count($corr[0]); $x++
)
4929 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1)
4931 // somme des colonnes correspondant au colspan
4932 $s = 0; for($i=0; $i<$corr[$y][$x][3]; $i++
) $s+
= $sh[$y+
$i];
4934 // si la somme est inférieure à la taille necessaire => règle de 3 pour adapter
4935 if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'])
4936 for($i=0; $i<$corr[$y][$x][3]; $i++
)
4937 $sh[$y+
$i] = $sh[$y+
$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
4943 // on applique les nouvelles hauteurs
4944 for($y=0; $y<count($corr); $y++
)
4946 for($x=0; $x<count($corr[0]); $x++
)
4948 if (isset($corr[$y][$x]) && is_array($corr[$y][$x]))
4950 if ($corr[$y][$x][3]==1)
4952 $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y];
4956 // somme des lignes correspondant au rowspan
4957 $s = 0; for($i=0; $i<$corr[$y][$x][3]; $i++
) $s+
= $sh[$y+
$i];
4958 $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s;
4960 for($j=1; $j<$corr[$y][$x][3]; $j++
)
4964 for(true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++
);
4965 if (isset($corr[$ty][$tx])) $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+
= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
4978 * @param array paramètres de l'élément de parsing
4981 function o_TH($param)
4983 if ($this->forOneLine
) return false;
4986 // identique à TD mais en gras
4987 if (!isset($param['style']['font-weight'])) $param['style']['font-weight'] = 'bold';
4988 $this->o_TD($param, 'th');
4997 * @param array paramètres de l'élément de parsing
5000 function c_TH($param)
5002 if ($this->forOneLine
) return false;
5006 $this->c_TD($param);
5015 * @param array paramètres de l'élément de parsing
5018 function o_IMG($param)
5021 $src = str_replace('&', '&', $param['src']);
5023 $this->style
->save();
5024 $this->style
->value
['width'] = 0;
5025 $this->style
->value
['height'] = 0;
5026 $this->style
->value
['border'] = array(
5029 'color' => array(0, 0, 0),
5031 $this->style
->value
['background'] = array(
5037 $this->style
->analyse('img', $param);
5038 $this->style
->setPosition();
5039 $this->style
->FontSet();
5041 // affichage de l'image
5042 $res = $this->Image($src, isset($param['sub_li']));
5043 if (!$res) return $res;
5045 // restauration du style
5046 $this->style
->load();
5047 $this->style
->FontSet();
5057 * @param array paramètres de l'élément de parsing
5060 function o_SELECT($param)
5062 // preparation du champs
5063 if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps
)+
1);
5065 $param['name'] = strtolower($param['name']);
5067 if (isset($this->lstChamps
[$param['name']]))
5068 $this->lstChamps
[$param['name']]++
;
5070 $this->lstChamps
[$param['name']] = 1;
5072 $this->style
->save();
5073 $this->style
->analyse('select', $param);
5074 $this->style
->setPosition();
5075 $this->style
->FontSet();
5077 $this->lstSelect
= array();
5078 $this->lstSelect
['name'] = $param['name'];
5079 $this->lstSelect
['multi'] = isset($param['multiple']) ?
true : false;
5080 $this->lstSelect
['size'] = isset($param['size']) ?
$param['size'] : 1;
5081 $this->lstSelect
['options'] = array();
5083 if ($this->lstSelect
['multi'] && $this->lstSelect
['size']<3) $this->lstSelect
['size'] = 3;
5092 * @param array paramètres de l'élément de parsing
5095 function o_OPTION($param)
5097 // on extrait tout ce qui est contenu dans l'option
5098 $level = $this->parsing
->getLevel($this->parse_pos
);
5099 $this->parse_pos+
= count($level);
5100 $value = isset($param['value']) ?
$param['value'] : 'auto_opt_'.(count($this->lstSelect
)+
1);
5102 $this->lstSelect
['options'][$value] = isset($level[0]['param']['txt']) ?
$level[0]['param']['txt'] : '';
5111 * @param array paramètres de l'élément de parsing
5114 function c_OPTION($param) { return true; }
5120 * @param array paramètres de l'élément de parsing
5125 // position d'affichage
5126 $x = $this->pdf
->getX();
5127 $y = $this->pdf
->getY();
5128 $f = 1.08*$this->style
->value
['font-size'];
5130 $w = $this->style
->value
['width']; if (!$w) $w = 50;
5131 $h = ($f*1.07*$this->lstSelect
['size'] +
1);
5133 if ($this->lstSelect
['multi']) $prop['multipleSelection'] = true;
5134 $this->pdf
->form_Select($this->lstSelect
['name'], $x, $y, $w, $h, $this->lstSelect
['options'], $this->lstSelect
['size']>1, $prop);
5136 $this->maxX
= max($this->maxX
, $x+
$w);
5137 $this->maxY
= max($this->maxY
, $y+
$h);
5138 $this->maxH
= max($this->maxH
, $h);
5139 $this->pdf
->setX($x+
$w);
5141 $this->style
->load();
5142 $this->style
->FontSet();
5144 $this->lstSelect
= array();
5153 * @param array paramètres de l'élément de parsing
5156 function o_TEXTAREA($param)
5158 // preparation du champs
5159 if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps
)+
1);
5161 $param['name'] = strtolower($param['name']);
5163 if (isset($this->lstChamps
[$param['name']]))
5164 $this->lstChamps
[$param['name']]++
;
5166 $this->lstChamps
[$param['name']] = 1;
5168 $this->style
->save();
5169 $this->style
->analyse('textarea', $param);
5170 $this->style
->setPosition();
5171 $this->style
->FontSet();
5173 // position d'affichage
5174 $x = $this->pdf
->getX();
5175 $y = $this->pdf
->getY();
5176 $fx = 0.65*$this->style
->value
['font-size'];
5177 $fy = 1.08*$this->style
->value
['font-size'];
5179 // on extrait tout ce qui est contenu dans le textarea
5180 $level = $this->parsing
->getLevel($this->parse_pos
);
5181 $this->parse_pos+
= count($level);
5183 $w = $fx*(isset($param['cols']) ?
$param['cols'] : 22)+
1;
5184 $h = $fy*1.07*(isset($param['rows']) ?
$param['rows'] : 3)+
3;
5186 // if ($this->style->value['width']) $w = $this->style->value['width'];
5187 // if ($this->style->value['height']) $h = $this->style->value['height'];
5190 $prop['multiline'] = true;
5191 $prop['value'] = isset($level[0]['param']['txt']) ?
$level[0]['param']['txt'] : '';
5193 $this->pdf
->form_InputText($param['name'], $x, $y, $w, $h, $prop);
5195 $this->maxX
= max($this->maxX
, $x+
$w);
5196 $this->maxY
= max($this->maxY
, $y+
$h);
5197 $this->maxH
= max($this->maxH
, $h);
5198 $this->pdf
->setX($x+
$w);
5207 * @param array paramètres de l'élément de parsing
5210 function c_TEXTAREA()
5212 $this->style
->load();
5213 $this->style
->FontSet();
5222 * @param array paramètres de l'élément de parsing
5225 function o_INPUT($param)
5227 // preparation du champs
5228 if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps
)+
1);
5229 if (!isset($param['value'])) $param['value'] = '';
5230 if (!isset($param['type'])) $param['type'] = 'text';
5232 $param['name'] = strtolower($param['name']);
5233 $param['type'] = strtolower($param['type']);
5235 if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) $param['type'] = 'text';
5237 if (isset($this->lstChamps
[$param['name']]))
5238 $this->lstChamps
[$param['name']]++
;
5240 $this->lstChamps
[$param['name']] = 1;
5242 $this->style
->save();
5243 $this->style
->analyse('input', $param);
5244 $this->style
->setPosition();
5245 $this->style
->FontSet();
5247 $name = $param['name'];
5249 // position d'affichage
5250 $x = $this->pdf
->getX();
5251 $y = $this->pdf
->getY();
5252 $f = 1.08*$this->style
->value
['font-size'];
5254 switch($param['type'])
5259 if ($h<$f) $y+
= ($f-$h)*0.5;
5260 $this->pdf
->form_InputCheckBox($name, $x, $y, $w, isset($param['checked']));
5266 if ($h<$f) $y+
= ($f-$h)*0.5;
5267 $this->pdf
->form_InputRadio($name, $x, $y, $w);
5273 $this->pdf
->form_InputHidden($name, $param['value']);
5277 $w = $this->style
->value
['width']; if (!$w) $w = 40;
5280 $prop['value'] = $param['value'];
5281 $this->pdf
->form_InputText($name, $x, $y, $w, $h, $prop);
5285 $w = $this->style
->value
['width']; if (!$w) $w = 40;
5286 $h = $this->style
->value
['height']; if (!$h) $h = $f*1.3;
5287 $action = 'this.submitForm("'.$this->isInForm
.'", false);';
5288 $this->pdf
->form_InputButton($name, $x, $y, $w, $h, $param['value'], $action, array());
5292 $w = $this->style
->value
['width']; if (!$w) $w = 40;
5293 $h = $this->style
->value
['height']; if (!$h) $h = $f*1.3;
5294 $action = 'this.resetForm();';
5295 $this->pdf
->form_InputButton($name, $x, $y, $w, $h, $param['value'], $action, array());
5299 $w = $this->style
->value
['width']; if (!$w) $w = 40;
5300 $h = $this->style
->value
['height']; if (!$h) $h = $f*1.3;
5301 $action = isset($param['onclick']) ?
$param['onclick'] : '';
5302 $this->pdf
->form_InputButton($name, $x, $y, $w, $h, $param['value'], $action, array());
5311 $this->maxX
= max($this->maxX
, $x+
$w);
5312 $this->maxY
= max($this->maxY
, $y+
$h);
5313 $this->maxH
= max($this->maxH
, $h);
5314 $this->pdf
->setX($x+
$w);
5316 $this->style
->load();
5317 $this->style
->FontSet();
5326 * @param array paramètres de l'élément de parsing
5329 function o_DRAW($param)
5331 if ($this->forOneLine
) return false;
5332 if ($this->DEBUG_actif
) $this->DEBUG_add('DRAW', true);
5334 $this->style
->save();
5335 $this->style
->analyse('draw', $param);
5336 $this->style
->FontSet();
5338 $align_object = null;
5339 if ($this->style
->value
['margin-auto']) $align_object = 'center';
5341 $over_w = $this->style
->value
['width'];
5342 $over_h = $this->style
->value
['height'];
5343 $this->style
->value
['old_maxX'] = $this->maxX
;
5344 $this->style
->value
['old_maxY'] = $this->maxY
;
5345 $this->style
->value
['old_maxH'] = $this->maxH
;
5347 $w = $this->style
->value
['width'];
5348 $h = $this->style
->value
['height'];
5350 if (!$this->style
->value
['position'])
5353 $w < ($this->pdf
->getW() - $this->pdf
->getlMargin()-$this->pdf
->getrMargin()) &&
5354 $this->pdf
->getX() +
$w>=($this->pdf
->getW() - $this->pdf
->getrMargin())
5356 $this->o_BR(array());
5359 ($h < ($this->pdf
->getH() - $this->pdf
->gettMargin()-$this->pdf
->getbMargin())) &&
5360 ($this->pdf
->getY() +
$h>=($this->pdf
->getH() - $this->pdf
->getbMargin())) &&
5361 !$this->isInOverflow
5363 $this->setNewPage();
5365 // en cas d'alignement => correction
5366 $old = $this->style
->getOldValues();
5367 $parent_w = $old['width'] ?
$old['width'] : $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
5371 if ($align_object=='center') $this->pdf
->setX($this->pdf
->getX() +
($parent_w-$w)*0.5);
5372 else if ($align_object=='right') $this->pdf
->setX($this->pdf
->getX() +
$parent_w-$w);
5375 $this->style
->setPosition();
5379 // en cas d'alignement => correction
5380 $old = $this->style
->getOldValues();
5381 $parent_w = $old['width'] ?
$old['width'] : $this->pdf
->getW() - $this->pdf
->getlMargin() - $this->pdf
->getrMargin();
5385 if ($align_object=='center') $this->pdf
->setX($this->pdf
->getX() +
($parent_w-$w)*0.5);
5386 else if ($align_object=='right') $this->pdf
->setX($this->pdf
->getX() +
$parent_w-$w);
5389 $this->style
->setPosition();
5397 // initialisation du style des bordures de la div
5398 $this->drawRectangle(
5399 $this->style
->value
['x'],
5400 $this->style
->value
['y'],
5401 $this->style
->value
['width'],
5402 $this->style
->value
['height'],
5403 $this->style
->value
['border'],
5404 $this->style
->value
['padding'],
5406 $this->style
->value
['background']
5410 $marge['l'] = $this->style
->value
['border']['l']['width'];
5411 $marge['r'] = $this->style
->value
['border']['r']['width'];
5412 $marge['t'] = $this->style
->value
['border']['t']['width'];
5413 $marge['b'] = $this->style
->value
['border']['b']['width'];
5415 $this->style
->value
['width'] -= $marge['l']+
$marge['r'];
5416 $this->style
->value
['height']-= $marge['t']+
$marge['b'];
5418 $over_w-= $marge['l']+
$marge['r'];
5419 $over_h-= $marge['t']+
$marge['b'];
5420 $this->pdf
->clippingPathOpen(
5421 $this->style
->value
['x']+
$marge['l'],
5422 $this->style
->value
['y']+
$marge['t'],
5423 $this->style
->value
['width'],
5424 $this->style
->value
['height']
5427 // limitation des marges aux dimensions du contenu
5428 $mL = $this->style
->value
['x']+
$marge['l'];
5429 $mR = $this->pdf
->getW() - $mL - $over_w;
5431 $x = $this->style
->value
['x']+
$marge['l'];
5432 $y = $this->style
->value
['y']+
$marge['t'];
5433 $this->saveMargin($mL, 0, $mR);
5434 $this->pdf
->setXY($x, $y);
5436 $this->isInDraw
= array(
5442 $this->pdf
->doTransform(array(1,0,0,1,$x,$y));
5450 * @param array paramètres de l'élément de parsing
5453 function c_DRAW($param)
5455 if ($this->forOneLine
) return false;
5457 $this->pdf
->undoTransform();
5458 $this->pdf
->clippingPathClose();
5460 $this->maxX
= $this->style
->value
['old_maxX'];
5461 $this->maxY
= $this->style
->value
['old_maxY'];
5462 $this->maxH
= $this->style
->value
['old_maxH'];
5465 $marge['l'] = $this->style
->value
['border']['l']['width'];
5466 $marge['r'] = $this->style
->value
['border']['r']['width'];
5467 $marge['t'] = $this->style
->value
['border']['t']['width'];
5468 $marge['b'] = $this->style
->value
['border']['b']['width'];
5470 $x = $this->style
->value
['x'];
5471 $y = $this->style
->value
['y'];
5472 $w = $this->style
->value
['width']+
$marge['l']+
$marge['r'];
5473 $h = $this->style
->value
['height']+
$marge['t']+
$marge['b'];
5475 if ($this->style
->value
['position']!='absolute')
5478 $this->pdf
->setXY($x+
$w, $y);
5481 $this->maxX
= max($this->maxX
, $x+
$w);
5482 $this->maxY
= max($this->maxY
, $y+
$h);
5483 $this->maxH
= max($this->maxH
, $h);
5488 $this->pdf
->setXY($this->style
->value
['xc'], $this->style
->value
['yc']);
5493 $block = ($this->style
->value
['display']!='inline' && $this->style
->value
['position']!='absolute');
5495 $this->style
->load();
5496 $this->style
->FontSet();
5497 $this->loadMargin();
5499 if ($block) $this->o_BR(array());
5500 if ($this->DEBUG_actif
) $this->DEBUG_add('DRAW', false);
5502 $this->isInDraw
= null;
5511 * @param array paramètres de l'élément de parsing
5514 function o_LINE($param)
5516 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'LINE');
5517 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5518 $this->style
->save();
5519 $styles = $this->style
->getSvgStyle('path', $param);
5520 $styles['fill'] = null;
5521 $style = $this->pdf
->svgSetStyle($styles);
5523 $x1 = isset($param['x1']) ?
$this->style
->ConvertToMM($param['x1'], $this->isInDraw
['w']) : 0.;
5524 $y1 = isset($param['y1']) ?
$this->style
->ConvertToMM($param['y1'], $this->isInDraw
['h']) : 0.;
5525 $x2 = isset($param['x2']) ?
$this->style
->ConvertToMM($param['x2'], $this->isInDraw
['w']) : 0.;
5526 $y2 = isset($param['y2']) ?
$this->style
->ConvertToMM($param['y2'], $this->isInDraw
['h']) : 0.;
5527 $this->pdf
->svgLine($x1, $y1, $x2, $y2);
5529 $this->pdf
->undoTransform();
5530 $this->style
->load();
5537 * @param array paramètres de l'élément de parsing
5540 function o_RECT($param)
5542 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'RECT');
5543 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5544 $this->style
->save();
5545 $styles = $this->style
->getSvgStyle('path', $param);
5546 $style = $this->pdf
->svgSetStyle($styles);
5548 $x = isset($param['x']) ?
$this->style
->ConvertToMM($param['x'], $this->isInDraw
['w']) : 0.;
5549 $y = isset($param['y']) ?
$this->style
->ConvertToMM($param['y'], $this->isInDraw
['h']) : 0.;
5550 $w = isset($param['w']) ?
$this->style
->ConvertToMM($param['w'], $this->isInDraw
['w']) : 0.;
5551 $h = isset($param['h']) ?
$this->style
->ConvertToMM($param['h'], $this->isInDraw
['h']) : 0.;
5553 $this->pdf
->svgRect($x, $y, $w, $h, $style);
5555 $this->pdf
->undoTransform();
5556 $this->style
->load();
5563 * @param array paramètres de l'élément de parsing
5566 function o_CIRCLE($param)
5568 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'CIRCLE');
5569 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5570 $this->style
->save();
5571 $styles = $this->style
->getSvgStyle('path', $param);
5572 $style = $this->pdf
->svgSetStyle($styles);
5574 $cx = isset($param['cx']) ?
$this->style
->ConvertToMM($param['cx'], $this->isInDraw
['w']) : 0.;
5575 $cy = isset($param['cy']) ?
$this->style
->ConvertToMM($param['cy'], $this->isInDraw
['h']) : 0.;
5576 $r = isset($param['r']) ?
$this->style
->ConvertToMM($param['r'], $this->isInDraw
['w']) : 0.;
5577 $this->pdf
->svgEllipse($cx, $cy, $r, $r, $style);
5579 $this->pdf
->undoTransform();
5580 $this->style
->load();
5587 * @param array paramètres de l'élément de parsing
5590 function o_ELLIPSE($param)
5592 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'ELLIPSE');
5593 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5594 $this->style
->save();
5595 $styles = $this->style
->getSvgStyle('path', $param);
5596 $style = $this->pdf
->svgSetStyle($styles);
5598 $cx = isset($param['cx']) ?
$this->style
->ConvertToMM($param['cx'], $this->isInDraw
['w']) : 0.;
5599 $cy = isset($param['cy']) ?
$this->style
->ConvertToMM($param['cy'], $this->isInDraw
['h']) : 0.;
5600 $rx = isset($param['ry']) ?
$this->style
->ConvertToMM($param['rx'], $this->isInDraw
['w']) : 0.;
5601 $ry = isset($param['rx']) ?
$this->style
->ConvertToMM($param['ry'], $this->isInDraw
['h']) : 0.;
5602 $this->pdf
->svgEllipse($cx, $cy, $rx, $ry, $style);
5604 $this->pdf
->undoTransform();
5605 $this->style
->load();
5613 * @param array paramètres de l'élément de parsing
5616 function o_POLYLINE($param)
5618 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'POLYGON');
5619 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5620 $this->style
->save();
5621 $styles = $this->style
->getSvgStyle('path', $param);
5622 $style = $this->pdf
->svgSetStyle($styles);
5624 $path = isset($param['points']) ?
$param['points'] : null;
5627 $path = str_replace(',', ' ', $path);
5628 $path = preg_replace('/[\s]+/', ' ', trim($path));
5630 // decoupage et nettoyage
5631 $path = explode(' ', $path);
5632 foreach($path as $k => $v)
5634 $path[$k] = trim($v);
5635 if ($path[$k]==='') unset($path[$k]);
5637 $path = array_values($path);
5640 for($k=0; $k<count($path); $k+
=2)
5642 $actions[] = array(($k ?
'L' : 'M') ,
5643 $this->style
->ConvertToMM($path[$k+
0], $this->isInDraw
['w']),
5644 $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['h']));
5648 $this->pdf
->svgPolygone($actions, $style);
5651 $this->pdf
->undoTransform();
5652 $this->style
->load();
5659 * @param array paramètres de l'élément de parsing
5662 function o_POLYGON($param)
5664 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'POLYGON');
5665 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5666 $this->style
->save();
5667 $styles = $this->style
->getSvgStyle('path', $param);
5668 $style = $this->pdf
->svgSetStyle($styles);
5670 $path = isset($param['points']) ?
$param['points'] : null;
5673 $path = str_replace(',', ' ', $path);
5674 $path = preg_replace('/[\s]+/', ' ', trim($path));
5676 // decoupage et nettoyage
5677 $path = explode(' ', $path);
5678 foreach($path as $k => $v)
5680 $path[$k] = trim($v);
5681 if ($path[$k]==='') unset($path[$k]);
5683 $path = array_values($path);
5686 for($k=0; $k<count($path); $k+
=2)
5688 $actions[] = array(($k ?
'L' : 'M') ,
5689 $this->style
->ConvertToMM($path[$k+
0], $this->isInDraw
['w']),
5690 $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['h']));
5692 $actions[] = array('z');
5694 $this->pdf
->svgPolygone($actions, $style);
5697 $this->pdf
->undoTransform();
5698 $this->style
->load();
5705 * @param array paramètres de l'élément de parsing
5708 function o_PATH($param)
5710 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'PATH');
5711 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5712 $this->style
->save();
5713 $styles = $this->style
->getSvgStyle('path', $param);
5714 $style = $this->pdf
->svgSetStyle($styles);
5716 $path = isset($param['d']) ?
$param['d'] : null;
5720 $path = str_replace(',', ' ', $path);
5721 $path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path);
5722 $path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path);
5723 $path = preg_replace('/[\s]+/', ' ', trim($path));
5724 $path = preg_replace('/ ([a-z]{2})/', '$1', $path);
5726 // decoupage et nettoyage
5727 $path = explode(' ', $path);
5728 foreach($path as $k => $v)
5730 $path[$k] = trim($v);
5731 if ($path[$k]==='') unset($path[$k]);
5733 $path = array_values($path);
5735 // conversion des unites
5738 for($k=0; $k<count($path); $k+
=count($action))
5741 $action[] = $path[$k];
5746 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['w']); // x1
5747 $action[] = $this->style
->ConvertToMM($path[$k+
2], $this->isInDraw
['h']); // y1
5748 $action[] = $this->style
->ConvertToMM($path[$k+
3], $this->isInDraw
['w']); // x2
5749 $action[] = $this->style
->ConvertToMM($path[$k+
4], $this->isInDraw
['h']); // y2
5750 $action[] = $this->style
->ConvertToMM($path[$k+
5], $this->isInDraw
['w']); // x
5751 $action[] = $this->style
->ConvertToMM($path[$k+
6], $this->isInDraw
['h']); // y
5758 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['w']); // x2
5759 $action[] = $this->style
->ConvertToMM($path[$k+
2], $this->isInDraw
['h']); // y2
5760 $action[] = $this->style
->ConvertToMM($path[$k+
3], $this->isInDraw
['w']); // x
5761 $action[] = $this->style
->ConvertToMM($path[$k+
4], $this->isInDraw
['h']); // y
5766 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['w']); // rx
5767 $action[] = $this->style
->ConvertToMM($path[$k+
2], $this->isInDraw
['h']); // ry
5768 $action[] = 1.*$path[$k+
3]; // angle de deviation de l'axe X
5769 $action[] = ($path[$k+
4]=='1') ?
1 : 0; // large-arc-flag
5770 $action[] = ($path[$k+
5]=='1') ?
1 : 0; // sweep-flag
5771 $action[] = $this->style
->ConvertToMM($path[$k+
6], $this->isInDraw
['w']); // x
5772 $action[] = $this->style
->ConvertToMM($path[$k+
7], $this->isInDraw
['h']); // y
5781 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['w']); // x
5782 $action[] = $this->style
->ConvertToMM($path[$k+
2], $this->isInDraw
['h']); // y
5787 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['w']); // x
5792 $action[] = $this->style
->ConvertToMM($path[$k+
1], $this->isInDraw
['h']); // y
5800 $actions[] = $action;
5804 $this->pdf
->svgPolygone($actions, $style);
5807 $this->pdf
->undoTransform();
5808 $this->style
->load();
5815 * @param array paramètres de l'élément de parsing
5818 function o_G($param)
5820 if (!$this->isInDraw
) HTML2PDF
::makeError(8, __FILE__
, __LINE__
, 'LINE');
5821 $this->pdf
->doTransform(isset($param['transform']) ?
$this->_prepareTransform($param['transform']) : null);
5822 $this->style
->save();
5823 $styles = $this->style
->getSvgStyle('path', $param);
5824 $style = $this->pdf
->svgSetStyle($styles);
5831 * @param array paramètres de l'élément de parsing
5834 function c_G($param)
5836 $this->pdf
->undoTransform();
5837 $this->style
->load();
5840 function _prepareTransform($transform)
5842 if (!$transform) return null;
5844 if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null;
5846 for($k=0; $k<count($match[0]); $k++
)
5848 $nom = strtolower($match[1][$k]);
5849 $val = explode(',', trim($match[2][$k]));
5850 foreach($val as $i => $j)
5851 $val[$i] = trim($j);
5856 if (!isset($val[0])) $val[0] = 1.; else $val[0] = 1.*$val[0];
5857 if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1];
5858 $actions[] = array($val[0],0,0,$val[1],0,0);
5862 if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->style
->ConvertToMM($val[0], $this->isInDraw
['w']);
5863 if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->style
->ConvertToMM($val[1], $this->isInDraw
['h']);
5864 $actions[] = array(1,0,0,1,$val[0],$val[1]);
5868 if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI
/180.;
5869 if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->style
->ConvertToMM($val[1], $this->isInDraw
['w']);
5870 if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->style
->ConvertToMM($val[2], $this->isInDraw
['h']);
5871 if ($val[1] ||
$val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]);
5872 $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0);
5873 if ($val[1] ||
$val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]);
5877 if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI
/180.;
5878 $actions[] = array(1,0,tan($val[0]),1,0,0);
5882 if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI
/180.;
5883 $actions[] = array(1,tan($val[0]),0,1,0,0);
5886 if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.;
5887 if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.;
5888 if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.;
5889 if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.;
5890 if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->style
->ConvertToMM($val[4], $this->isInDraw
['w']);
5891 if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->style
->ConvertToMM($val[5], $this->isInDraw
['h']);
5897 if (!$actions) return null;
5898 $m = $actions[0]; unset($actions[0]);
5899 foreach($actions as $n)
5902 $m[0]*$n[0]+
$m[2]*$n[1],
5903 $m[1]*$n[0]+
$m[3]*$n[1],
5904 $m[0]*$n[2]+
$m[2]*$n[3],
5905 $m[1]*$n[2]+
$m[3]*$n[3],
5906 $m[0]*$n[4]+
$m[2]*$n[5]+
$m[4],
5907 $m[1]*$n[4]+
$m[3]*$n[5]+
$m[5]
5914 function _getDrawNumber(&$lst, $key, $n=1, $correct=false)
5916 $res = array_fill(0, $n, 0);
5917 $tmp = isset($lst[$key]) ?
$lst[$key] : null;
5918 if (!$tmp) return $res;
5919 $tmp = explode(' ', trim(preg_replace('/[\s]+/', ' ', $tmp)));
5920 foreach($tmp as $k => $v)
5925 $res[$k] = $this->style
->ConvertToMM($v);
5929 $res[$k] = $this->style
->ConvertToMM($v, ($k%2
) ?
$this->isInDraw
['h'] : $this->isInDraw
['w']);
5936 * permet d'afficher un index automatique utilisant les bookmark
5938 * @param string titre du sommaire
5939 * @param int taille en mm de la fonte du titre du sommaire
5940 * @param int taille en mm de la fonte du texte du sommaire
5941 * @param boolean ajouter un bookmark spécifique pour l'index, juste avant le début de celui-ci
5942 * @param boolean afficher les numéros de page associés à chaque bookmark
5943 * @param int si présent : page où afficher le sommaire. sinon : nouvelle page
5944 * @param string nom de la fonte à utiliser
5947 function createIndex($titre = 'Index', $size_title = 20, $size_bookmark = 15, $bookmark_title = true, $display_page = true, $on_page = null, $font_name = 'helvetica')
5949 $old_page = $this->INDEX_NewPage($on_page);
5950 $this->pdf
->createIndex($this, $titre, $size_title, $size_bookmark, $bookmark_title, $display_page, $on_page, $font_name);
5951 if ($old_page) $this->pdf
->setPage($old_page);
5955 * nouvelle page pour l'index. ne pas utiliser directement. seul MyPDF doit l'utiliser !!!!
5957 * @param int page courante
5960 function INDEX_NewPage(&$page)
5964 $old_page = $this->pdf
->getPage();
5965 $this->pdf
->setPage($page);
5966 $this->pdf
->setXY($this->margeLeft
, $this->margeTop
);
5973 $this->setNewPage();
5979 * chargement du fichier de langue
5981 * @param string langue
5984 function textLOAD($langue)
5986 global $HTML2PDF_TEXTES;
5987 if (count($HTML2PDF_TEXTES)) return true;
5989 if (!preg_match('/^([a-z0-9]+)$/isU', $langue))
5991 echo 'ERROR : language code <b>'.$langue.'</b> incorrect.';
5995 $file = dirname(__FILE__
).'/langues/'.strtolower($langue).'.txt';
5996 if (!is_file($file))
5998 echo 'ERROR : language code <b>'.$langue.'</b> unknown.<br>';
5999 echo 'You can create the translation file <b>'.$file.'</b> and send it to me in order to integrate it into a future version.';
6004 $infos = file($file);
6005 foreach($infos as $val)
6008 $val = explode("\t", $val);
6009 if (count($val)<2) continue;
6011 $t_k = trim($val[0]); unset($val[0]);
6012 $t_v = trim(implode(' ', $val));
6013 if ($t_k && $t_v) $texte[$t_k] = $t_v;
6015 $HTML2PDF_TEXTES = $texte;
6021 * recuperer un texte precis
6023 * @param string code du texte
6026 function textGET($key)
6028 global $HTML2PDF_TEXTES;
6029 if (!isset($HTML2PDF_TEXTES[$key])) return '######';
6031 return $HTML2PDF_TEXTES[$key];
6035 * generer une erreur HTML2PDF
6037 * @param int numero de l'erreur
6038 * @param string nom du fichier ou c'est produit l'erreur
6039 * @param int numero de la ligne ou c'est produit l'erreur
6040 * @param mixed indications suplementaires sur l'erreur
6041 * @return string code HTML eventuel associé à l'erreur
6043 function makeError($err, $file, $line, $other = null, $html = '')
6049 $msg = (HTML2PDF
::textGET('err01'));
6050 $msg = str_replace('[[OTHER]]', $other, $msg);
6054 $msg = (HTML2PDF
::textGET('err02'));
6055 $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
6056 $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
6057 $msg = str_replace('[[OTHER_2]]', $other[2], $msg);
6061 $msg = (HTML2PDF
::textGET('err03'));
6062 $msg = str_replace('[[OTHER]]', $other, $msg);
6066 $msg = (HTML2PDF
::textGET('err04'));
6067 $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
6071 $msg = (HTML2PDF
::textGET('err05'));
6072 $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
6076 $msg = (HTML2PDF
::textGET('err06'));
6077 $msg = str_replace('[[OTHER]]', $other, $msg);
6081 $msg = (HTML2PDF
::textGET('err07'));
6085 $msg = (HTML2PDF
::textGET('err08'));
6086 $msg = str_replace('[[OTHER]]', $other, $msg);
6090 $msg = (HTML2PDF
::textGET('err09'));
6091 $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
6092 $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
6095 echo '<span style="color: #AA0000; font-weight: bold;">'.(HTML2PDF
::textGET('txt01')).$err.'</span><br>';
6096 echo (HTML2PDF
::textGET('txt02')).' '.$file.'<br>';
6097 echo (HTML2PDF
::textGET('txt03')).' '.$line.'<br>';
6101 if ($html) echo '<br>HTML : ...'.htmlentities($html).'...';