Browse Source

update html2pdf library to ver 3.24

Juan Carlos Raña 15 years ago
parent
commit
4d1f853437

+ 26 - 13
main/inc/lib/html2pdf/_mypdf/01_fpdf_bookmark.class.php

@@ -123,20 +123,26 @@ require_once(dirname(__FILE__).'/00_fpdf_codebar.class.php');
 			}
 		}
 		
-		function CreateIndex($titre = 'Index', $size1 = 20, $size2 = 15)
+		function CreateIndex(&$obj, $titre = 'Index', $size_title = 20, $size_bookmark = 15, $bookmark_title = true, $display_page = true)
 		{
-			$this->Bookmark($titre, 0, -1);
+			if ($bookmark_title) $this->Bookmark($titre, 0, -1);
 			
 			//Index title
-			$this->SetFontSize($size1);
+			$this->SetFontSize($size_title);
 			$this->Cell(0,5,$titre,0,1,'C');
-			$this->SetFontSize($size2);
+			$this->SetFontSize($size_bookmark);
 			$this->Ln(10);
 			
 			$size=sizeof($this->outlines);
 			$PageCellSize=$this->GetStringWidth('p. '.$this->outlines[$size-1]['p'])+2;
 			for ($i=0;$i<$size;$i++)
 			{
+				if ($this->getY()+$this->FontSize>=($this->h - $this->bMargin))
+				{
+					$obj->setNewPage();
+					$this->SetFontSize($size_bookmark);
+				}
+				
 				//Offset
 				$level=$this->outlines[$i]['l'];
 				if($level>0) $this->Cell($level*8);
@@ -150,16 +156,23 @@ require_once(dirname(__FILE__).'/00_fpdf_codebar.class.php');
 					$str=substr($str,0,-1);
 					$strsize=$this->GetStringWidth($str);
 				}
-				$this->Cell($strsize+2,$this->FontSize+2,$str);
-			
-				//Filling dots
-				$w=$this->w-$this->lMargin-$this->rMargin-$PageCellSize-($level*8)-($strsize+2);
-				$nb=$w/$this->GetStringWidth('.');
-				$dots=str_repeat('.',$nb);
-				$this->Cell($w,$this->FontSize+2,$dots,0,0,'R');
+				if ($display_page)
+				{
+					$this->Cell($strsize+2,$this->FontSize+2,$str);
 				
-				//Page number
-				$this->Cell($PageCellSize,$this->FontSize+2,'p. '.$this->outlines[$i]['p'],0,1,'R');
+					//Filling dots
+					$w=$this->w-$this->lMargin-$this->rMargin-$PageCellSize-($level*8)-($strsize+2);
+					$nb=$w/$this->GetStringWidth('.');
+					$dots=str_repeat('.',$nb);
+					$this->Cell($w,$this->FontSize+2,$dots,0,0,'R');
+
+					//Page number
+					$this->Cell($PageCellSize,$this->FontSize+2,'p. '.$this->outlines[$i]['p'],0,1,'R');
+				}
+				else
+				{
+					$this->Cell($strsize+2,$this->FontSize+2,$str, 0, 1);					
+				}
 			}
 		}
 	}

+ 2 - 2
main/inc/lib/html2pdf/_mypdf/02_fpdf_formulaire.class.php

@@ -114,7 +114,7 @@ if (!defined('__CLASS_FPDF_FORMULAIRE__'))
 			static $aColors = array('transparent', 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'dkGray', 'gray', 'ltGray');
 			if (substr($color,0,1) == '#')
 			{
-				return sprintf("['RGB',%.3f,%.3f,%.3f]", hexdec(substr($color,1,2))/255, hexdec(substr($color,3,2))/255, hexdec(substr($color,5,2))/255);
+				return sprintf("['RGB',%.3F,%.3F,%.3F]", hexdec(substr($color,1,2))/255, hexdec(substr($color,3,2))/255, hexdec(substr($color,5,2))/255);
 			}
 			if (!in_array($color,$aColors))
 			{
@@ -155,7 +155,7 @@ if (!defined('__CLASS_FPDF_FORMULAIRE__'))
 			
 			// the followind avoid fields duplication after saving the document
 			$this->javascript .= "if(this.getField('pdfoldsaved') && this.getField('pdfoldsaved').value != 'saved') {";
-			$this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", $name, $type, $this->PageNo()-1, $x*$this->k, ($this->h-$y)*$this->k+1, ($x+$w)*$this->k, ($this->h-$y-$h)*$this->k+1)."\n";
+			$this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%d,[%.2F,%.2F,%.2F,%.2F]);", $name, $type, $this->PageNo()-1, $x*$this->k, ($this->h-$y)*$this->k+1, ($x+$w)*$this->k, ($this->h-$y-$h)*$this->k+1)."\n";
 			$this->javascript .= 'f'.$name.'.textSize='.$this->FontSizePt.";\n";
 			while (list($key, $val) = each($prop))
 			{

+ 28 - 28
main/inc/lib/html2pdf/_mypdf/mypdf.class.php

@@ -6,7 +6,7 @@
  * Distribué sous la licence LGPL. 
  *
  * @author		Laurent MINGUET <webmaster@spipu.net>
- * @version		3.22a - 15/06/2009
+ * @version		3.24 - 05/08/2009
  */
 
 if (!defined('__CLASS_MYPDF__'))
@@ -47,11 +47,11 @@ if (!defined('__CLASS_MYPDF__'))
 		function Footer()
 		{ 
 			$txt = '';
-			if ($this->footer_param['form'])	$txt = (HTML2PDF::textGET('pdf05'));
-			if ($this->footer_param['date'] && $this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(HTML2PDF::textGET('pdf03'));
-			if ($this->footer_param['date'] && !$this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(HTML2PDF::textGET('pdf01'));
-			if (!$this->footer_param['date'] && $this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(HTML2PDF::textGET('pdf02'));
-			if ($this->footer_param['page'])	$txt.= ($txt ? ' - ' : '').(HTML2PDF::textGET('pdf04'));
+			if ($this->footer_param['form'])	$txt = (@HTML2PDF::textGET('pdf05'));
+			if ($this->footer_param['date'] && $this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(@HTML2PDF::textGET('pdf03'));
+			if ($this->footer_param['date'] && !$this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(@HTML2PDF::textGET('pdf01'));
+			if (!$this->footer_param['date'] && $this->footer_param['heure'])	$txt.= ($txt ? ' - ' : '').(@HTML2PDF::textGET('pdf02'));
+			if ($this->footer_param['page'])	$txt.= ($txt ? ' - ' : '').(@HTML2PDF::textGET('pdf04'));
 			
 			$txt = str_replace('[[date_d]]',	date('d'),			$txt);
 			$txt = str_replace('[[date_m]]',	date('m'),			$txt);
@@ -165,7 +165,7 @@ if (!defined('__CLASS_MYPDF__'))
 			$points_string = '';
 			for($i=0; $i<count($points); $i+=2)
 			{
-				$points_string .= sprintf('%.2f %.2f', $points[$i]*$k, ($h-$points[$i+1])*$k);
+				$points_string .= sprintf('%.2F %.2F', $points[$i]*$k, ($h-$points[$i+1])*$k);
 				if($i==0)	$points_string .= ' m ';
 				else		$points_string .= ' l ';
 			}
@@ -356,9 +356,9 @@ if (!defined('__CLASS_MYPDF__'))
 					$MyArc = 4/3 * (sqrt(2) - 1);
 					
 					if ($coin_TL)
-						$path.= sprintf('%.2f %.2f m ', $x1+$coin_TL[0], $y1);
+						$path.= sprintf('%.2F %.2F m ', $x1+$coin_TL[0], $y1);
 					else
-						$path.= sprintf('%.2f %.2f m ', $x1, $y1);
+						$path.= sprintf('%.2F %.2F m ', $x1, $y1);
 					
 					if ($coin_TR)
 					{
@@ -367,11 +367,11 @@ if (!defined('__CLASS_MYPDF__'))
 						$xt2 = ($x2-$coin_TR[0])+$coin_TR[0];
 						$yt2 = ($y2+$coin_TR[1])-$coin_TR[1]*$MyArc;
 
-						$path.= sprintf('%.2f %.2f l ', $x2-$coin_TR[0], $y2);						
-						$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2+$coin_TR[1]);
+						$path.= sprintf('%.2F %.2F l ', $x2-$coin_TR[0], $y2);						
+						$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2+$coin_TR[1]);
 					}
 					else
-						$path.= sprintf('%.2f %.2f l ', $x2, $y2);
+						$path.= sprintf('%.2F %.2F l ', $x2, $y2);
 
 					if ($coin_BR)
 					{
@@ -380,11 +380,11 @@ if (!defined('__CLASS_MYPDF__'))
 						$xt2 = ($x3-$coin_BR[0])+$coin_BR[0]*$MyArc;
 						$yt2 = ($y3-$coin_BR[1])+$coin_BR[1];
 
-						$path.= sprintf('%.2f %.2f l ', $x3, $y3-$coin_BR[1]);						
-						$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $x3-$coin_BR[0], $y3);
+						$path.= sprintf('%.2F %.2F l ', $x3, $y3-$coin_BR[1]);						
+						$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3-$coin_BR[0], $y3);
 					}
 					else
-						$path.= sprintf('%.2f %.2f l ', $x3, $y3);
+						$path.= sprintf('%.2F %.2F l ', $x3, $y3);
 
 					if ($coin_BL)
 					{
@@ -393,11 +393,11 @@ if (!defined('__CLASS_MYPDF__'))
 						$xt2 = ($x4+$coin_BL[0])-$coin_BL[0];
 						$yt2 = ($y4-$coin_BL[1])+$coin_BL[1]*$MyArc;
 
-						$path.= sprintf('%.2f %.2f l ', $x4+$coin_BL[0], $y4);						
-						$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4-$coin_BL[1]);
+						$path.= sprintf('%.2F %.2F l ', $x4+$coin_BL[0], $y4);						
+						$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4-$coin_BL[1]);
 					}
 					else
-						$path.= sprintf('%.2f %.2f l ', $x4, $y4);
+						$path.= sprintf('%.2F %.2F l ', $x4, $y4);
 				
 					if ($coin_TL)
 					{
@@ -406,16 +406,16 @@ if (!defined('__CLASS_MYPDF__'))
 						$xt2 = ($x1+$coin_TL[0])-$coin_TL[0]*$MyArc;
 						$yt2 = ($y1+$coin_TL[1])-$coin_TL[1];
 
-						$path.= sprintf('%.2f %.2f l ', $x1, $y1+$coin_TL[1]);						
-						$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $x1+$coin_TL[0], $y1);
+						$path.= sprintf('%.2F %.2F l ', $x1, $y1+$coin_TL[1]);						
+						$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1+$coin_TL[0], $y1);
 					}
 				}
 				else
 				{
-					$path.= sprintf('%.2f %.2f m ', $x1, $y1);
-					$path.= sprintf('%.2f %.2f l ', $x2, $y2);
-					$path.= sprintf('%.2f %.2f l ', $x3, $y3);
-					$path.= sprintf('%.2f %.2f l ', $x4, $y4);
+					$path.= sprintf('%.2F %.2F m ', $x1, $y1);
+					$path.= sprintf('%.2F %.2F l ', $x2, $y2);
+					$path.= sprintf('%.2F %.2F l ', $x3, $y3);
+					$path.= sprintf('%.2F %.2F l ', $x4, $y4);
 				}
 
 				$path.= ' h W n';
@@ -456,8 +456,8 @@ if (!defined('__CLASS_MYPDF__'))
 
 			}
 
-			$path.= sprintf('%.2f %.2f m ', $ext1_x, $ext1_y);
-			$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $ext2_x, $ext2_y);
+			$path.= sprintf('%.2F %.2F m ', $ext1_x, $ext1_y);
+			$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2_x, $ext2_y);
 
 			if ($int1_x-$cen_x!=0)
 			{
@@ -475,8 +475,8 @@ if (!defined('__CLASS_MYPDF__'))
 
 			}
 			
-			$path.= sprintf('%.2f %.2f l ', $int2_x, $int2_y);
-			$path.= sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $xt1, $yt1, $xt2, $yt2, $int1_x, $int1_y);
+			$path.= sprintf('%.2F %.2F l ', $int2_x, $int2_y);
+			$path.= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1_x, $int1_y);
 
 			$this->_out($path . 'f');
 		}

File diff suppressed because it is too large
+ 144 - 137
main/inc/lib/html2pdf/html2pdf.class.php


+ 4 - 4
main/inc/lib/html2pdf/parsingHTML.class.php

@@ -6,7 +6,7 @@
  * Distribué sous la licence LGPL. 
  *
  * @author		Laurent MINGUET <webmaster@spipu.net>
- * @version		3.22a - 15/06/2009
+ * @version		3.24 - 05/08/2009
  */
  
 if (!defined('__CLASS_PARSINGHTML__'))
@@ -122,9 +122,9 @@ if (!defined('__CLASS_PARSINGHTML__'))
 							if ($res['close'])
 							{
 								if (count($parents)<1)
-									HTML2PDF::makeError(3, __FILE__, __LINE__, $res['name']);
+									@HTML2PDF::makeError(3, __FILE__, __LINE__, $res['name']);
 								else if ($parents[count($parents)-1]!=$res['name'])
-									HTML2PDF::makeError(4, __FILE__, __LINE__, $parents);
+									@HTML2PDF::makeError(4, __FILE__, __LINE__, $parents);
 								else
 									unset($parents[count($parents)-1]);
 							}
@@ -159,7 +159,7 @@ if (!defined('__CLASS_PARSINGHTML__'))
 						$todos[$k]['param']['txt'] = preg_replace('/([^\s])([\s]*)$/isU', '$1', 	$todos[$k]['param']['txt']);
 				}
 			}
-			if (count($parents)) HTML2PDF::makeError(5, __FILE__, __LINE__, $parents);
+			if (count($parents)) @HTML2PDF::makeError(5, __FILE__, __LINE__, $parents);
 			
 			// liste des actions sauvée
 			$this->code = $todos;

+ 34 - 18
main/inc/lib/html2pdf/styleHTML.class.php

@@ -6,7 +6,7 @@
  * Distribué sous la licence LGPL. 
  *
  * @author		Laurent MINGUET <webmaster@spipu.net>
- * @version		3.22a - 15/06/2009
+ * @version		3.24 - 05/08/2009
  */
  
 if (!defined('__CLASS_STYLEHTML__'))
@@ -387,6 +387,11 @@ if (!defined('__CLASS_STYLEHTML__'))
 			}
 		}
 
+		function restorePosition(&$current_x, &$current_y)
+		{
+			if ($this->value['y']==$current_y) $current_y = $this->value['yc'];
+		}
+		
 		function setPosition(&$current_x, &$current_y)
 		{
 			$this->value['xc'] = $current_x;
@@ -499,6 +504,8 @@ if (!defined('__CLASS_STYLEHTML__'))
 					
 			// interpreration des nouvelles valeurs
 			$correct_width = false;
+			$no_width = true;
+
 			foreach($styles as $nom => $val)
 			{
 				switch($nom)
@@ -558,6 +565,7 @@ if (!defined('__CLASS_STYLEHTML__'))
 					case 'width':
 						$this->value['width'] = $this->ConvertToMM($val, $this->getLastWidth());
 						if ($this->value['width'] && substr($val, -1)=='%') $correct_width=true;
+						$no_width = false;
 						break;
 					
 					case 'height':
@@ -880,28 +888,36 @@ if (!defined('__CLASS_STYLEHTML__'))
 			if ($this->onlyLeft) $this->value['text-align'] = 'left';
 			
 			// correction de la largeur pour correspondre au modèle de boite quick
-			if ($correct_width)
+			if ($no_width && in_array($balise, array('div')) && $this->value['position']!='absolute')
 			{
-				if (!in_array($balise, array('table', 'div', 'hr')))
-				{
-					$this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
-					$this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
-				}
-				if (in_array($balise, array('th', 'td')))
-				{
-					$this->value['width']-= $this->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
-				}
-				if ($this->value['width']<0) $this->value['width']=0;
+				$this->value['width'] = $this->getLastWidth();
+				$this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
 			}
 			else
 			{
-				if ($this->value['width'])
+				if ($correct_width)
 				{
-					if ($this->value['border']['l']['width'])	$this->value['width']	+= $this->value['border']['l']['width'];
-					if ($this->value['border']['r']['width'])	$this->value['width']	+= $this->value['border']['r']['width'];			
-					if ($this->value['padding']['l'])			$this->value['width']	+= $this->value['padding']['l'];
-					if ($this->value['padding']['r'])			$this->value['width']	+= $this->value['padding']['r'];
-				}		
+					if (!in_array($balise, array('table', 'div', 'hr')))
+					{
+						$this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
+						$this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
+					}
+					if (in_array($balise, array('th', 'td')))
+					{
+						$this->value['width']-= $this->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
+					}
+					if ($this->value['width']<0) $this->value['width']=0;
+				}
+				else
+				{
+					if ($this->value['width'])
+					{
+						if ($this->value['border']['l']['width'])	$this->value['width']	+= $this->value['border']['l']['width'];
+						if ($this->value['border']['r']['width'])	$this->value['width']	+= $this->value['border']['r']['width'];			
+						if ($this->value['padding']['l'])			$this->value['width']	+= $this->value['padding']['l'];
+						if ($this->value['padding']['r'])			$this->value['width']	+= $this->value['padding']['r'];
+					}		
+				}
 			}
 			if ($this->value['height'])
 			{

Some files were not shown because too many files changed in this diff