Académique Documents
Professionnel Documents
Culture Documents
php
/**
* Logiciel : HTML2PDF
* @version 3.31
*/
if (!defined('__CLASS_HTML2PDF__'))
define('__CLASS_HTML2PDF__', '3.31');
class HTML2PDF
var $defaultTop = 0;
var $defaultRight = 0;
var $defaultBottom = 0;
var $margeTop = 0;
var $margeRight = 0;
var $margeBottom = 0;
var $DEBUG_start_time = 0; //
var $DEBUG_last_time = 0; //
/**
* Constructeur
* @param array marges par defaut, dans l'ordre (left, top, right,
bottom)
* @return null
*/
function HTML2PDF($sens = 'P', $format = 'A4', $langue='fr', $marges_marges)
$this->page = 0;
$this->sens = $sens;
$this->format = $format;
$this->encoding = 'ISO-8859-15';
$this->firstPage = true;
$this->langue = strtolower($langue);
HTML2PDF::textLOAD($this->langue);
$this->style->FontSet();
$this->defLIST = array();
// initialisations diverses
$this->setTestTdInOnePage(true);
$this->setTestIsImage(true);
$this->setTestIsDeprecated(true);
$this->setDefaultFont(null);
// initialisation du parsing
$this->sub_part = false;
$this->setMargins();
$this->marges = array();
$this->lstChamps = array();
/**
* @return null
*/
function setModeDebug()
$this->DEBUG_actif = true;
$this->DEBUG_ok_usage = function_exists('memory_get_usage');
$this->DEBUG_ok_peak = function_exists('memory_get_peak_usage');
$this->DEBUG_add('Init debug');
}
/**
* @return null
*/
if ($level===true) $this->DEBUG_level++;
$this->DEBUG_stepline(
$nom,
number_format(($time - $this-
>DEBUG_start_time)*1000, 1, '.', ' ').' ms',
number_format(($time - $this-
>DEBUG_last_time)*1000, 1, '.', ' ').' ms',
$this->DEBUG_last_time = $time;
if ($level===false) $this->DEBUG_level--;
return true;
/**
* @return null
*/
/**
*/
$old = $this->encoding;
$this->encoding = $encoding;
$this->parsing->setEncoding($this->encoding);
return $old;
/**
*/
$old = $this->testTDin1page;
return $old;
/**
*/
$old = $this->testIsImage;
return $old;
}
/**
*/
$old = $this->testIsDeprecated;
return $old;
/**
* @param string nom de la fonte par defaut. si null : Arial pour fonte non
sp�cifi�e, et erreur pour fonte non existante
*/
$old = $this->defaultFont;
$this->defaultFont = $default;
$this->style->setDefaultFont($default);
return $old;
/**
* d�finir les marges par d�fault
* @return null
*/
if ($bottom===null) $bottom = 8;
$this->defaultLeft = $this->style->ConvertToMM($left.'mm');
$this->defaultTop = $this->style->ConvertToMM($top.'mm');
$this->defaultRight = $this->style->ConvertToMM($right.'mm');
$this->defaultBottom = $this->style->ConvertToMM($bottom.'mm');
/**
* @return null
*/
function setMargins()
$this->pdf->setcMargin(0);
$this->pdf->SetAutoPageBreak(false, $this->margeBottom);
$this->pageMarges = array();
$this->pageMarges[floor($this->margeTop*100)] = array($this->margeLeft,
$this->pdf->getW()-$this->margeRight);
/**
* @param float y
*/
function getMargins($y)
$y = floor($y*100);
$x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf-
>getrMargin());
if ($m_y<=$y) $x = $m_x;
return $x;
/**
* ajouter une marge suite a un float
* @param float x1
* @param float y1
* @param float x2
* @param float y2
* @return null
*/
$old1 = $this->getMargins($y1);
$old2 = $this->getMargins($y2);
$y1 = floor($y1*100);
$y2 = floor($y2*100);
if ($m_y<$y1) continue;
if ($m_y>$y2) break;
$this->pageMarges[$y1] = $old1;
$this->pageMarges[$y2] = $old2;
ksort($this->pageMarges);
$this->isAfterFloat = true;
/**
* @return null
*/
$this->pageMarges = array();
/**
* @return null
*/
function loadMargin()
$old = array_pop($this->marges);
if ($old)
$ml = $old['l'];
$mt = $old['t'];
$mr = $old['r'];
$mP = $old['page'];
else
$ml = $this->margeLeft;
$mt = 0;
$mr = $this->margeRight;
$this->pageMarges = $mP;
/**
* @return null
*/
}
/**
* @return null
*/
function saveMax()
/**
* @return null
*/
function loadMax()
$old = array_pop($this->maxSave);
if ($old)
$this->maxX = $old[0];
$this->maxY = $old[1];
$this->maxH = $old[2];
$this->maxE = $old[3];
else
$this->maxX = 0;
$this->maxY = 0;
$this->maxH = 0;
$this->maxE = 0;
/**
* @return null
*/
function setPageHeader()
$OLD_parse_pos = $this->parse_pos;
$OLD_parse_code = $this->parsing->code;
$this->parse_pos = 0;
$this->parsing->code = $this->subHEADER;
$this->makeHTMLcode();
$this->parse_pos = $OLD_parse_pos;
$this->parsing->code = $OLD_parse_code;
/**
* @return null
*/
function setPageFooter()
$OLD_parse_pos = $this->parse_pos;
$OLD_parse_code = $this->parsing->code;
$this->parse_pos = 0;
$this->parsing->code = $this->subFOOTER;
$this->isInFooter = true;
$this->makeHTMLcode();
$this->isInFooter = false;
$this->parse_pos = $OLD_parse_pos;
$this->parsing->code = $OLD_parse_code;
/**
* @return null
*/
$this->pdf->Ln($h);
$this->setNewPositionForNewLine($curr);
}
/**
* @return null
*/
$this->firstPage = false;
$this->maxY = 0;
$this->maxX = 0;
$this->maxH = 0;
$this->pdf->AddPage($this->sens, $this->format);
$this->page++;
if (is_array($this->background))
{
$this->pdf->setMyFillColor($this-
>background['color']);
$this->pdf->Image($this->background['img'], $this-
>background['posX'], $this->background['posY'], $this->background['width']);
$this->setPageHeader();
$this->setPageFooter();
$this->setMargins();
$this->pdf->setY($this->margeTop);
$this->setNewPositionForNewLine($curr);
$this->maxH = 0;
/**
*/
$this->pdf->setX($lx);
$wMax = $rx-$lx;
$this->currentH = 0;
// $this->pdf->setWordSpacing(0);
return null;
/*
if (
$this->style->value['text-align']!='right' &&
$this->style->value['text-align']!='center' &&
$this->style->value['text-align']!='justify'
// $this->pdf->setWordSpacing(0);
return null;
*/
$sub = null;
$this->createSubHTML($sub);
$sub->saveMargin(0, 0, $sub->pdf->getW()-$wMax);
$sub->forOneLine = true;
$sub->parse_pos = $this->parse_pos;
$sub->parsing->code = $this->parsing->code;
if ($curr!==null && $sub->parsing->code[$this->parse_pos]['name']=='write')
$txt = $sub->parsing->code[$this->parse_pos]['param']['txt'];
$sub->parsing->code[$this->parse_pos]['param']['txt'] = substr($txt,
$curr);
else
$sub->parse_pos++;
$res = null;
$todo = $sub->parsing->code[$sub->parse_pos];
$res = $sub->loadAction($todo);
if (!$res) break;
$this->destroySubHTML($sub);
if ($this->style->value['text-align']=='center')
$this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
elseif ($this->style->value['text-align']=='right')
$this->pdf->setX($rx-$w-0.01);
else
$this->pdf->setX($lx);
$this->currentH = $h;
/*
$this->pdf->setWordSpacing(($wMax-$w)/($e-1));
else
$this->pdf->setWordSpacing(0);
*/
/**
* r�cup�ration du PDF
* true : equivalent � I
* false : equivalent � S
* 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.
* F : sauver dans un fichier local, avec le nom indiqu� dans name (peut inclure un
r�pertoire).
*/
{
// nettoyage
if ($this->DEBUG_actif)
$this->DEBUG_add('Before output');
$this->pdf->Close();
exit;
if ($name=='') $name='document.pdf';
// verification de la destination
$dest = strtoupper($dest);
// verification du nom
if (strtolower(substr($name, -4))!='.pdf')
exit;
}
/**
* @return null
*/
// calcul de la largueur
if ($this->style->value['width'])
$marge = $cellmargin*2;
else
$marge = $this->margeLeft+$this->margeRight;
//clonage
$this->sens,
$this->format,
$this->langue,
array($this-
>defaultLeft,$this->defaultTop,$this->defaultRight,$this->defaultBottom)
);
$sub_html->setIsSubPart();
$sub_html->setEncoding($this->encoding);
$sub_html->setTestTdInOnePage($this->testTDin1page);
$sub_html->setTestIsImage($this->testIsImage);
$sub_html->setTestIsDeprecated($this->testIsDeprecated);
$sub_html->setDefaultFont($this->defaultFont);
$sub_html->style->css = $this->style->css;
$sub_html->style->css_keys = $this->style->css_keys;
$sub_html->pdf->cloneFontFrom($this->pdf);
$sub_html->style->table = $this->style->table;
$sub_html->style->value = $this->style->value;
$sub_html->style->setOnlyLeft();
$sub_html->setNewPage($this->format, $this->sens);
$sub_html->maxX = 0;
$sub_html->maxY = 0;
$sub_html->maxH = 0;
$sub_html->pdf->setXY(0, 0);
/**
* @return null
*/
$this->saveMargin(0, 0, $marge);
$this->defLIST = $defLIST;
$this->page = $page;
$this->pdf->setXY(0, 0);
$this->style->FontSet();
function setIsSubPart()
$this->isSubPart = true;
/**
* @return null
*/
function destroySubHTML(&$sub_html)
unset($sub_html);
$sub_html = null;
/**
*/
function listeArab2Rom($nb_ar)
{
$nb_b10 = array('I','X','C','M');
$nb_b5 = array('V','L','D');
$nb_ro = '';
$chiffre=floor($nb_ar/pow(10,$i));
if($chiffre>=1)
$nb_ar=$nb_ar-$chiffre*pow(10,$i);
if($chiffre<=3)
$nb_ro=$nb_ro.$nb_b10[$i];
else if($chiffre==9)
$nb_ro=$nb_ro.$nb_b10[$i].$nb_b10[$i+1];
elseif($chiffre==4)
$nb_ro=$nb_ro.$nb_b10[$i].$nb_b5[$i];
else
$nb_ro=$nb_ro.$nb_b5[$i];
for($j=$chiffre-5; $j>=1; $j--)
$nb_ro=$nb_ro.$nb_b10[$i];
return $nb_ro;
/**
* @return null
*/
function listeAddLi()
$this->defLIST[count($this->defLIST)-1]['nb']++;
/**
*/
function listeGetLi()
$im = $this->defLIST[count($this->defLIST)-1]['img'];
$st = $this->defLIST[count($this->defLIST)-1]['style'];
$nb = $this->defLIST[count($this->defLIST)-1]['nb'];
switch($st)
case 'none':
case 'upper-alpha':
case 'lower-alpha':
$str = '';
while($nb>26)
$str = chr(96+$nb%26).$str;
$nb = floor($nb/26);
$str = chr(96+$nb).$str;
case 'upper-roman':
case 'lower-roman':
$str = $this->listeArab2Rom($nb);
case 'decimal':
return array('helvetica', false, $nb.'.');
case 'square':
case 'circle':
case 'disc':
default:
/**
* @return null
*/
if ($img)
$img = $match[1];
else
$img = null;
else
$img = null;
if (!$style)
/**
* @return null
*/
function listeDelLevel()
if (count($this->defLIST))
unset($this->defLIST[count($this->defLIST)-1]);
$this->defLIST = array_values($this->defLIST);
/**
*
* @param string code HTML � convertir
* @return null
*/
if (preg_match('/<body/isU', $html))
$html = $this->getHtmlFromPage($html);
// End:0009582:
if ($vue) $this->vueHTML($html);
// parsing
$this->sub_pdf = false;
$this->style->readStyle($html);
$this->parsing->setHTML($html);
$this->parsing->parse();
$this->makeHTMLcode();
/**
*/
function getHtmlFromPage($html)
// extraction du contenu
$content = '<page'.$res[1];
$content = $content[0].'</page>';
foreach($match[0] as $src)
$content = $src.'</link>'.$content;
foreach($match[0] as $src)
$content = $src.$content;
return $content;
/**
* @return null
*/
function makeHTMLcode()
for($this->parse_pos=0; $this->parse_pos<count($this->parsing->code);
$this->parse_pos++)
// r�cup�ration de l'�l�ment
$todo = $this->parsing->code[$this->parse_pos];
$tag_open = $todo['name'];
$this->sub_part = true;
$this->temp_pos = $this->parse_pos;
while(isset($this->parsing->code[$this->temp_pos]) && !
($this->parsing->code[$this->temp_pos]['name']==$tag_open && $this->parsing->code[$this-
>temp_pos]['close']))
{
$this->loadAction($this->parsing->code[$this-
>temp_pos]);
$this->temp_pos++;
if (isset($this->parsing->code[$this->temp_pos]))
$this->loadAction($this->parsing->code[$this->temp_pos]);
$this->sub_part = false;
$this->loadAction($todo);
/**
* @return null
*/
function vueHTML($content)
$content = preg_replace('/<page_header([^>]*)>/isU',
'<hr>'.HTML2PDF::textGET('vue01').' : $1<hr><div$1>', $content);
$content = preg_replace('/<page_footer([^>]*)>/isU',
'<hr>'.HTML2PDF::textGET('vue02').' : $1<hr><div$1>', $content);
$content = preg_replace('/<page([^>]*)>/isU',
'<hr>'.HTML2PDF::textGET('vue03').' : $1<hr><div$1>', $content);
$content = preg_replace('/<\/page([^>]*)>/isU',
'</div><hr>', $content);
$content = preg_replace('/<bookmark([^>]*)>/isU',
'<hr>bookmark : $1<hr>', $content);
$content = preg_replace('/<barcode([^>]*)>/isU',
'<hr>barcode : $1<hr>', $content);
<html>
<head>
<title>'.HTML2PDF::textGET('vue04').' HTML</title>
</head>
'.$content.'
</body>
</html>';
exit;
/**
* @return null
*/
function loadAction($row)
// nom de l'action
// parametres de l'action
$param = $row['param'];
$this->setNewPage();
// lancement de l'action
if (is_callable(array(&$this, $fnc)))
$res = $this->{$fnc}($param);
$this->previousCall = $fnc;
return $res;
else
return false;
/**
* balise : PAGE
* mode : OUVERTURE
* @return null
*/
function o_PAGE($param)
$this->maxH = 0;
if ($newPageSet)
$this->subHEADER = array();
$this->subFOOTER = array();
$orientation = '';
if (isset($param['orientation']))
$param['orientation'] = strtolower($param['orientation']);
if ($param['orientation']=='p')
$orientation = 'P';
if ($param['orientation']=='l')
$orientation = 'L';
$format = null;
if (isset($param['format']))
$format = strtolower($param['format']);
$format = array(intval($match[1]),
intval($match[2]));
$background = array();
if (isset($param['backimg']))
$background['img'] = isset($param['backimg'])
? $param['backimg'] : ''; // nom de l'image
$background['posX'] = isset($param['backimgx'])
? $param['backimgx'] : 'center'; // position horizontale de l'image
$background['posY'] = isset($param['backimgy'])
? $param['backimgy'] : 'middle'; // position verticale de l'image
$background['width'] = isset($param['backimgw']) ?
$param['backimgw'] : '100%'; // taille de l'image (100% = largueur de la feuille)
if ($background['posX']=='right')$background['posX'] =
'100%';
if ($background['posY']=='top') $background['posY']
= '0%';
if ($background['posY']=='middle') $background['posY']
= '50%';
if ($background['posY']=='bottom') $background['posY']
= '100%';
if ($background['img'])
$infos=@GetImageSize($background['img']);
if (count($infos)>1)
$Wi = $this->style-
>ConvertToMM($background['width'], $this->pdf->getW());
$Hi = $Wi*$infos[1]/$infos[0];
$background['width'] = $Wi;
$background['posX'] = $this-
>style->ConvertToMM($background['posX'], $this->pdf->getW() - $Wi);
$background['posY'] = $this-
>style->ConvertToMM($background['posY'], $this->pdf->getH() - $Hi);
else
$background = array();
else
$background = array();
$background['top'] = isset($param['backtop'])
? $param['backtop'] : '0';
$background['bottom'] = isset($param['backbottom']) ?
$param['backbottom'] : '0';
$background['left'] = isset($param['backleft'])
? $param['backleft'] : '0';
$background['right'] = isset($param['backright']) ?
$param['backright'] : '0';
if (preg_match('/^([0-9]*)$/isU', $background['top']))
$background['top'] .= 'mm';
if (preg_match('/^([0-9]*)$/isU', $background['bottom']))
$background['bottom'] .= 'mm';
if (preg_match('/^([0-9]*)$/isU', $background['left']))
$background['left'] .= 'mm';
if (preg_match('/^([0-9]*)$/isU', $background['right']))
$background['right'] .= 'mm';
$background['top'] = $this->style-
>ConvertToMM($background['top'], $this->pdf->getH());
$background['bottom'] = $this->style-
>ConvertToMM($background['bottom'], $this->pdf->getH());
$background['left'] = $this->style-
>ConvertToMM($background['left'], $this->pdf->getW());
$background['right'] = $this->style-
>ConvertToMM($background['right'], $this->pdf->getW());
$res = false;
$background['color'] = isset($param['backcolor']) ? $this-
>style->ConvertToColor($param['backcolor'], $res) : null;
$this->style->save();
$this->style->analyse('PAGE', $param);
$this->style->setPosition();
$this->style->FontSet();
// nouvelle page
// footer automatique
if (isset($param['footer']))
else
$page = null;
$date = null;
$heure = null;
$form = null;
}
else
$this->style->save();
$this->style->analyse('PAGE', $param);
$this->style->setPosition();
$this->style->FontSet();
$this->setNewPage();
return true;
/**
* balise : PAGE
* mode : FERMETURE
* @return null
*/
function c_PAGE($param)
$this->maxH = 0;
$this->style->load();
$this->style->FontSet();
function o_PAGE_HEADER($param)
$this->subHEADER = array();
$todo = $this->parsing->code[$this->parse_pos];
if ($todo['name']=='page_header')
$todo['name']='page_header_sub';
$this->subHEADER[] = $todo;
if (strtolower($todo['name'])=='page_header_sub' &&
$todo['close']) break;
$this->setPageHeader();
return true;
function o_PAGE_FOOTER($param)
$this->subFOOTER = array();
$todo = $this->parsing->code[$this->parse_pos];
if ($todo['name']=='page_footer') $todo['name']='page_footer_sub';
$this->subFOOTER[] = $todo;
$this->setPageFooter();
return true;
function o_PAGE_HEADER_SUB($param)
// sauvegarde de l'�tat
$this->subSTATES = array();
$this->subSTATES['x'] = $this->pdf->getX();
$this->subSTATES['y'] = $this->pdf->getY();
$this->subSTATES['s'] = $this->style->value;
$this->subSTATES['t'] = $this->style->table;
$this->subSTATES['ml'] = $this->margeLeft;
$this->subSTATES['mr'] = $this->margeRight;
$this->subSTATES['mt'] = $this->margeTop;
$this->subSTATES['mb'] = $this->margeBottom;
$this->subSTATES['mp'] = $this->pageMarges;
$this->pageMarges = array();
$this->margeLeft = $this->defaultLeft;
$this->margeRight = $this->defaultRight;
$this->margeTop = $this->defaultTop;
$this->margeBottom = $this->defaultBottom;
$this->pdf->SetAutoPageBreak(false, $this->margeBottom);
$this->pdf->setXY($this->defaultLeft, $this->defaultTop);
$this->style->initStyle();
$this->style->resetStyle();
$this->style->table = array();
$this->style->save();
$this->style->analyse('page_header_sub', $param);
$this->style->setPosition();
$this->style->FontSet();
$this->setNewPositionForNewLine();
return true;
function c_PAGE_HEADER_SUB($param)
$this->style->load();
// retablissement de l'etat
$this->style->value = $this->subSTATES['s'];
$this->style->table = $this->subSTATES['t'];
$this->pageMarges = $this->subSTATES['mp'];
$this->margeLeft = $this->subSTATES['ml'];
$this->margeRight = $this->subSTATES['mr'];
$this->margeTop = $this-
>subSTATES['mt'];
$this->margeBottom = $this->subSTATES['mb'];
$this->pdf->setbMargin($this->margeBottom);
$this->pdf->SetAutoPageBreak(false, $this->margeBottom);
$this->pdf->setXY($this->subSTATES['x'], $this->subSTATES['y']);
$this->style->FontSet();
$this->maxH = 0;
return true;
function o_PAGE_FOOTER_SUB($param)
$this->subSTATES = array();
$this->subSTATES['x'] = $this->pdf->getX();
$this->subSTATES['y'] = $this->pdf->getY();
$this->subSTATES['s'] = $this->style->value;
$this->subSTATES['t'] = $this->style->table;
$this->subSTATES['ml'] = $this->margeLeft;
$this->subSTATES['mr'] = $this->margeRight;
$this->subSTATES['mt'] = $this->margeTop;
$this->subSTATES['mb'] = $this->margeBottom;
$this->subSTATES['mp'] = $this->pageMarges;
// nouvel etat pour le footer
$this->pageMarges = array();
$this->margeLeft = $this->defaultLeft;
$this->margeRight = $this->defaultRight;
$this->margeTop = $this->defaultTop;
$this->margeBottom = $this->defaultBottom;
$this->pdf->SetAutoPageBreak(false, $this->margeBottom);
$this->pdf->setXY($this->defaultLeft, $this->defaultTop);
$this->style->initStyle();
$this->style->resetStyle();
$this->style->table = array();
$sub = null;
$this->CreateSubHTML($sub);
$sub->parsing->code = $this->parsing->getLevel($this->parse_pos);
$sub->MakeHTMLcode();
$this->destroySubHTML($sub);
$this->style->save();
$this->style->analyse('page_footer_sub', $param);
$this->style->setPosition();
$this->style->FontSet();
$this->setNewPositionForNewLine();
return true;
function c_PAGE_FOOTER_SUB($param)
$this->style->load();
$this->style->value = $this->subSTATES['s'];
$this->style->table = $this->subSTATES['t'];
$this->pageMarges = $this->subSTATES['mp'];
$this->margeLeft = $this->subSTATES['ml'];
$this->margeRight = $this->subSTATES['mr'];
$this->margeTop = $this-
>subSTATES['mt'];
$this->margeBottom = $this->subSTATES['mb'];
$this->pdf->SetAutoPageBreak(false, $this->margeBottom);
$this->pdf->setXY($this->subSTATES['x'], $this->subSTATES['y']);
$this->style->FontSet();
$this->maxH = 0;
return true;
}
/**
* balise : NOBREAK
* mode : OUVERTURE
* @return null
*/
function o_NOBREAK($param)
$this->maxH = 0;
// et voir si ca rentre
$sub = null;
$this->CreateSubHTML($sub);
$sub->parsing->code = $this->parsing->getLevel($this->parse_pos);
$sub->MakeHTMLcode();
$y = $this->pdf->getY();
if (
$y + $sub->maxY>=($this->pdf->getH() - $this->pdf-
>getbMargin())
$this->setNewPage();
$this->destroySubHTML($sub);
return true;
}
/**
* balise : NOBREAK
* mode : FERMETURE
* @return null
*/
function c_NOBREAK($param)
$this->maxH = 0;
return true;
/**
* balise : DIV
* mode : OUVERTURE
* @return null
*/
$this->style->analyse($other, $param);
$this->style->FontSet();
if (isset($param['moveTop'])) $this->style->value['margin']['t'] +=
$param['moveTop'];
if (isset($param['moveLeft'])) $this->style->value['margin']['l'] +=
$param['moveLeft'];
if (isset($param['moveDown'])) $this->style->value['margin']['b']
+= $param['moveDown'];
$align_object = null;
$marge = array();
$level = $this->parsing->getLevel($this->parse_pos);
if (count($level))
$sub = null;
$this->CreateSubHTML($sub);
$sub->parsing->code = $level;
$sub->MakeHTMLcode();
$w = $sub->maxX;
$h = $sub->maxY;
$this->destroySubHTML($sub);
$w_reel = $w;
$h_reel = $h;
$w+= $marge['l']+$marge['r']+0.001;
$h+= $marge['t']+$marge['b']+0.001;
if ($this->style->value['overflow']=='hidden')
$overflow = true;
$this->style->value['old_maxX'] = $this->maxX;
$this->style->value['old_maxY'] = $this->maxY;
$this->style->value['old_maxH'] = $this->maxH;
$this->style->value['old_overflow'] = $this->isInOverflow;
$this->isInOverflow = true;
}
else
$over_w = null;
$over_h = null;
$overflow = false;
switch($this->style->value['rotate'])
case 90:
unset($tmp);
$w = $this->style->value['height'];
$h = $this->style->value['width'];
$t_x =-$h;
$t_y = 0;
break;
case 180:
$w = $this->style->value['width'];
$h = $this->style->value['height'];
$t_x = -$w;
$t_y = -$h;
break;
case 270:
unset($tmp);
$w = $this->style->value['height'];
$h = $this->style->value['width'];
$t_x = 0;
$t_y =-$w;
break;
default:
$w = $this->style->value['width'];
$h = $this->style->value['height'];
$t_x = 0;
$t_y = 0;
break;
if (!$this->style->value['position'])
if (
$this->o_BR(array());
if (
($this->pdf->getY() + $h>=($this->pdf->getH() -
$this->pdf->getbMargin())) &&
!$this->isInOverflow
)
$this->setNewPage();
$old = $this->style->getOldValues();
if ($parent_w>$w)
if ($align_object=='center') $this->pdf-
>setX($this->pdf->getX() + ($parent_w-$w)*0.5);
$this->style->setPosition();
else
$old = $this->style->getOldValues();
if ($parent_w>$w)
if ($align_object=='center') $this->pdf-
>setX($this->pdf->getX() + ($parent_w-$w)*0.5);
}
$this->style->setPosition();
$this->saveMax();
$this->maxX = 0;
$this->maxY = 0;
$this->maxH = 0;
$this->maxE = 0;
if ($this->style->value['rotate'])
$this->pdf->startTransform();
$this->pdf->setRotation($this->style->value['rotate']);
$this->pdf->setTranslate($t_x, $t_y);
$this->drawRectangle(
$this->style->value['x'],
$this->style->value['y'],
$this->style->value['width'],
$this->style->value['height'],
$this->style->value['border'],
$this->style->value['padding'],
0,
$this->style->value['background']
);
$marge = array();
$this->style->value['width'] -= $marge['l']+$marge['r'];
$this->style->value['height']-= $marge['t']+$marge['b'];
$x_corr = 0;
$y_corr = 0;
switch($this->style->value['text-align'])
if ($x_corr>0) $x_corr=0;
switch($this->style->value['vertical-align'])
if ($overflow)
$over_w-= $marge['l']+$marge['r'];
$over_h-= $marge['t']+$marge['b'];
$this->pdf->clippingPathOpen(
$this->style->value['x']+$marge['l'],
$this->style->value['y']+$marge['t'],
$this->style->value['width'],
$this->style->value['height']
);
$this->style->value['x']+= $x_corr;
$mL = $this->style->value['x']+$marge['l'];
else
$mL = $this->style->value['x']+$marge['l'];
$x = $this->style->value['x']+$marge['l'];
$y = $this->style->value['y']+$marge['t']+$y_corr;
$this->saveMargin($mL, 0, $mR);
$this->pdf->setXY($x, $y);
$this->setNewPositionForNewLine();
return true;
* balise : FIELDSET
* mode : OUVERTURE
* @return null
*/
function o_FIELDSET($param)
$this->style->save();
$this->style->analyse('fieldset', $param);
$todo = $this->parsing->code[$temp_pos];
$legend_open_pos = $temp_pos;
$sub = null;
$this->CreateSubHTML($sub);
$sub->parsing->code = $this->parsing->getLevel($temp_pos
- 1);
$res = null;
for($sub->parse_pos = 0; $sub->parse_pos<count($sub-
>parsing->code); $sub->parse_pos++)
$todo = $sub->parsing->code[$sub->parse_pos];
$sub->loadAction($todo);
break;
$legendH = $sub->maxY;
$this->destroySubHTML($sub);
$param['moveTop'] = $legendH / 2;
$this->parsing->code[$legend_open_pos]['param']
['moveTop'] = - ($legendH / 2 + $move);
$this->parsing->code[$legend_open_pos]['param']
['moveLeft'] = 2 - $this->style->value['border']['l']['width'] - $this->style->value['padding']['l'];
$this->parsing->code[$legend_open_pos]['param']
['moveDown'] = $move;
break;
$this->style->load();
/**
* balise : DIV
* mode : FERMETURE
* @return null
*/
if ($this->style->value['overflow']=='hidden')
$this->maxX = $this->style->value['old_maxX'];
$this->maxY = $this->style->value['old_maxY'];
$this->maxH = $this->style->value['old_maxH'];
$this->isInOverflow = $this->style->value['old_overflow'];
$this->pdf->clippingPathClose();
if ($this->style->value['rotate'])
$this->pdf->stopTransform();
$marge = array();
$y = $this->style->value['y'];
$w = $this->style->value['width']+$marge['l']+$marge['r']+$this->style-
>value['margin']['r'];
$h = $this->style->value['height']+$marge['t']+$marge['b']+$this->style-
>value['margin']['b'];
switch($this->style->value['rotate'])
case 90:
break;
case 270:
break;
default:
break;
if ($this->style->value['position']!='absolute')
// position
$this->pdf->setXY($x+$w, $y);
// position MAX
}
else
// position
$this->pdf->setXY($this->style->value['xc'], $this->style->value['yc']);
$this->loadMax();
$this->style->load();
$this->style->FontSet();
$this->loadMargin();
if ($block) $this->o_BR(array());
return true;
/**
* balise : BARCODE
* mode : OUVERTURE
* @return null
*/
function o_BARCODE($param)
if (!isset($param['value'])) $param['value'] = 0;
$lst_barcode = array();
$lst_barcode['EAN13'] = 'EAN13';
$lst_barcode['UPCA'] = 'UPC_A';
$lst_barcode['C39'] = 'CODE39';
$lst_barcode['UPC_A'] = 'UPC_A';
$lst_barcode['CODE39'] = 'CODE39';
$param['type'] = strtoupper($param['type']);
if (!isset($lst_barcode[$param['type']])) $param['type']=='C39';
$param['type'] = $lst_barcode[$param['type']];
$param['style']['background-color'] = $param['style']['color'];
$this->style->save();
$this->style->analyse('barcode', $param);
$this->style->setPosition();
$this->style->FontSet();
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$txt = ($param['label']!=='none');
$this->maxE++;
$this->pdf->setXY($x+$infos[0], $y);
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : BARCODE
* mode : FERMETURE
* @return null
*/
function c_BARCODE($param)
// completement inutile
return true;
/**
* balise : QRCODE
* mode : OUVERTURE
* @return null
*/
function o_QRCODE($param)
$msg = '
<h1>QRCODE Tag</h1>
<pre>
<b>ATTENTION :</b>
Vous devez t�l�charger la librairie "QR-code generator >=0.99" (sous licence LGPL)
You have to download the librairy "QR-code generator >=0.99" (under LGPL licence)
</pre>';
$file_class = dirname(__FILE__).'/qrcode/qrcode.class.php';
require_once($file_class);
if (!isset($param['value']))
$param['value'] = '';
if (!isset($param['ec']))
$param['ec'] = 'H';
if (!isset($param['style']['color']))
$param['style']['color'] = '#000000';
if (!isset($param['style']['background-color'])) $param['style']
['background-color'] = '#FFFFFF';
if (isset($param['style']['border']))
$borders = $param['style']['border']!='none';
unset($param['style']['border']);
else
$borders = true;
$this->style->analyse('qrcode', $param);
$this->style->setPosition();
$this->style->FontSet();
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$w = $this->style->value['width'];
$h = $this->style->value['height'];
$color = $this->style->value['color'];
$color[0] = floor($color[0]*255.);
$color[1] = floor($color[1]*255.);
$color[2] = floor($color[2]*255.);
$background = $this->style->value['background']['color'];
$background[0] = floor($background[0]*255.);
$background[1] = floor($background[1]*255.);
$background[2] = floor($background[2]*255.);
if (!$borders) $qrcode->disableBorder();
unset($qrcode);
}
// position maximale globale
$this->pdf->setX($x+$size);
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : QRCODE
* mode : FERMETURE
* @return null
*/
function c_QRCODE($param)
// completement inutile
return true;
/**
* balise : BOOKMARK
* mode : OUVERTURE
*
* @return null
*/
function o_BOOKMARK($param)
if ($level<0) $level = 0;
return true;
/**
* balise : BOOKMARK
* mode : FERMETURE
* @return null
*/
function c_BOOKMARK($param)
// completement inutile
return true;
function getElementY($h)
{
if ($this->sub_part || $this->isSubPart || !$this->currentH || $this-
>currentH<$h)
return 0;
return ($this->currentH-$h)*0.8;
/**
* balise : WRITE
* mode : OUVERTURE
* @return null
*/
function o_WRITE($param)
$fill = false;
$txt = $param['txt'];
if ($this->isAfterFloat)
$txt = ltrim($txt);
$this->isAfterFloat = false;
if ($this->style->value['text-transform']=='capitalize')
$txt = ucwords($txt);
else if ($this->style->value['text-transform']=='uppercase')
$txt = strtoupper($txt);
else if ($this->style->value['text-transform']=='lowercase')
$txt = strtolower($txt);
// tailles du texte
$h = 1.08*$this->style->value['font-size'];
$dh = $h*$this->style->value['mini-decal'];
$lh = $this->style->getLineHeight();
// identification de l'alignement
$align = 'L';
if ($this->style->value['text-align']=='li_right')
$w = $this->style->value['width'];
$align = 'R';
$w = 0;
$w+= $words[$k][1];
}
$w+= $space*(count($words)-1);
$curr_pos = 0;
// position dans le texte
$curr_max = strlen($txt); //
taille maxi du texte
$maxX = 0;
// plus grande largeur du texte apres retour � la ligne
$x = $this->pdf->getX(); // position
du texte
$y = $this->pdf->getY();
$dy = $this->getElementY($lh);
$nb = 0;
// nbr de lignes d�coup�es
// tant que ca ne rentre pas sur la ligne et qu'on a du texte => on d�coupe
$i=0;
$str = $words[0];
$add = false;
while(($x+$str[1])<$right)
$i++;
$add = true;
array_shift($words);
$old = $str;
if (!count($words)) break;
$str[1]+= $space+$words[0][1];
$str = $old;
$str = $words[0];
array_shift($words);
$i++;
$add = true;
/*
if ($this->pdf->ws)
$this->pdf->CurrentFont['cw'][' ']*=(1.+$this->pdf->ws);
$wc = $str[1];
}
*/
if (strlen($str[0]))
$this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
$this->pdf->setXY($this->pdf->getX(), $y);
$w-= $str[1];
$y = $this->pdf->getY();
$x = $this->pdf->getX();
$dy = $this->getElementY($lh);
if (count($words))
if ($this->forOneLine)
$this->maxE+= $i+1;
return null;
// retour � la ligne
$this->o_BR(array('style' => ''), $curr_pos);
$y = $this->pdf->getY();
$x = $this->pdf->getX();
$dy = $this->getElementY($lh);
$y = $this->pdf->getY();
$x = $this->pdf->getX();
$dy = $this->getElementY($lh);
$nb++;
if ($nb>1000)
}
}
// si il reste du text apres d�coupe, c'est qu'il rentre direct => on l'affiche
if (count($words))
$txt = ''; foreach($words as $k => $word) $txt.= ($k ? ' ' : '').
$word[0];
/*
if ($this->pdf->ws)
$this->pdf->CurrentFont['cw'][' ']*=(1.+$this->pdf->ws);
$w = $this->pdf->GetStringWidth($txt);
*/
$this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
$this->pdf->setXY($this->pdf->getX(), $y);
$this->maxE+= count($words);
$maxY = $this->pdf->getY()+$h;
/**
* @return null
*/
$infos=@GetImageSize($src);
if (count($infos)<2)
if ($this->testIsImage)
return false;
$src = null;
$wi = $infos[0]/$this->pdf->getK();
$hi = $infos[1]/$this->pdf->getK();
$w = $this->style->value['width'];
$h = $this->style->value['height'];
else if ($this->style->value['width'])
$w = $this->style->value['width'];
$h = $hi*$w/$wi;
else if ($this->style->value['height'])
$h = $this->style->value['height'];
$w = $wi*$h/$hi;
else
$w = 72./96.*$wi;
$h = 72./96.*$hi;
// detection du float
$float = $this->style->getFloat();
if (!$this->o_BR(array()))
return false;
// position d'affichage
$x = $this->pdf->getX();
$y = $this->pdf->getY();
// si l'image ne rentre pas dans la ligne => nouvelle ligne
$this->setNewLine($hnl);
$x = $this->pdf->getX();
$y = $this->pdf->getY();
if (
!$this->isInOverflow
$this->setNewPage();
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$hT = 0.80*$this->style->value['font-size'];
$y+=($hT-$h);
$yc = $y-$this->style->value['margin']['t'];
// d�termination de la position r�elle d'affichage en fonction du text-align
du parent
$old = $this->style->getOldValues();
if ( $old['width'])
$parent_w = $old['width'];
$parent_x = $x;
else
$parent_x = $this->pdf->getlMargin();
if ($float)
$parent_x = $lx;
$parent_w = $rx-$lx;
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'];
else
$x-= $this->style->value['margin']['l'];
$y-= $this->style->value['margin']['t'];
if ($float=='left')
$this->pdf->setXY($lx, $yc);
else if ($float=='right')
$this->pdf->setXY($lx, $yc);
else
$this->pdf->setX($x+$w);
return true;
/**
* Tracer un rectanble
* @param float padding - marge int�rieur au rectangle => non utile mais on
le passe en param�tre
* @return null
*/
$y+= $margin;
$w-= $margin*2;
$h-= $margin*2;
$out_TL = $border['radius']['tl'];
$out_TR = $border['radius']['tr'];
$out_BR = $border['radius']['br'];
$out_BL = $border['radius']['bl'];
$in_TL = $out_TL;
$in_TR = $out_TR;
$in_BR = $out_BR;
$in_BL = $out_BL;
$STYLE = '';
if ($background['color'])
$this->pdf->setMyFillColor($background['color']);
$STYLE.= 'F';
if ($STYLE)
$this->pdf->clippingPathClose();
if ($background['image'])
$i_name = $background['image'];
$i_position = $background['position']!==null ?
$background['position'] : array(0, 0);
$i_repeat = $background['repeat']!==null ?
$background['repeat'] : array(true, true);
$b_y = $y;
$b_w = $w;
$b_h = $h;
$i_infos=@GetImageSize($i_name);
if (count($i_infos)<2)
if ($this->testIsImage)
return false;
else
$i_width = 72./96.*$i_infos[0]/$this->pdf->getK();
$i_height = 72./96.*$i_infos[1]/$this->pdf->getK();
$i_x_min = $b_x;
$i_x_max = $b_x+$b_w;
$i_y_min = $b_y;
$i_y_max = $b_y+$b_h;
}
$this->pdf->clippingPathOpen($b_x, $b_y, $b_w, $b_h,
$in_TL, $in_TR, $in_BL, $in_BR);
$c_x = null;
$c_y = null;
$c_w = $i_width;
$c_h = $i_height;
if ($i_y_max-$i_y<$i_height)
$c_x = $i_x;
$c_y = $i_y;
$c_h = $i_y_max-$i_y;
if ($i_x_max-$i_x<$i_width)
$c_x = $i_x;
$c_y = $i_y;
$c_w = $i_x_max-$i_x;
$this->pdf->clippingPathClose();
$x-= 0.01;
$y-= 0.01;
$w+= 0.02;
$h+= 0.02;
if ($in_BL)
$courbe = array();
$courbe[] = $x+$out_BL[0];
$courbe[] = $y+$h;
$courbe[] = $x;
$courbe[] = $y+$h-$out_BL[1];
$courbe[] = $x+$out_BL[0];
$courbe[] = $y+$h-$border['b']['width'];
$courbe[] = $x+$out_BL[0];
$courbe[] = $y+$h-$out_BL[1];
else
$courbe = array();
$courbe[] = $x+$out_BL[0];
$courbe[] = $y+$h;
$courbe[] = $x;
$courbe[] = $y+$h-$out_BL[1];
$courbe[] = $x+$out_BL[0];
$courbe[] = $y+$h-$out_BL[1];
$this->drawCourbe($courbe, $border['l']['color']);
if ($in_TL)
$courbe = array();
$courbe[] = $x;
$courbe[] = $y+$out_TL[1];
$courbe[] = $x+$out_TL[0];
$courbe[] = $y;
$courbe[] = $x+$out_TL[0];
$courbe[] = $y+$border['t']['width'];
$courbe[] = $x+$out_TL[0];
$courbe[] = $y+$out_TL[1];
else
$courbe = array();
$courbe[] = $x;
$courbe[] = $y+$out_TL[1];
$courbe[] = $x+$out_TL[0];
$courbe[] = $y;
$courbe[] = $x+$out_TL[0];
$courbe[] = $y+$out_TL[1];
$this->drawCourbe($courbe, $border['t']['color']);
if ($in_TR)
$courbe = array();
$courbe[] = $x+$w-$out_TR[0];
$courbe[] = $y;
$courbe[] = $x+$w;
$courbe[] = $y+$out_TR[1];
$courbe[] = $x+$w-$out_TR[0];
$courbe[] = $y+$border['t']['width'];
$courbe[] = $x+$w-$out_TR[0];
$courbe[] = $y+$out_TR[1];
else
$courbe = array();
$courbe[] = $x+$w-$out_TR[0];
$courbe[] = $y;
$courbe[] = $x+$w;
$courbe[] = $y+$out_TR[1];
$this->drawCourbe($courbe, $border['r']['color']);
if ($in_BR)
$courbe = array();
$courbe[] = $x+$w;
$courbe[] = $y+$h-$out_BR[1];
$courbe[] = $x+$w-$out_BR[0];
$courbe[] = $y+$h;
$courbe[] = $x+$w-$out_BR[0];
$courbe[] = $y+$h-$border['b']['width'];
$courbe[] = $x+$w-$out_BR[0];
$courbe[] = $y+$h-$out_BR[1];
else
$courbe = array();
$courbe[] = $x+$w;
$courbe[] = $y+$h-$out_BR[1];
$courbe[] = $x+$w-$out_BR[0];
$courbe[] = $y+$h;
$courbe[] = $x+$w-$out_BR[0];
$courbe[] = $y+$h-$out_BR[1];
}
$this->drawCourbe($courbe, $border['b']['color']);
if ($Bl)
$pt = array();
$pt[] = $x;
$pt[] = $y+$h;
$pt[] = $x;
$pt[] = $y+$h-$border['b']['width'];
$pt[] = $x;
$pt[] = $y+$border['t']['width'];
$pt[] = $x;
$pt[] = $y;
$bord = 3;
if (is_array($out_BL))
$bord-=1;
unset($pt[0]);unset($pt[1]);
if (is_array($out_TL))
$bord-=2;
$pt[5] += $out_TL[1]-$border['t']['width'];
unset($pt[6]);unset($pt[7]);
}
$pt = array_values($pt);
if ($Bt)
$pt = array();
$pt[] = $x;
$pt[] = $y;
$pt[] = $x+$w;
$pt[] = $y;
$bord = 3;
if (is_array($out_TL))
$bord-=1;
unset($pt[0]);unset($pt[1]);
if (is_array($out_TR))
$bord-=2;
unset($pt[6]);unset($pt[7]);
$pt = array_values($pt);
if ($Br)
$pt = array();
$pt[] = $x+$w;
$pt[] = $y;
$pt[] = $x+$w;
$pt[] = $y+$border['t']['width'];
$pt[] = $x+$w;
$pt[] = $y+$h-$border['b']['width'];
$pt[] = $x+$w;
$pt[] = $y+$h;
$bord = 3;
if (is_array($out_TR))
$bord-=1;
unset($pt[0]);unset($pt[1]);
}
if (is_array($out_BR))
$bord-=2;
unset($pt[6]);unset($pt[7]);
$pt = array_values($pt);
if ($Bb)
$pt = array();
$pt[] = $x+$w;
$pt[] = $y+$h;
$pt[] = $x;
$pt[] = $y+$h;
$bord = 3;
if (is_array($out_BL))
$bord-=2;
if (is_array($out_BR))
$bord-=1;
unset($pt[0]);unset($pt[1]);
$pt = array_values($pt);
if ($background['color'])
$this->pdf->setMyFillColor($background['color']);
$this->pdf->setMyFillColor($color);
if (count($pt)==10)
else
/**
* Tracer une ligne epaisse d�fini par ses points avec des extreminites en biseau
* @return null
*/
$this->pdf->setMyFillColor($color);
if ($type=='dashed' || $type=='dotted')
if ($bord==1)
$this->pdf->Polygon($tmp, 'F');
$pt = $tmp;
else if ($bord==2)
$this->pdf->Polygon($tmp, 'F');
$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];
$pt = $tmp;
else if ($bord==3)
$this->pdf->Polygon($tmp, 'F');
$this->pdf->Polygon($tmp, 'F');
$pt = $tmp;
if ($pt[2]==$pt[0])
$l = abs(($pt[3]-$pt[1])*0.5);
$px = 0;
$py = $width;
else
$l = abs(($pt[2]-$pt[0])*0.5);
$px = $width;
$py = 0;
$x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1];
if ($type=='dashed')
$px = $px*3.;
$py = $py*3.;
$mode = ($l/($px+$py)<.5);
if (($i%2)==$mode)
$j = $i-0.5;
$tmp = array();
$this->pdf->Polygon($tmp, 'F');
if ($j>0)
$tmp = array();
$this->pdf->Polygon($tmp, 'F');
else if ($type=='double')
$pt1 = $pt;
$pt2 = $pt;
if (count($pt)==12)
else
$this->pdf->Polygon($pt1, 'F');
$this->pdf->Polygon($pt2, 'F');
else if ($type=='solid')
$this->pdf->Polygon($pt, 'F');
/**
* balise : BR
* mode : OUVERTURE
* @return null
*/
$h = max($this->maxH, $this->style->getLineHeight());
// si la ligne est vide, la position maximale n'a pas �t� mise � jour => on la
met � jour
$this->makeBR($h, $curr);
$this->maxH = 0;
return true;
if ($h)
if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf-
>getbMargin()) || $this->isInOverflow || $this->isInFooter)
$this->setNewLine($h, $curr);
else
else
$this->setNewPositionForNewLine($curr);
}
$this->maxH = 0;
/**
* balise : HR
* mode : OUVERTURE
* @return null
*/
function o_HR($param)
$old_align = $this->style->value['text-align'];
$this->style->value['text-align'] = 'left';
if ($this->maxH) $this->o_BR($param);
$f_size = $this->style->value['font-size'];
$this->style->value['font-size']=$f_size*0.5; $this->o_BR($param);
$this->style->value['font-size']=0;
$param['style']['width'] = '100%';
$this->style->save();
$this->style->value['height']=$this->style->ConvertToMM('1mm');
$this->style->analyse('hr', $param);
$this->style->setPosition();
$this->style->FontSet();
$h = $this->style->value['height'];
if ($h<=0) $h = $this->style->value['border']['t']['width']+$this->style-
>value['border']['b']['width'];
$this->maxH = $h;
$this->style->load();
$this->style->FontSet();
$this->o_BR($param);
$this->style->value['font-size']=$f_size*0.5; $this->o_BR($param);
$this->style->value['font-size']=$f_size;
$this->style->value['text-align'] = $old_align;
$this->setNewPositionForNewLine();
return true;
/**
* balise : B
* mode : OUVERTURE
* @return null
*/
$this->style->save();
$this->style->value['font-bold'] = true;
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : B
* mode : FERMETURE
* @return null
*/
function c_B($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : I
* mode : OUVERTURE
*
* @param array param�tres de l'�l�ment de parsing
* @return null
*/
$this->style->save();
$this->style->value['font-italic'] = true;
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : I
* mode : FERMETURE
* @return null
*/
function c_I($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : S
* mode : OUVERTURE
* @return null
*/
$this->style->save();
$this->style->value['font-linethrough'] = true;
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : S
* mode : FERMETURE
*
* @param array param�tres de l'�l�ment de parsing
* @return null
*/
function c_S($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : U
* mode : OUVERTURE
* @return null
*/
$this->style->save();
$this->style->value['font-underline'] = true;
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
* balise : U
* mode : FERMETURE
* @return null
*/
function c_U($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : A
* mode : OUVERTURE
* @return null
*/
function o_A($param)
if (isset($param['name']))
$nom = $param['name'];
if (!isset($this->lstAncre[$nom])) $this->lstAncre[$nom] =
array($this->pdf->AddLink(), false);
if (!$this->lstAncre[$nom][1])
$this->lstAncre[$nom][1] = true;
$nom = $match[1];
if (!isset($this->lstAncre[$nom])) $this->lstAncre[$nom] =
array($this->pdf->AddLink(), false);
$this->inLink = $this->lstAncre[$nom][0];
$this->style->save();
$this->style->value['font-underline'] = true;
$this->style->analyse('a', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : A
* mode : FERMETURE
*
* @return null
*/
function c_A($param)
$this->inLink = '';
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : H1
* mode : OUVERTURE
* @return null
*/
if ($this->maxH) $this->o_BR(array());
$this->style->save();
$this->style->value['font-bold'] = true;
$size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5'
=> '12px', 'h6' => '9px');
$this->style->value['margin']['l'] = 0;
$this->style->value['margin']['r'] = 0;
$this->style->value['margin']['t'] = $this->style->ConvertToMM('16px');
$this->style->value['margin']['b'] = $this->style->ConvertToMM('16px');
$this->style->value['font-size'] = $this->style->ConvertToMM($size[$other]);
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
$this->setNewPositionForNewLine();
return true;
/**
* balise : H1
* mode : FERMETURE
* @return null
*/
function c_H1($param)
// hauteur du H1
$this->maxH+= $this->style->value['margin']['b'];
$h = max($this->maxH, $this->style->getLineHeight());
$this->style->load();
$this->style->FontSet();
$this->makeBR($h);
$this->maxH = 0;
return true;
/**
* balise : SPAN
* mode : OUVERTURE
* @return null
*/
$this->style->save();
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : SPAN
* mode : FERMETURE
* @return null
*/
function c_SPAN($param)
$this->style->restorePosition();
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : P
* mode : OUVERTURE
* @return null
*/
function o_P($param)
if ($this->maxH) $this->o_BR(array());
$this->style->save();
$this->style->analyse('p', $param);
$this->style->setPosition();
$this->style->FontSet();
$this->pdf->setXY($this->pdf->getX()-$this->style->value['margin']['l'], $this-
>pdf->getY()-$this->style->value['margin']['t']);
$mR = $this->pdf->getW()-$mR;
$mL+= $this->style->value['margin']['l']+$this->style->value['padding']['l'];
$mR+= $this->style->value['margin']['r']+$this->style->value['padding']['r'];
$this->saveMargin($mL,0,$mR);
if ($this->style->value['text-indent']>0)
$y = $this->pdf->getY()+$this->style->value['margin']['t']+$this-
>style->value['padding']['t'];
$this->pageMarges[floor($y*100)] = array($mL+$this->style-
>value['text-indent'], $this->pdf->getW()-$mR);
$y+= $this->style->getLineHeight()*0.1;
$this->pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-
$mR);
$this->makeBR($this->style->value['margin']['t']+$this->style-
>value['padding']['t']);
return true;
/**
* balise : P
* mode : FERMETURE
* @return null
*/
function c_P($param)
if ($this->maxH) $this->o_BR(array());
$this->loadMargin();
$h = $this->style->value['margin']['b']+$this->style->value['padding']['b'];
$this->style->load();
$this->style->FontSet();
$this->makeBR($h);
return true;
/**
* balise : PRE
* mode : OUVERTURE
* @return null
*/
$this->style->save();
$this->style->value['font-family'] = 'courier';
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : PRE
* mode : FERMETURE
* @return null
*/
if ($other=='pre')
{
$this->c_DIV($param);
$this->o_BR(array());
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : BIG
* mode : OUVERTURE
* @return null
*/
function o_BIG($param)
$this->style->save();
$this->style->value['mini-decal']-= $this->style->value['mini-size']*0.05;
$this->style->value['mini-size'] *= 1.2;
$this->style->analyse('big', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
}
/**
* balise : BIG
* mode : FERMETURE
* @return null
*/
function c_BIG($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : SMALL
* mode : OUVERTURE
* @return null
*/
function o_SMALL($param)
$this->style->save();
$this->style->value['mini-decal']+= $this->style->value['mini-size']*0.05;
$this->style->value['mini-size'] *= 0.82;
$this->style->analyse('small', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
}
/**
* balise : SMALL
* mode : FERMETURE
* @return null
*/
function c_SMALL($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : SUP
* mode : OUVERTURE
* @return null
*/
function o_SUP($param)
$this->style->save();
$this->style->value['mini-decal']-= $this->style->value['mini-size']*0.15;
$this->style->value['mini-size'] *= 0.75;
$this->style->analyse('sup', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : SUP
* mode : FERMETURE
* @return null
*/
function c_SUP($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : SUB
* mode : OUVERTURE
* @return null
*/
function o_SUB($param)
$this->style->save();
$this->style->value['mini-decal']+= $this->style->value['mini-size']*0.15;
$this->style->value['mini-size'] *= 0.75;
$this->style->analyse('sub', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : SUB
* mode : FERMETURE
* @return null
*/
function c_SUB($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : UL
* mode : OUVERTURE
* @return null
*/
if ($this->maxH) $this->o_BR(array());
if (!count($this->defLIST)) $this->o_BR(array());
$param['cellspacing'] = 0;
$this->o_TABLE($param, $other);
return true;
/**
* balise : UL
* mode : FERMETURE
* @return null
*/
function c_UL($param)
{
// fin du tableau
$this->c_TABLE($param);
$this->listeDelLevel();
if (!$this->sub_part)
if (!count($this->defLIST)) $this->o_BR(array());
return true;
/**
* balise : LI
* mode : OUVERTURE
* @return null
*/
function o_LI($param)
$this->listeAddLi();
if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
$paramPUCE = $param;
$inf = $this->listeGetLi();
if ($inf[0])
$paramPUCE['style']['font-family'] = $inf[0];
$paramPUCE['style']['text-align'] = 'li_right';
$paramPUCE['style']['vertical-align'] = 'top';
$paramPUCE['style']['width'] = $this-
>listeGetWidth();
$paramPUCE['style']['padding-right'] = $this->listeGetPadding();
$paramPUCE['txt'] = $inf[2];
else
$paramPUCE['style']['text-align'] = 'li_right';
$paramPUCE['style']['vertical-align'] = 'top';
$paramPUCE['style']['width'] = $this-
>listeGetWidth();
$paramPUCE['style']['padding-right'] = $this->listeGetPadding();
$paramPUCE['src'] = $inf[2];
$paramPUCE['sub_li'] = true;
// nouvelle ligne
$this->o_TR($param, 'li');
$this->style->save();
if ($inf[1]) // small
$this->style->value['mini-decal']+= $this->style->value['mini-
size']*0.045;
$this->style->value['mini-size'] *= 0.75;
if ($this->sub_part)
// TD pour la puce
$tmp_pos = $this->temp_pos;
$tmp_lst1 = $this->parsing->code[$tmp_pos+1];
$tmp_lst2 = $this->parsing->code[$tmp_pos+2];
$this->parsing->code[$tmp_pos+1] = array();
$this->parsing->code[$tmp_pos+1]['name'] =
(isset($paramPUCE['src'])) ? 'img' : 'write';
$this->parsing->code[$tmp_pos+1]['param'] = $paramPUCE;
unset($this->parsing->code[$tmp_pos+1]['param']['style']['width']);
$this->parsing->code[$tmp_pos+1]['close'] = 0;
$this->parsing->code[$tmp_pos+2] = array();
$this->parsing->code[$tmp_pos+2]['name'] = 'li';
$this->parsing->code[$tmp_pos+2]['param'] = $paramPUCE;
$this->parsing->code[$tmp_pos+2]['close'] = 1;
$this->o_TD($paramPUCE, 'li_sub');
$this->c_TD($param);
$this->temp_pos = $tmp_pos;
$this->parsing->code[$tmp_pos+1] = $tmp_lst1;
$this->parsing->code[$tmp_pos+2] = $tmp_lst2;
else
{
// TD pour la puce
$this->o_TD($paramPUCE, 'li_sub');
unset($paramPUCE['style']['width']);
if (isset($paramPUCE['src'])) $this->o_IMG($paramPUCE);
else $this-
>o_WRITE($paramPUCE);
$this->c_TD($paramPUCE);
$this->style->load();
// td pour le contenu
$this->o_TD($param, 'li');
return true;
/**
* balise : LI
* mode : FERMETURE
* @return null
*/
function c_LI($param)
// fin du contenu
$this->c_TD($param);
// fin de la ligne
$this->c_TR($param);
return true;
/**
* balise : TBODY
* mode : OUVERTURE
* @return null
*/
function o_TBODY($param)
$this->style->save();
$this->style->analyse('tbody', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : TBODY
* mode : FERMETURE
*/
function c_TBODY($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : THEAD
* mode : OUVERTURE
* @return null
*/
function o_THEAD($param)
global $HTML2PDF_TABLEAU;
$this->style->save();
$this->style->analyse('thead', $param);
$this->style->setPosition();
$this->style->FontSet();
$HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0] =
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
$HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array();
for($pos=$this->temp_pos; $pos<count($this->parsing->code);
$pos++)
$todo = $this->parsing->code[$pos];
if (strtolower($todo['name'])=='thead') $todo['name'] =
'thead_sub';
$HTML2PDF_TABLEAU[$param['num']]['thead']['code'][] =
$todo;
if (strtolower($todo['name'])=='thead_sub' &&
$todo['close']) break;
else
$level = $this->parsing->getLevel($this->parse_pos);
$this->parse_pos+= count($level);
$HTML2PDF_TABLEAU[$param['num']]['tr_curr']+=
count($HTML2PDF_TABLEAU[$param['num']]['thead']['tr']);
return true;
/**
* balise : THEAD
* mode : FERMETURE
*/
function c_THEAD($param)
$this->style->load();
$this->style->FontSet();
if ($this->sub_part)
global $HTML2PDF_TABLEAU;
$min = $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
$max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
$HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = range($min,
$max);
return true;
/**
* balise : TFOOT
* mode : OUVERTURE
* @return null
*/
function o_TFOOT($param)
{
if ($this->forOneLine) return false;
global $HTML2PDF_TABLEAU;
$this->style->save();
$this->style->analyse('tfoot', $param);
$this->style->setPosition();
$this->style->FontSet();
if ($this->sub_part)
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0] =
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array();
for($pos=$this->temp_pos; $pos<count($this->parsing->code);
$pos++)
$todo = $this->parsing->code[$pos];
if (strtolower($todo['name'])=='tfoot') $todo['name'] =
'tfoot_sub';
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'][] =
$todo;
if (strtolower($todo['name'])=='tfoot_sub' &&
$todo['close']) break;
else
$level = $this->parsing->getLevel($this->parse_pos);
$this->parse_pos+= count($level);
$HTML2PDF_TABLEAU[$param['num']]['tr_curr']+=
count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr']);
}
return true;
/**
* balise : TFOOT
* mode : FERMETURE
* @return null
*/
function c_TFOOT($param)
$this->style->load();
$this->style->FontSet();
if ($this->sub_part)
global $HTML2PDF_TABLEAU;
$min = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
$max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = range($min,
$max);
return true;
}
/**
* balise : THEAD_SUB
* mode : OUVERTURE
* @return null
*/
function o_THEAD_SUB($param)
$this->style->save();
$this->style->analyse('thead', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : THEAD_SUB
* mode : FERMETURE
* @return null
*/
function c_THEAD_SUB($param)
$this->style->FontSet();
return true;
/**
* balise : TFOOT_SUB
* mode : OUVERTURE
* @return null
*/
function o_TFOOT_SUB($param)
$this->style->save();
$this->style->analyse('tfoot', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
/**
* balise : TFOOT_SUB
* mode : FERMETURE
*/
function c_TFOOT_SUB($param)
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : FORM
* mode : OUVERTURE
* @return null
*/
function o_FORM($param)
$this->style->save();
$this->style->analyse('form', $param);
$this->style->setPosition();
$this->style->FontSet();
return true;
}
/**
* balise : FORM
* mode : FERMETURE
* @return null
*/
function c_FORM($param)
$this->isInForm = false;
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : TABLE
* mode : OUVERTURE
* @return null
*/
if ($this->maxH)
$this->o_BR(array());
}
if ($this->forOneLine)
$this->maxE++;
return false;
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
if (isset($param['align'])) unset($param['align']);
$this->style->save();
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
// est-on en collapse
$collapse = false;
if ($other=='table')
if ($collapse)
{
$param['style']['border'] = 'none';
$param['cellspacing'] = 0;
$none = $this->style->readBorder('none');
$this->style->value['border']['t'] = $none;
$this->style->value['border']['r'] = $none;
$this->style->value['border']['b'] = $none;
$this->style->value['border']['l'] = $none;
if ($this->sub_part)
$HTML2PDF_TABLEAU[$param['num']] = array();
$HTML2PDF_TABLEAU[$param['num']]['border'] =
isset($param['border']) ? $this->style->readBorder($param['border']) : null; // border sp�cifique si
border precis� en param�tre
$HTML2PDF_TABLEAU[$param['num']]['cellpadding'] = $this-
>style->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); // cellpadding du
tableau
$HTML2PDF_TABLEAU[$param['num']]['cellspacing'] = $this-
>style->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); // cellspacing du
tableau
$HTML2PDF_TABLEAU[$param['num']]['cases'] = array();
// liste des propri�t�s des cases
$HTML2PDF_TABLEAU[$param['num']]['corr'] = array();
// tableau de correlation pour les colspan et rowspan
$HTML2PDF_TABLEAU[$param['num']]['corr_x'] = 0;
// position dans le tableau de correlation
$HTML2PDF_TABLEAU[$param['num']]['corr_y'] = 0;
// position dans le tableau de correlation
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
// colonne courante
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0;
// ligne courante
$HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $this-
>pdf->getX(); // position courante X
$HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this-
>pdf->getY(); // position courante Y
$HTML2PDF_TABLEAU[$param['num']]['width'] = 0;
// largeur globale
$HTML2PDF_TABLEAU[$param['num']]['height'] = 0;
// hauteur globale
$HTML2PDF_TABLEAU[$param['num']]['align'] =
$align_object;
$HTML2PDF_TABLEAU[$param['num']]['marge'] = array();
$HTML2PDF_TABLEAU[$param['num']]['marge']['t'] = $this-
>style->value['padding']['t']+$this->style->value['border']['t']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
$HTML2PDF_TABLEAU[$param['num']]['marge']['r'] = $this-
>style->value['padding']['r']+$this->style->value['border']['r']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
$HTML2PDF_TABLEAU[$param['num']]['marge']['b'] = $this-
>style->value['padding']['b']+$this->style->value['border']['b']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
$HTML2PDF_TABLEAU[$param['num']]['marge']['l'] = $this-
>style->value['padding']['l']+$this->style->value['border']['l']['width']+
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
$HTML2PDF_TABLEAU[$param['num']]['page'] = 0;
// nombre de pages
$HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
// nouvelle page pour le TR courant
$HTML2PDF_TABLEAU[$param['num']]['style_value'] = null;
// style du tableau
$HTML2PDF_TABLEAU[$param['num']]['thead'] = array();
// infos sur le thead
$HTML2PDF_TABLEAU[$param['num']]['tfoot'] = array();
// infos sur le tfoot
$HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = array();
// tr du thead
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = array();
// tr du tfoot
$HTML2PDF_TABLEAU[$param['num']]['thead']['height'] = 0;
// hauteur du thead
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'] = 0;
// hauteur du tfoot
$HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array();
// contenu HTML du thead
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array();
// contenu HTML du tfoot
$HTML2PDF_TABLEAU[$param['num']]['cols'] = array();
// definition via les balises col
$this->saveMargin($this->pdf->getlMargin(), $this->pdf-
>gettMargin(), $this->pdf->getrMargin());
$this->style->value['width']-=
$HTML2PDF_TABLEAU[$param['num']]['marge']['l'] + $HTML2PDF_TABLEAU[$param['num']]
['marge']['r'];
else
$HTML2PDF_TABLEAU[$param['num']]['page'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['td_x'] =
$HTML2PDF_TABLEAU[$param['num']]['marge']['l']+$HTML2PDF_TABLEAU[$param['num']]
['curr_x'];
$HTML2PDF_TABLEAU[$param['num']]['td_y'] =
$HTML2PDF_TABLEAU[$param['num']]['marge']['t']+$HTML2PDF_TABLEAU[$param['num']]
['curr_y'];
$this->drawRectangle(
$HTML2PDF_TABLEAU[$param['num']]['curr_x'],
$HTML2PDF_TABLEAU[$param['num']]['curr_y'],
$HTML2PDF_TABLEAU[$param['num']]['width'],
isset($HTML2PDF_TABLEAU[$param['num']]
['height'][0]) ? $HTML2PDF_TABLEAU[$param['num']]['height'][0] : null,
$this->style->value['border'],
$this->style->value['padding'],
0,
$this->style->value['background']
);
$HTML2PDF_TABLEAU[$param['num']]['style_value'] = $this->style-
>value;
return true;
/**
* balise : TABLE
* mode : FERMETURE
* @return null
*/
function c_TABLE($param)
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
// restauration du style
$this->style->load();
$this->style->FontSet();
if ($this->sub_part)
$this->calculTailleCases($HTML2PDF_TABLEAU[$param['num']]
['cases'], $HTML2PDF_TABLEAU[$param['num']]['corr']);
foreach($lst as $mode)
$HTML2PDF_TABLEAU[$param['num']][$mode]['height'] =
0;
foreach($HTML2PDF_TABLEAU[$param['num']][$mode]['tr']
as $tr)
// hauteur de la ligne tr
$h = 0;
for($i=0;
$i<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$tr]); $i++)
if ($HTML2PDF_TABLEAU[$param['num']]
['cases'][$tr][$i]['rowspan']==1)
$h = max($h,
$HTML2PDF_TABLEAU[$param['num']]['cases'][$tr][$i]['h']);
$HTML2PDF_TABLEAU[$param['num']][$mode]
['height']+= $h;
}
// calcul des dimensions du tableau - Largeur
$HTML2PDF_TABLEAU[$param['num']]['width'] =
$HTML2PDF_TABLEAU[$param['num']]['marge']['l'] + $HTML2PDF_TABLEAU[$param['num']]
['marge']['r'];
if (isset($HTML2PDF_TABLEAU[$param['num']]['cases'][0]))
foreach($HTML2PDF_TABLEAU[$param['num']]['cases'][0]
as $case)
$HTML2PDF_TABLEAU[$param['num']]['width']+=
$case['w'];
$old = $this->style->getOldValues();
$x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'];
$w = $HTML2PDF_TABLEAU[$param['num']]['width'];
if ($parent_w>$w)
if ($HTML2PDF_TABLEAU[$param['num']]['align']=='center')
$x = $x + ($parent_w-$w)*0.5;
else if ($HTML2PDF_TABLEAU[$param['num']]
['align']=='right')
$x = $x + $parent_w-$w;
$HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $x;
$HTML2PDF_TABLEAU[$param['num']]['height'] = array();
$h0 = $HTML2PDF_TABLEAU[$param['num']]['marge']['t'] +
$HTML2PDF_TABLEAU[$param['num']]['marge']['b']; // minimum de hauteur � cause des
marges
$h0+= $HTML2PDF_TABLEAU[$param['num']]['thead']['height'] +
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['height']; // et du tfoot et thead
$y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']; // position Y
actuelle
$height = $h0;
for($k=0; $k<count($HTML2PDF_TABLEAU[$param['num']]['cases']);
$k++)
if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]
['thead']['tr'])) continue;
if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]
['tfoot']['tr'])) continue;
// hauteur de la ligne $k
$th = 0;
$h = 0;
for($i=0; $i<count($HTML2PDF_TABLEAU[$param['num']]
['cases'][$k]); $i++)
$h = max($h, $HTML2PDF_TABLEAU[$param['num']]
['cases'][$k][$i]['h']);
if ($HTML2PDF_TABLEAU[$param['num']]['cases']
[$k][$i]['rowspan']==1)
$th = max($th,
$HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['h']);
}
// si la ligne ne rentre pas dans la page
if ($y+$h+$height>$max)
$HTML2PDF_TABLEAU[$param['num']]['height'][] =
$height;
$height = $h0;
$y = $this->margeTop;
$height+= $th;
else
if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['code']))
$tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
$tmp_td = $HTML2PDF_TABLEAU[$param['num']]
['td_curr'];
$OLD_parse_pos = $this->parse_pos;
$OLD_parse_code = $this->parsing->code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] =
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
$this->parse_pos = 0;
$this->parsing->code =
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
$this->makeHTMLcode();
$this->parse_pos = $OLD_parse_pos;
$this->parsing->code = $OLD_parse_code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] =
$tmp_td;
$x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'] +
$HTML2PDF_TABLEAU[$param['num']]['width'];
if (count($HTML2PDF_TABLEAU[$param['num']]['height'])>1)
$y = $this->margeTop+
$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]
['height'])-1];
else if (count($HTML2PDF_TABLEAU[$param['num']]['height'])==1)
$y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']+
$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]
['height'])-1];
else
$y = $HTML2PDF_TABLEAU[$param['num']]['curr_y'];
// taille du tableau
$this->pdf->setXY($this->pdf->getlMargin(), $y);
// restauration des marges
$this->loadMargin();
return true;
/**
* balise : COL
* @return null
*/
function o_COL($param)
global $HTML2PDF_TABLEAU;
$HTML2PDF_TABLEAU[$param['num']]['cols'][] = $param;
/**
* balise : TR
* mode : OUVERTURE
*/
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
// analyse du style
$this->style->save();
$this->style->analyse($other, $param);
$this->style->setPosition();
$this->style->FontSet();
$HTML2PDF_TABLEAU[$param['num']]['tr_curr']++;
$HTML2PDF_TABLEAU[$param['num']]['td_curr']= 0;
if (!$this->sub_part)
$ty=null;
for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++)
$hfoot = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'];
if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']
['code']))
$tmp_tr = $HTML2PDF_TABLEAU[$param['num']]
['tr_curr'];
$tmp_td = $HTML2PDF_TABLEAU[$param['num']]
['td_curr'];
$OLD_parse_pos = $this->parse_pos;
$OLD_parse_code = $this->parsing->code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] =
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] =
0;
$this->parse_pos = 0;
$this->parsing->code =
$HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
$this->isInTfoot = true;
$this->makeHTMLcode();
$this->isInTfoot = false;
$this->parse_pos = $OLD_parse_pos;
$this->parsing->code = $OLD_parse_code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] =
$tmp_tr;
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] =
$tmp_td;
$HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
$this->setNewPage();
$HTML2PDF_TABLEAU[$param['num']]['page']++;
$HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this-
>pdf->getY();
$HTML2PDF_TABLEAU[$param['num']]['td_y'] =
$HTML2PDF_TABLEAU[$param['num']]['curr_y']+$HTML2PDF_TABLEAU[$param['num']]['marge']
['t'];
if (isset($HTML2PDF_TABLEAU[$param['num']]['height']
[$HTML2PDF_TABLEAU[$param['num']]['page']]))
$old = $this->style->value;
$this->style->value =
$HTML2PDF_TABLEAU[$param['num']]['style_value'];
$this->drawRectangle(
$HTML2PDF_TABLEAU[$param['num']]['curr_x'],
$HTML2PDF_TABLEAU[$param['num']]['curr_y'],
$HTML2PDF_TABLEAU[$param['num']]['width'],
$HTML2PDF_TABLEAU[$param['num']]['height'][$HTML2PDF_TABLEAU[$param['num']]
['page']],
$this->style->value['border'],
$this->style->value['padding'],
$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5,
$this->style->value['background']
);
$this->style->value = $old;
if ($HTML2PDF_TABLEAU[$param['num']]['new_page'] &&
count($HTML2PDF_TABLEAU[$param['num']]['thead']['code']))
$HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
$tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
$tmp_td = $HTML2PDF_TABLEAU[$param['num']]
['td_curr'];
$OLD_parse_pos = $this->parse_pos;
$OLD_parse_code = $this->parsing->code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] =
$HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
$this->parse_pos = 0;
$this->parsing->code =
$HTML2PDF_TABLEAU[$param['num']]['thead']['code'];
$this->isInThead = true;
$this->makeHTMLcode();
$this->isInThead = false;
$this->parse_pos = $OLD_parse_pos;
$this->parsing->code = $OLD_parse_code;
$HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
$HTML2PDF_TABLEAU[$param['num']]['td_curr'] =
$tmp_td;
$HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
}
else
$HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1] = array();
if (!isset($HTML2PDF_TABLEAU[$param['num']]['corr']
[$HTML2PDF_TABLEAU[$param['num']]['corr_y']]))
$HTML2PDF_TABLEAU[$param['num']]['corr']
[$HTML2PDF_TABLEAU[$param['num']]['corr_y']] = array();
$HTML2PDF_TABLEAU[$param['num']]['corr_x']=0;
while(isset($HTML2PDF_TABLEAU[$param['num']]['corr']
[$HTML2PDF_TABLEAU[$param['num']]['corr_y']][$HTML2PDF_TABLEAU[$param['num']]['corr_x']]))
$HTML2PDF_TABLEAU[$param['num']]['corr_x']++;
return true;
/**
* balise : TR
* mode : FERMETURE
* @return null
*/
function c_TR($param)
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
// restauration du style
$this->style->load();
$this->style->FontSet();
if (!$this->sub_part)
$ty=null;
for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++)
if ($HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['rowspan']==1)
$ty = $HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['h'];
$HTML2PDF_TABLEAU[$param['num']]['td_x'] =
$HTML2PDF_TABLEAU[$param['num']]['curr_x']+$HTML2PDF_TABLEAU[$param['num']]['marge']
['l'];
$HTML2PDF_TABLEAU[$param['num']]['td_y']+= $ty;
$HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
else
$HTML2PDF_TABLEAU[$param['num']]['corr_y']++;
return true;
/**
* balise : TD
* mode : OUVERTURE
* @return null
*/
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
$param['cellpadding'] = $HTML2PDF_TABLEAU[$param['num']]
['cellpadding'].'mm';
$param['cellspacing'] = $HTML2PDF_TABLEAU[$param['num']]
['cellspacing'].'mm';
if ($other=='li')
$special_li = true;
else
$special_li = false;
if ($other=='li_sub')
$param['style']['border'] = 'none';
$param['style']['background-color'] =
'transparent';
$param['style']['background-image'] = 'none';
$param['style']['background-position'] = '';
$param['style']['background-repeat'] = '';
$other = 'li';
$x = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
$y = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
$collapse = false;
$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'];
if (isset($HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col]))
// on la recupere
$col_param = $HTML2PDF_TABLEAU[$param['num']]['cols']
[$num_col];
$col_param['style']['width'] = array();
if (isset($HTML2PDF_TABLEAU[$param['num']]
['cols'][$num_col+$k]['style']['width']))
$col_param['style']['width'][] =
$HTML2PDF_TABLEAU[$param['num']]['cols'][$num_col+$k]['style']['width'];
}
// on les somme
$total = '';
$last = $this->style->getLastWidth();
if (count($col_param['style']['width']))
$total = $col_param['style']['width'][0];
unset($col_param['style']['width'][0]);
foreach($col_param['style']['width'] as $width)
else
$total = ($this->style-
>ConvertToMM($total, $last) + $this->style->ConvertToMM($width, $last)).'mm';
if ($total)
$col_param['style']['width'] = $total;
else
unset($col_param['style']['width']);
$param['style'] = array_merge($col_param['style'],
$param['style']);
if (isset($col_param['class']))
$param['class'] = $col_param['class'].
(isset($param['class']) ? ' '.$param['class'] : '');
// analyse du style
$this->style->save();
$heritage = null;
$heritage = array();
$old = $this->style->getLastValue('background');
$heritage['background'] = $old;
if ($HTML2PDF_TABLEAU[$param['num']]['border'])
$heritage['border'] = array();
$heritage['border']['l'] =
$HTML2PDF_TABLEAU[$param['num']]['border'];
$heritage['border']['t'] =
$HTML2PDF_TABLEAU[$param['num']]['border'];
$heritage['border']['r'] =
$HTML2PDF_TABLEAU[$param['num']]['border'];
$heritage['border']['b'] =
$HTML2PDF_TABLEAU[$param['num']]['border'];
}
$return = $this->style->analyse($other, $param, $heritage);
if ($special_li)
$this->style->value['width']-= $this->style->ConvertToMM($this-
>listeGetWidth());
$this->style->value['width']-= $this->style->ConvertToMM($this-
>listeGetPadding());
$this->style->setPosition();
$this->style->FontSet();
if ($collapse)
if (!$this->sub_part)
if (
($HTML2PDF_TABLEAU[$param['num']]
['tr_curr']>1 && !$HTML2PDF_TABLEAU[$param['num']]['new_page']) ||
(!$this->isInThead &&
count($HTML2PDF_TABLEAU[$param['num']]['thead']['code']))
$this->style->value['border']['t'] = $this->style-
>readBorder('none');
if ($HTML2PDF_TABLEAU[$param['num']]['td_curr']>0)
$marge = array();
$marge['t'] = $this->style->value['padding']['t']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['t']['width'];
$marge['r'] = $this->style->value['padding']['r']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['r']['width'];
$marge['b'] = $this->style->value['padding']['b']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['b']['width'];
$marge['l'] = $this->style->value['padding']['l']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['l']['width'];
if ($this->sub_part)
$HTML2PDF_TABLEAU[$param['num']]['td_curr']++;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x] = array();
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['w'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['h'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['dw'] = 0;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['colspan'] =
$colspan;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['rowspan'] =
$rowspan;
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Xr'] =
$HTML2PDF_TABLEAU[$param['num']]['corr_x'];
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['Yr'] =
$HTML2PDF_TABLEAU[$param['num']]['corr_y'];
$HTML2PDF_TABLEAU[$param['num']]['corr']
[$HTML2PDF_TABLEAU[$param['num']]
['corr_y']+$j]
[$HTML2PDF_TABLEAU[$param['num']]
['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan);
$HTML2PDF_TABLEAU[$param['num']]['corr_x']+= $colspan;
while(isset($HTML2PDF_TABLEAU[$param['num']]['corr']
[$HTML2PDF_TABLEAU[$param['num']]['corr_y']][$HTML2PDF_TABLEAU[$param['num']]['corr_x']]))
$HTML2PDF_TABLEAU[$param['num']]['corr_x']++;
$level = $this->parsing->getLevel($this->temp_pos);
$this->CreateSubHTML($this->sub_html);
$this->sub_html->parsing->code = $level;
$this->sub_html->MakeHTMLcode();
$this->temp_pos+= count($level);
else
$HTML2PDF_TABLEAU[$param['num']]['td_curr']++;
$HTML2PDF_TABLEAU[$param['num']]['td_x']+=
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]['dw'];
// initialisation du style des bordures de la premiere partie de
tableau
$this->drawRectangle(
$HTML2PDF_TABLEAU[$param['num']]['td_x'],
$HTML2PDF_TABLEAU[$param['num']]['td_y'],
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y]
[$x]['w'],
$HTML2PDF_TABLEAU[$param['num']]['cases'][$y]
[$x]['h'],
$this->style->value['border'],
$this->style->value['padding'],
$HTML2PDF_TABLEAU[$param['num']]
['cellspacing']*0.5,
$this->style->value['background']
);
$this->style->value['width'] = $HTML2PDF_TABLEAU[$param['num']]
['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];
$mL = $HTML2PDF_TABLEAU[$param['num']]['td_x']+$marge['l'];
$this->saveMargin($mL, 0, $mR);
// positionnement en fonction
$h_corr = $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]
['h'];
$h_reel = $HTML2PDF_TABLEAU[$param['num']]['cases'][$y][$x]
['real_h'];
switch($this->style->value['vertical-align'])
case 'bottom':
$y_corr = $h_corr-$h_reel;
break;
case 'middle':
$y_corr = ($h_corr-$h_reel)*0.5;
break;
case 'top':
default:
$y_corr = 0;
break;
$x = $HTML2PDF_TABLEAU[$param['num']]['td_x']+$marge['l'];
$y = $HTML2PDF_TABLEAU[$param['num']]['td_y']+$marge['t']+
$y_corr;
$this->pdf->setXY($x, $y);
$this->setNewPositionForNewLine();
return true;
/**
* balise : TD
* mode : FERMETURE
* @return null
*/
function c_TD($param)
{
$this->maxH = 0;
global $HTML2PDF_TABLEAU;
// r�cup�ration de la marge
$marge = array();
$marge['t'] = $this->style->value['padding']['t']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['t']['width'];
$marge['r'] = $this->style->value['padding']['r']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['r']['width'];
$marge['b'] = $this->style->value['padding']['b']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['b']['width'];
$marge['l'] = $this->style->value['padding']['l']
+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['l']['width'];
$marge['t']+= 0.001;
$marge['r']+= 0.001;
$marge['b']+= 0.001;
$marge['l']+= 0.001;
if ($this->sub_part)
$HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]
['td_curr']-1]['w'] = max(array($w0, $w2));
$HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]
['td_curr']-1]['h'] = max(array($h0, $h2));
$HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]
['td_curr']-1]['real_w'] = $w0;
$HTML2PDF_TABLEAU[$param['num']]['cases']
[$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]
['td_curr']-1]['real_h'] = $h0;
// suppresion du sous_html
$this->destroySubHTML($this->sub_html);
else
$this->loadMargin();
//positionnement
$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'];
// restauration du style
$this->style->load();
$this->style->FontSet();
return true;
}
$corr = array();
// on fait correspondre chaque case d'un tableau norm� aux cases r�elles,
en prennant en compte les colspan et rowspan
$Yr=0;
$Xr+= $cases[$y][$x]['colspan'];
while(isset($corr[$Yr][$Xr])) $Xr++;
$Yr++;
*/
$sw = array();
$m=0;
$m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x]
[0]]['w']);
$sw[$x] = $m;
// on v�rifie que cette taille est valide avec les colones en colspan
$sw[$x+$i] =
$sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
}
}
if ($corr[$y][$x][2]==1)
$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]
['w'] = $sw[$x];
else
$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]
['w'] = $s;
$sh = array();
{
$m=0;
$m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x]
[0]]['h']);
$sh[$y] = $m;
// on v�rifie que cette taille est valide avec les lignes en rowspan
$sh[$y+$i] =
$sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
}
// on applique les nouvelles hauteurs
if ($corr[$y][$x][3]==1)
$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]
['h'] = $sh[$y];
else
$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]
['h'] = $s;
$tx = $x+1;
$ty = $y+$j;
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'];
}
}
/**
* balise : TH
* mode : OUVERTURE
* @return null
*/
function o_TH($param)
$this->maxH = 0;
if (!isset($param['style']['font-weight'])) $param['style']['font-weight'] =
'bold';
$this->o_TD($param, 'th');
return true;
/**
* balise : TH
* mode : FERMETURE
*/
function c_TH($param)
$this->maxH = 0;
// identique � TD
$this->c_TD($param);
return true;
/**
* balise : IMG
* mode : OUVERTURE
* @return null
*/
function o_IMG($param)
// analyse du style
$this->style->save();
$this->style->value['width'] = 0;
$this->style->value['height'] = 0;
$this->style->value['border'] = array(
);
$this->style->value['background'] = array(
);
$this->style->analyse('img', $param);
$this->style->setPosition();
$this->style->FontSet();
// affichage de l'image
// restauration du style
$this->style->load();
$this->style->FontSet();
$this->maxE++;
return true;
/**
* balise : SELECT
* mode : OUVERTURE
* @return null
*/
function o_SELECT($param)
// preparation du champs
$param['name'] = strtolower($param['name']);
if (isset($this->lstChamps[$param['name']]))
$this->lstChamps[$param['name']]++;
else
$this->lstChamps[$param['name']] = 1;
$this->style->save();
$this->style->analyse('select', $param);
$this->style->setPosition();
$this->style->FontSet();
$this->lstSelect = array();
$this->lstSelect['name'] = $param['name'];
$this->lstSelect['options'] = array();
/**
* balise : OPTION
* mode : OUVERTURE
* @return null
*/
function o_OPTION($param)
$level = $this->parsing->getLevel($this->parse_pos);
$this->parse_pos+= count($level);
return true;
/**
* balise : OPTION
* mode : FERMETURE
* @return null
*/
* balise : SELECT
* mode : FERMETURE
* @return null
*/
function c_SELECT()
// position d'affichage
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$f = 1.08*$this->style->value['font-size'];
$h = ($f*1.07*$this->lstSelect['size'] + 1);
$prop = array();
$this->pdf->setX($x+$w);
$this->style->load();
$this->style->FontSet();
$this->lstSelect = array();
return true;
/**
* balise : TEXTAREA
* mode : OUVERTURE
* @return null
*/
function o_TEXTAREA($param)
// preparation du champs
$param['name'] = strtolower($param['name']);
if (isset($this->lstChamps[$param['name']]))
$this->lstChamps[$param['name']]++;
else
$this->lstChamps[$param['name']] = 1;
$this->style->save();
$this->style->analyse('textarea', $param);
$this->style->setPosition();
$this->style->FontSet();
// position d'affichage
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$fx = 0.65*$this->style->value['font-size'];
$fy = 1.08*$this->style->value['font-size'];
$level = $this->parsing->getLevel($this->parse_pos);
$this->parse_pos+= count($level);
// if ($this->style->value['width']) $w = $this->style->value['width'];
// if ($this->style->value['height']) $h = $this->style->value['height'];
$prop = array();
$prop['multiline'] = true;
$this->pdf->setX($x+$w);
return true;
/**
* balise : TEXTAREA
* mode : FERMETURE
*
* @return null
*/
function c_TEXTAREA()
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : INPUT
* mode : OUVERTURE
* @return null
*/
function o_INPUT($param)
// preparation du champs
$param['name'] = strtolower($param['name']);
$param['type'] = strtolower($param['type']);
$this->lstChamps[$param['name']]++;
else
$this->lstChamps[$param['name']] = 1;
$this->style->save();
$this->style->analyse('input', $param);
$this->style->setPosition();
$this->style->FontSet();
$name = $param['name'];
// position d'affichage
$x = $this->pdf->getX();
$y = $this->pdf->getY();
$f = 1.08*$this->style->value['font-size'];
switch($param['type'])
case 'checkbox':
$w = 3;
$h = $w;
break;
case 'radio':
$w = 3;
$h = $w;
if ($h<$f) $y+= ($f-$h)*0.5;
break;
case 'hidden':
$w = 0;
$h = 0;
$this->pdf->form_InputHidden($name, $param['value']);
break;
case 'text':
$h = $f*1.3;
$prop = array();
$prop['value'] = $param['value'];
break;
case 'submit':
break;
case 'reset':
$action = 'this.resetForm();';
case 'button':
break;
default:
$w = 0;
$h = 0;
break;
$this->pdf->setX($x+$w);
$this->style->load();
$this->style->FontSet();
return true;
/**
* balise : DRAW
* mode : OUVERTURE
*
* @param array param�tres de l'�l�ment de parsing
* @return null
*/
function o_DRAW($param)
$this->style->save();
$this->style->analyse('draw', $param);
$this->style->FontSet();
$align_object = null;
$over_w = $this->style->value['width'];
$over_h = $this->style->value['height'];
$this->style->value['old_maxX'] = $this->maxX;
$this->style->value['old_maxY'] = $this->maxY;
$this->style->value['old_maxH'] = $this->maxH;
$w = $this->style->value['width'];
$h = $this->style->value['height'];
if (!$this->style->value['position'])
if (
)
$this->o_BR(array());
if (
($this->pdf->getY() + $h>=($this->pdf->getH() -
$this->pdf->getbMargin())) &&
!$this->isInOverflow
$this->setNewPage();
$old = $this->style->getOldValues();
if ($parent_w>$w)
if ($align_object=='center') $this->pdf-
>setX($this->pdf->getX() + ($parent_w-$w)*0.5);
$this->style->setPosition();
else
$old = $this->style->getOldValues();
if ($align_object=='center') $this->pdf-
>setX($this->pdf->getX() + ($parent_w-$w)*0.5);
$this->style->setPosition();
$this->saveMax();
$this->maxX = 0;
$this->maxY = 0;
$this->maxH = 0;
$this->maxE = 0;
$this->drawRectangle(
$this->style->value['x'],
$this->style->value['y'],
$this->style->value['width'],
$this->style->value['height'],
$this->style->value['border'],
$this->style->value['padding'],
0,
$this->style->value['background']
);
$marge = array();
$marge['l'] = $this->style->value['border']['l']['width'];
$marge['r'] = $this->style->value['border']['r']['width'];
$marge['t'] = $this->style->value['border']['t']['width'];
$marge['b'] = $this->style->value['border']['b']['width'];
$this->style->value['width'] -= $marge['l']+$marge['r'];
$this->style->value['height']-= $marge['t']+$marge['b'];
$over_w-= $marge['l']+$marge['r'];
$over_h-= $marge['t']+$marge['b'];
$this->pdf->clippingPathOpen(
$this->style->value['x']+$marge['l'],
$this->style->value['y']+$marge['t'],
$this->style->value['width'],
$this->style->value['height']
);
$mL = $this->style->value['x']+$marge['l'];
$x = $this->style->value['x']+$marge['l'];
$y = $this->style->value['y']+$marge['t'];
$this->saveMargin($mL, 0, $mR);
$this->pdf->setXY($x, $y);
$this->isInDraw = array(
);
$this->pdf->doTransform(array(1,0,0,1,$x,$y));
return true;
}
/**
* balise : DRAW
* mode : FERMETURE
* @return null
*/
function c_DRAW($param)
$this->pdf->undoTransform();
$this->pdf->clippingPathClose();
$this->maxX = $this->style->value['old_maxX'];
$this->maxY = $this->style->value['old_maxY'];
$this->maxH = $this->style->value['old_maxH'];
$marge = array();
$marge['l'] = $this->style->value['border']['l']['width'];
$marge['r'] = $this->style->value['border']['r']['width'];
$marge['t'] = $this->style->value['border']['t']['width'];
$marge['b'] = $this->style->value['border']['b']['width'];
$x = $this->style->value['x'];
$y = $this->style->value['y'];
$w = $this->style->value['width']+$marge['l']+$marge['r'];
$h = $this->style->value['height']+$marge['t']+$marge['b'];
if ($this->style->value['position']!='absolute')
// position
$this->pdf->setXY($x+$w, $y);
// position MAX
else
// position
$this->pdf->setXY($this->style->value['xc'], $this->style->value['yc']);
$this->loadMax();
$this->style->load();
$this->style->FontSet();
$this->loadMargin();
if ($block) $this->o_BR(array());
$this->isInDraw = null;
return true;
}
/**
* balise : LINE
* mode : OUVERTURE
* @return null
*/
function o_LINE($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$styles['fill'] = null;
$style = $this->pdf->svgSetStyle($styles);
$this->pdf->undoTransform();
$this->style->load();
}
/**
* balise : RECT
* mode : OUVERTURE
* @return null
*/
function o_RECT($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
$this->pdf->undoTransform();
$this->style->load();
/**
* balise : CIRCLE
* mode : OUVERTURE
* @return null
*/
function o_CIRCLE($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
$this->pdf->undoTransform();
$this->style->load();
/**
* balise : ELLIPSE
* mode : OUVERTURE
* @return null
*/
function o_ELLIPSE($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
$this->pdf->undoTransform();
$this->style->load();
/**
* balise : POLYLINE
* mode : OUVERTURE
* @return null
*/
function o_POLYLINE($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
if ($path)
// decoupage et nettoyage
$path[$k] = trim($v);
if ($path[$k]==='') unset($path[$k]);
$path = array_values($path);
$actions = array();
$this->style-
>ConvertToMM($path[$k+0], $this->isInDraw['w']),
$this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['h']));
// on trace
$this->pdf->svgPolygone($actions, $style);
$this->pdf->undoTransform();
$this->style->load();
/**
* balise : POLYGON
* mode : OUVERTURE
* @return null
*/
function o_POLYGON($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
if ($path)
{
$path = str_replace(',', ' ', $path);
// decoupage et nettoyage
$path[$k] = trim($v);
if ($path[$k]==='') unset($path[$k]);
$path = array_values($path);
$actions = array();
$this->style-
>ConvertToMM($path[$k+0], $this->isInDraw['w']),
$this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['h']));
$actions[] = array('z');
// on trace
$this->pdf->svgPolygone($actions, $style);
$this->pdf->undoTransform();
$this->style->load();
/**
* balise : PATH
* mode : OUVERTURE
* @return null
*/
function o_PATH($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
if ($path)
// preparation
// decoupage et nettoyage
$path[$k] = trim($v);
if ($path[$k]==='') unset($path[$k]);
}
$path = array_values($path);
$actions = array();
$action = array();
$action = array();
$action[] = $path[$k];
switch($path[$k])
case 'C':
case 'c':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['w']); // x1
$action[] = $this->style-
>ConvertToMM($path[$k+2], $this->isInDraw['h']); // y1
$action[] = $this->style-
>ConvertToMM($path[$k+3], $this->isInDraw['w']); // x2
$action[] = $this->style-
>ConvertToMM($path[$k+4], $this->isInDraw['h']); // y2
$action[] = $this->style-
>ConvertToMM($path[$k+5], $this->isInDraw['w']); // x
$action[] = $this->style-
>ConvertToMM($path[$k+6], $this->isInDraw['h']); // y
break;
case 'Q':
case 'S':
case 'q':
case 's':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['w']); // x2
$action[] = $this->style-
>ConvertToMM($path[$k+2], $this->isInDraw['h']); // y2
$action[] = $this->style-
>ConvertToMM($path[$k+3], $this->isInDraw['w']); // x
$action[] = $this->style-
>ConvertToMM($path[$k+4], $this->isInDraw['h']); // y
break;
case 'A':
case 'a':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['w']); // rx
$action[] = $this->style-
>ConvertToMM($path[$k+2], $this->isInDraw['h']); // ry
$action[] = 1.*$path[$k+3];
// angle de
deviation de l'axe X
$action[] = ($path[$k+4]=='1') ? 1 : 0;
// large-arc-flag
$action[] = ($path[$k+5]=='1') ? 1 : 0;
// sweep-flag
$action[] = $this->style-
>ConvertToMM($path[$k+6], $this->isInDraw['w']); // x
$action[] = $this->style-
>ConvertToMM($path[$k+7], $this->isInDraw['h']); // y
break;
case 'M':
case 'L':
case 'T':
case 'm':
case 'l':
case 't':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['w']); // x
$action[] = $this->style-
>ConvertToMM($path[$k+2], $this->isInDraw['h']); // y
break;
case 'H':
case 'h':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['w']); // x
break;
case 'V':
case 'v':
$action[] = $this->style-
>ConvertToMM($path[$k+1], $this->isInDraw['h']); // y
break;
case 'z':
case 'Z':
default:
break;
$actions[] = $action;
// on trace
$this->pdf->svgPolygone($actions, $style);
$this->pdf->undoTransform();
$this->style->load();
}
/**
* balise : G
* mode : OUVERTURE
* @return null
*/
function o_G($param)
$this->pdf->doTransform(isset($param['transform']) ? $this-
>_prepareTransform($param['transform']) : null);
$this->style->save();
$style = $this->pdf->svgSetStyle($styles);
/**
* balise : G
* mode : FERMETURE
* @return null
*/
function c_G($param)
$this->pdf->undoTransform();
$this->style->load();
function _prepareTransform($transform)
{
$actions = array();
$nom = strtolower($match[1][$k]);
$val[$i] = trim($j);
switch($nom)
case 'scale':
$actions[] = array($val[0],0,0,$val[1],0,0);
break;
case 'translate':
$actions[] = array(1,0,0,1,$val[0],$val[1]);
break;
case 'rotate':
if (!isset($val[0])) $val[0] = 0.; else $val[0] =
$val[0]*M_PI/180.;
$actions[] = array(cos($val[0]),sin($val[0]),-
sin($val[0]),cos($val[0]),0,0);
break;
case 'skewx':
$actions[] = array(1,0,tan($val[0]),1,0,0);
break;
case 'skewy':
$actions[] = array(1,tan($val[0]),0,1,0,0);
break;
case 'matrix':
$actions[] =$val;
break;
$m = $actions[0]; unset($actions[0]);
foreach($actions as $n)
$m = array(
$m[0]*$n[0]+$m[2]*$n[1],
$m[1]*$n[0]+$m[3]*$n[1],
$m[0]*$n[2]+$m[2]*$n[3],
$m[1]*$n[2]+$m[3]*$n[3],
$m[0]*$n[4]+$m[2]*$n[5]+$m[4],
$m[1]*$n[4]+$m[3]*$n[5]+$m[5]
);
return $m;
$v = trim($v);
if (!$correct)
$res[$k] = $this->style->ConvertToMM($v);
else
return $res;
/**
* @return null
*/
{
$old_page = $this->INDEX_NewPage($on_page);
if ($old_page) $this->pdf->setPage($old_page);
/**
* nouvelle page pour l'index. ne pas utiliser directement. seul MyPDF doit
l'utiliser !!!!
* @return null
*/
function INDEX_NewPage(&$page)
if ($page)
$old_page = $this->pdf->getPage();
$this->pdf->setPage($page);
$this->pdf->setXY($this->margeLeft, $this->margeTop);
$this->maxH = 0;
$page++;
return $old_page;
else
$this->setNewPage();
return null;
/**
* chargement du fichier de langue
* @return null
*/
function textLOAD($langue)
global $HTML2PDF_TEXTES;
if (!preg_match('/^([a-z0-9]+)$/isU', $langue))
exit;
$file = dirname(__FILE__).'/langues/'.strtolower($langue).'.txt';
if (!is_file($file))
echo 'You can create the translation file <b>'.$file.'</b> and send it
to me in order to integrate it into a future version.';
exit;
$texte = array();
$infos = file($file);
foreach($infos as $val)
$val = trim($val);
$HTML2PDF_TEXTES = $texte;
return true;
/**
* @return null
*/
function textGET($key)
global $HTML2PDF_TEXTES;
return $HTML2PDF_TEXTES[$key];
/**
*/
$msg = '';
switch($err)
case 1:
$msg = (HTML2PDF::textGET('err01'));
break;
case 2:
$msg = (HTML2PDF::textGET('err02'));
break;
case 3:
$msg = (HTML2PDF::textGET('err03'));
break;
case 4:
$msg = (HTML2PDF::textGET('err04'));
break;
case 5:
$msg = (HTML2PDF::textGET('err05'));
break;
case 6:
$msg = (HTML2PDF::textGET('err06'));
break;
case 7:
$msg = (HTML2PDF::textGET('err07'));
break;
case 8:
$msg = (HTML2PDF::textGET('err08'));
break;
case 9:
$msg = (HTML2PDF::textGET('err09'));
break;
echo '<br>';
echo $msg;
echo '<br>';
if ($html) echo '<br>HTML : ...'.htmlentities($html).'...';*/
if($msg != "") {
if(!empty($msg_arr[0])) {
echo $msg_arr[0];
exit;