Ejemplo n.º 1
0
function setCSS($arrayaux,$type='',$tag='') {	// type= INLINE | BLOCK | LIST // tag= BODY
	if (!is_array($arrayaux)) return; //Removes PHP Warning
	// Set font size first so that e.g. MARGIN 0.83em works on font size for this element
	if (isset($arrayaux['FONT-SIZE'])) {
		$v = $arrayaux['FONT-SIZE'];
		if(is_numeric($v[0])) {
			if ($type == 'BLOCK' && $this->blklvl>0 && isset($this->blk[$this->blklvl-1]['InlineProperties']) && isset($this->blk[$this->blklvl-1]['InlineProperties']['size'])) {
				$mmsize = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['InlineProperties']['size']);
			}
			else {
				$mmsize = $this->ConvertSize($v,$this->FontSize);
			}
			$this->SetFontSize( $mmsize*(_MPDFK),false ); //Get size in points (pt)
		}
		else{
  			$v = strtoupper($v);
			if (isset($this->fontsizes[$v])) { 
				$this->SetFontSize( $this->fontsizes[$v]* $this->default_font_size,false);
			}
		}
		if ($tag == 'BODY') { $this->SetDefaultFontSize($this->FontSizePt); }
	}


	if ($this->useLang && !$this->usingCoreFont) { 
	   if (isset($arrayaux['LANG']) && $arrayaux['LANG'] && $arrayaux['LANG'] != $this->default_lang && ((strlen($arrayaux['LANG']) == 5 && $arrayaux['LANG'] != 'UTF-8') || strlen($arrayaux['LANG']) == 2)) {
		list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($arrayaux['LANG'], $this->useAdobeCJK);
		if ($mpdf_pdf_unifonts) { $this->RestrictUnicodeFonts($mpdf_pdf_unifonts); }
		else { $this->RestrictUnicodeFonts($this->default_available_fonts ); }
		if ($tag == 'BODY') {
			$this->currentLang = $arrayaux['LANG'];
			$this->default_lang = $arrayaux['LANG'];
			if ($mpdf_pdf_unifonts) { $this->default_available_fonts = $mpdf_pdf_unifonts; }
		}
	   }
	   else { 
		$this->RestrictUnicodeFonts($this->default_available_fonts ); 
	   }
	}

	// FOR INLINE and BLOCK OR 'BODY'
	if (isset($arrayaux['FONT-FAMILY'])) {
		$v = $arrayaux['FONT-FAMILY'];
		//If it is a font list, get all font types
		$aux_fontlist = explode(",",$v);
		$found = 0;
		foreach($aux_fontlist AS $f) {
			$fonttype = trim($f);
			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
			$fonttype = preg_replace('/ /','',$fonttype);
			$v = strtolower(trim($fonttype));
			if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
			if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) || 
				in_array($v,array('ccourier','ctimes','chelvetica')) ||
				($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) || 
				in_array($v, array('sjis','uhc','big5','gb'))) { 
				$fonttype = $v; 
				$found = 1;
				break;
			}
		}
		if (!$found) {
		   foreach($aux_fontlist AS $f) {
			$fonttype = trim($f);
			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
			$fonttype = preg_replace('/ /','',$fonttype);
			$v = strtolower(trim($fonttype));
			if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
			if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) { 
				$fonttype = $v; 
				break;
			}
		   }
		}

		if ($tag == 'BODY') { 
			$this->SetDefaultFont($fonttype); 
		}
		$this->SetFont($fonttype,$this->currentfontstyle,0,false);
	}
	else { 
		$this->SetFont($this->currentfontfamily,$this->currentfontstyle,0,false); 
	}

   foreach($arrayaux as $k => $v) {
	if ($type != 'INLINE' && $tag != 'BODY' && $type != 'LIST') {
	  switch($k){
		// BORDERS
		case 'BORDER-TOP':
			$this->blk[$this->blklvl]['border_top'] = $this->border_details($v);
			if ($this->blk[$this->blklvl]['border_top']['s']) { $this->blk[$this->blklvl]['border'] = 1; }
			break;
		case 'BORDER-BOTTOM':
			$this->blk[$this->blklvl]['border_bottom'] = $this->border_details($v);
			if ($this->blk[$this->blklvl]['border_bottom']['s']) { $this->blk[$this->blklvl]['border'] = 1; }
			break;
		case 'BORDER-LEFT':
			$this->blk[$this->blklvl]['border_left'] = $this->border_details($v);
			if ($this->blk[$this->blklvl]['border_left']['s']) { $this->blk[$this->blklvl]['border'] = 1; }
			break;
		case 'BORDER-RIGHT':
			$this->blk[$this->blklvl]['border_right'] = $this->border_details($v);
			if ($this->blk[$this->blklvl]['border_right']['s']) { $this->blk[$this->blklvl]['border'] = 1; }
			break;

		// PADDING
		case 'PADDING-TOP':
			$this->blk[$this->blklvl]['padding_top'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'PADDING-BOTTOM':
			$this->blk[$this->blklvl]['padding_bottom'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'PADDING-LEFT':
			$this->blk[$this->blklvl]['padding_left'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'PADDING-RIGHT':
			$this->blk[$this->blklvl]['padding_right'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;

		// MARGINS
		case 'MARGIN-TOP':
			$tmp = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			if (isset($this->blk[$this->blklvl]['lastbottommargin'])) {
				if ($tmp > $this->blk[$this->blklvl]['lastbottommargin']) {
					$tmp -= $this->blk[$this->blklvl]['lastbottommargin'];
				}
				else { 
					$tmp = 0;
				}
			}
			$this->blk[$this->blklvl]['margin_top'] = $tmp;
			break;
		case 'MARGIN-BOTTOM':
			$this->blk[$this->blklvl]['margin_bottom'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'MARGIN-LEFT':
			$this->blk[$this->blklvl]['margin_left'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'MARGIN-RIGHT':
			$this->blk[$this->blklvl]['margin_right'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;

/*-- BORDER-RADIUS --*/
		case 'BORDER-TOP-LEFT-RADIUS-H':
			$this->blk[$this->blklvl]['border_radius_TL_H'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-TOP-LEFT-RADIUS-V':
			$this->blk[$this->blklvl]['border_radius_TL_V'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-TOP-RIGHT-RADIUS-H':
			$this->blk[$this->blklvl]['border_radius_TR_H'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-TOP-RIGHT-RADIUS-V':
			$this->blk[$this->blklvl]['border_radius_TR_V'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-BOTTOM-LEFT-RADIUS-H':
			$this->blk[$this->blklvl]['border_radius_BL_H'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-BOTTOM-LEFT-RADIUS-V':
			$this->blk[$this->blklvl]['border_radius_BL_V'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-BOTTOM-RIGHT-RADIUS-H':
			$this->blk[$this->blklvl]['border_radius_BR_H'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
		case 'BORDER-BOTTOM-RIGHT-RADIUS-V':
			$this->blk[$this->blklvl]['border_radius_BR_V'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
			break;
/*-- END BORDER-RADIUS --*/

		case 'BOX-SHADOW':
			$bs = $this->cssmgr->setCSSboxshadow($v);
			if ($bs) { $this->blk[$this->blklvl]['box_shadow'] = $bs; }
			break;

		case 'BACKGROUND-CLIP':
			if (strtoupper($v) == 'PADDING-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'padding-box'; }
			else if (strtoupper($v) == 'CONTENT-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'content-box'; }	// mPDF 5.6.09
			break;

		case 'PAGE-BREAK-AFTER':
			if (strtoupper($v) == 'AVOID') { $this->blk[$this->blklvl]['page_break_after_avoid'] = true; }
			else if (strtoupper($v) == 'ALWAYS' || strtoupper($v) == 'LEFT' || strtoupper($v) == 'RIGHT') { $this->blk[$this->blklvl]['page_break_after'] = strtoupper($v) ; }
			break;

		case 'WIDTH':
			if (strtoupper($v) != 'AUTO') { 
				$this->blk[$this->blklvl]['css_set_width'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); 
			}
			break;

		case 'TEXT-INDENT':
			// Left as raw value (may include 1% or 2em)
			$this->blk[$this->blklvl]['text_indent'] = $v;
			break;

	  }//end of switch($k)
	}


	if ($type != 'INLINE' && $type != 'LIST') {	// includes BODY tag
	  switch($k){

		case 'MARGIN-COLLAPSE':	// Custom tag to collapse margins at top and bottom of page
			if (strtoupper($v) == 'COLLAPSE') { $this->blk[$this->blklvl]['margin_collapse'] = true; }
			break;

		case 'LINE-HEIGHT':
			$this->blk[$this->blklvl]['line_height'] = $this->fixLineheight($v);
			if (!$this->blk[$this->blklvl]['line_height'] ) { $this->blk[$this->blklvl]['line_height'] = $this->normalLineheight; }
			break;

		case 'TEXT-ALIGN': //left right center justify
			switch (strtoupper($v)) {
				case 'LEFT': 
                        $this->blk[$this->blklvl]['align']="L";
                        break;
				case 'CENTER': 
                        $this->blk[$this->blklvl]['align']="C";
                        break;
				case 'RIGHT': 
                        $this->blk[$this->blklvl]['align']="R";
                        break;
				case 'JUSTIFY': 
                        $this->blk[$this->blklvl]['align']="J";
                        break;
			}
			break;

/*-- BACKGROUNDS --*/
		case 'BACKGROUND-GRADIENT': 
			if ($type  == 'BLOCK') {
				$this->blk[$this->blklvl]['gradient'] = $v;
			}
			break;
/*-- END BACKGROUNDS --*/

		case 'DIRECTION': 
			if ($v) { $this->blk[$this->blklvl]['direction'] = strtolower($v); }
			break;

	  }//end of switch($k)
	}

	// FOR INLINE ONLY
	if ($type == 'INLINE' || $type == 'LIST') {
	  switch($k){
		case 'DISPLAY':	// Custom tag to collapse margins at top and bottom of page
			if (strtoupper($v) == 'NONE') { $this->inlineDisplayOff = true; }
			break;
		case 'DIRECTION': 
			break;
	  }//end of switch($k)
	}
	// FOR INLINE ONLY
	if ($type == 'INLINE') {
	  switch($k){
		// BORDERS
		case 'BORDER-TOP':
			$this->spanborddet['T'] = $this->border_details($v);
			$this->spanborder = true;
			break;
		case 'BORDER-BOTTOM':
			$this->spanborddet['B'] = $this->border_details($v);
			$this->spanborder = true;
			break;
		case 'BORDER-LEFT':
			$this->spanborddet['L'] = $this->border_details($v);
			$this->spanborder = true;
			break;
		case 'BORDER-RIGHT':
			$this->spanborddet['R'] = $this->border_details($v);
			$this->spanborder = true;
			break;
		// mPDF 5.6.26
		case 'VISIBILITY':	// block is set in OpenTag
			$v = strtolower($v);
			if ($v == 'visible' || $v == 'hidden' || $v == 'printonly' || $v == 'screenonly') { 
				$this->textparam['visibility'] = $v;
			}
			break;
	  }//end of switch($k)
	}


	// FOR INLINE and BLOCK
	  switch($k){
		case 'TEXT-ALIGN': //left right center justify
			if (strtoupper($v) == 'NOJUSTIFY' && $this->blk[$this->blklvl]['align']=="J") {
                        $this->blk[$this->blklvl]['align']="";
			}
			break;
		// bgcolor only - to stay consistent with original html2fpdf
		case 'BACKGROUND': 
		case 'BACKGROUND-COLOR': 
			$cor = $this->ConvertColor($v);
			if ($cor) { 
			   if ($tag  == 'BODY') {
				$this->bodyBackgroundColor = $cor;
			   }
			   else if ($type == 'INLINE' || $type == 'LIST') {
				$this->spanbgcolorarray = $cor;
				$this->spanbgcolor = true;
			   }
			   else {
				$this->blk[$this->blklvl]['bgcolorarray'] = $cor;
				$this->blk[$this->blklvl]['bgcolor'] = true;
			   }
			}
			else if ($type != 'INLINE' && $type != 'LIST') {
  		  		if ($this->ColActive || $this->keep_block_together) { 
					$this->blk[$this->blklvl]['bgcolorarray'] = $this->blk[$this->blklvl-1]['bgcolorarray'] ;
					$this->blk[$this->blklvl]['bgcolor'] = $this->blk[$this->blklvl-1]['bgcolor'] ;
				}
			}
			break;

		// auto | normal | none
		case 'FONT-KERNING': 
			if ((strtoupper($v) == 'NORMAL' || strtoupper($v) == 'AUTO') && $this->useKerning) { $this->kerning = true; }
			else if (strtoupper($v) == 'NONE') { $this->kerning = false; }
			break;


		// normal | <length>
		case 'LETTER-SPACING': 
			$this->lSpacingCSS = $v;
			if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') { 
				$this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
			}
			break;

		// normal | <length>
		case 'WORD-SPACING': 
			$this->wSpacingCSS = $v;
			if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
				$this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
			}
			break;

		case 'FONT-STYLE': // italic normal oblique
			switch (strtoupper($v)) {
				case 'ITALIC': 
				case 'OBLIQUE': 
            			$this->SetStyle('I',true);
					break;
				case 'NORMAL': 
            			$this->SetStyle('I',false);
					break;
			}
			break;

		case 'FONT-WEIGHT': // normal bold //Does not support: bolder, lighter, 100..900(step value=100)
			switch (strtoupper($v))	{
				case 'BOLD': 
            			$this->SetStyle('B',true);
					break;
				case 'NORMAL': 
            			$this->SetStyle('B',false);
					break;
			}
			break;

		case 'VERTICAL-ALIGN': //super and sub only dealt with here e.g. <SUB> and <SUP>
			switch (strtoupper($v)) {
				case 'SUPER': 
                        $this->SUP=true;
                        $this->SUB=false;	// mPDF 5.6.07
                       break;
				case 'SUB': 
                        $this->SUB=true;
                        $this->SUP=false;	// mPDF 5.6.07
                       break;
				case 'BASELINE': 	// mPDF 5.6.07
                        $this->SUB=false;
                        $this->SUP=false;
                       break;
			}
			break;

		case 'TEXT-DECORATION': // none underline line-through (strikeout) //Does not support: overline, blink
			if (stristr($v,'LINE-THROUGH')) {
					$this->strike = true;
			}
			else if (stristr($v,'UNDERLINE')) {
            			$this->SetStyle('U',true);
			}
			else if (stristr($v,'NONE')) {
            			$this->SetStyle('U',false);
					$this->strike = false;	// mPDF 5.6.07
			}
			break;

		case 'FONT-VARIANT': 
			switch (strtoupper($v)) {
				case 'SMALL-CAPS': 
					$this->SetStyle('S',true);
					break;
				case 'NORMAL': 
					$this->SetStyle('S',false);
					break;
			}
			break;

		case 'TEXT-TRANSFORM': // none uppercase lowercase //Does support: capitalize
			switch (strtoupper($v)) { //Not working 100%
				case 'CAPITALIZE':
					$this->capitalize=true;	
					break;
				case 'UPPERCASE':
					$this->toupper=true;
					break;
				case 'LOWERCASE':
 					$this->tolower=true;
					break;
				case 'NONE': break;
			}
			break;

		case 'TEXT-SHADOW':
			$ts = $this->cssmgr->setCSStextshadow($v);
			if ($ts) { $this->textshadow = $ts; }
			break;

		case 'HYPHENS':	// mPDF 5.6.08
			if (strtoupper($v)=='NONE') {
				$this->textparam['hyphens'] = 2;
			}
			else if (strtoupper($v)=='AUTO') {
				$this->textparam['hyphens'] = 1;
			}
			else if (strtoupper($v)=='MANUAL') {
				$this->textparam['hyphens'] = 0;
			}
			break;

		case 'TEXT-OUTLINE': 	// mPDF 5.6.07
			if (strtoupper($v)=='NONE') {
				$this->textparam['outline-s'] = false;
			}
			break;

		case 'TEXT-OUTLINE-WIDTH': 	// mPDF 5.6.07
		case 'OUTLINE-WIDTH': 
			switch(strtoupper($v)) {
				case 'THIN': $v = '0.03em'; break;
				case 'MEDIUM': $v = '0.05em'; break;
				case 'THICK': $v = '0.07em'; break;
			}
			$w = $this->ConvertSize($v,$this->blk[$this->blklvl]['inner_width'],$this->FontSize);
			if ($w) {
				$this->textparam['outline-WIDTH'] = $w;
				$this->textparam['outline-s'] = true;
			}
			else { $this->textparam['outline-s'] = false; }
			break;

		case 'TEXT-OUTLINE-COLOR': 	// mPDF 5.6.07
		case 'OUTLINE-COLOR': 
			if (strtoupper($v) == 'INVERT') {
			   if ($this->colorarray) {
				$cor = $this->colorarray;
				$this->textparam['outline-COLOR'] = $this->_invertColor($cor);
			   }
			   else {
				$this->textparam['outline-COLOR'] = $this->ConvertColor(255);
			   }
			}
			else { 
		  	  $cor = $this->ConvertColor($v);
			  if ($cor) { $this->textparam['outline-COLOR'] = $cor ; }	  
			}
			break;

		case 'COLOR': // font color
			$cor = $this->ConvertColor($v);
			if ($cor) { 
				$this->colorarray = $cor;
				$this->SetTColor($cor);	
			}
		  break;


	  }//end of switch($k)


   }//end of foreach
}
Ejemplo n.º 2
0
Archivo: svg.php Proyecto: hipogea/zega
 function xml_svg2pdf_start($parser, $name, $attribs)
 {
     //
     //	definition
     global $svg_class, $last_gradid, $last_svg_fontid, $last_svg_fontdefw, $last_svg_fontstyle;
     // mPDF 6
     // mPDF 6
     if (strtolower($name) == 'font') {
         $last_svg_fontid = '';
         if (isset($attribs['horiz-adv-x']) && $attribs['horiz-adv-x']) {
             $last_svg_fontdefw = $attribs['horiz-adv-x'];
         }
         return;
     } else {
         if (strtolower($name) == 'font-face') {
             $last_svg_fontstyle = 'R';
             $last_svg_fontstyle .= isset($attribs['font-weight']) && $attribs['font-weight'] == 'bold' ? 'B' : '';
             $last_svg_fontstyle .= isset($attribs['font-style']) && $attribs['font-style'] == 'italic' ? 'I' : '';
             $last_svg_fontstyle .= isset($attribs['font-variant']) && $attribs['font-variant'] == 'small-caps' ? 'S' : '';
             if (isset($attribs['font-family']) && $attribs['font-family']) {
                 $tmp_svg_font = array('units-per-em' => isset($attribs['units-per-em']) ? $attribs['units-per-em'] : '', 'd' => '', 'glyphs' => array());
                 $last_svg_fontid = strtolower($attribs['font-family']);
                 if ($last_svg_fontdefw) {
                     $tmp_svg_font['horiz-adv-x'] = $last_svg_fontdefw;
                 } else {
                     $tmp_svg_font['horiz-adv-x'] = 500;
                 }
                 $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle] = $tmp_svg_font;
             }
             return;
         } else {
             if (strtolower($name) == 'missing-glyph') {
                 if ($last_svg_fontid && isset($attribs['horiz-adv-x'])) {
                     $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['horiz-adv-x'] = isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : '';
                     $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['d'] = isset($attribs['d']) ? $attribs['d'] : '';
                 }
                 return;
             } else {
                 if (strtolower($name) == 'glyph') {
                     if ($last_svg_fontid && isset($attribs['unicode'])) {
                         $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['glyphs'][$attribs['unicode']] = array('horiz-adv-x' => isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : $last_svg_fontdefw, 'd' => isset($attribs['d']) ? $attribs['d'] : '');
                     }
                     return;
                 } else {
                     if (strtolower($name) == 'lineargradient') {
                         $tmp_gradient = array('type' => 'linear', 'transform' => isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : '', 'units' => isset($attribs['gradientUnits']) ? $attribs['gradientUnits'] : '', 'spread' => isset($attribs['spreadMethod']) ? $attribs['spreadMethod'] : '', 'color' => array());
                         if (isset($attribs['x1'])) {
                             $tmp_gradient['info']['x1'] = $attribs['x1'];
                         }
                         if (isset($attribs['y1'])) {
                             $tmp_gradient['info']['y1'] = $attribs['y1'];
                         }
                         if (isset($attribs['x2'])) {
                             $tmp_gradient['info']['x2'] = $attribs['x2'];
                         }
                         if (isset($attribs['y2'])) {
                             $tmp_gradient['info']['y2'] = $attribs['y2'];
                         }
                         $last_gradid = $attribs['id'];
                         $svg_class->svgAddGradient($attribs['id'], $tmp_gradient);
                         return;
                     } else {
                         if (strtolower($name) == 'radialgradient') {
                             $tmp_gradient = array('type' => 'radial', 'transform' => isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : '', 'units' => isset($attribs['gradientUnits']) ? $attribs['gradientUnits'] : '', 'spread' => isset($attribs['spreadMethod']) ? $attribs['spreadMethod'] : '', 'color' => array());
                             if (isset($attribs['cx'])) {
                                 $tmp_gradient['info']['x0'] = $attribs['cx'];
                             }
                             if (isset($attribs['cy'])) {
                                 $tmp_gradient['info']['y0'] = $attribs['cy'];
                             }
                             if (isset($attribs['fx'])) {
                                 $tmp_gradient['info']['x1'] = $attribs['fx'];
                             }
                             if (isset($attribs['fy'])) {
                                 $tmp_gradient['info']['y1'] = $attribs['fy'];
                             }
                             if (isset($attribs['r'])) {
                                 $tmp_gradient['info']['r'] = $attribs['r'];
                             }
                             $last_gradid = $attribs['id'];
                             $svg_class->svgAddGradient($attribs['id'], $tmp_gradient);
                             return;
                         } else {
                             if (strtolower($name) == 'stop') {
                                 if (!$last_gradid) {
                                     break;
                                 }
                                 $color = '#000000';
                                 if (isset($attribs['style']) and preg_match('/stop-color:\\s*([^;]*)/i', $attribs['style'], $m)) {
                                     $color = trim($m[1]);
                                 } else {
                                     if (isset($attribs['stop-color']) && $attribs['stop-color']) {
                                         $color = $attribs['stop-color'];
                                     }
                                 }
                                 $col = $svg_class->mpdf_ref->ConvertColor($color);
                                 if (!$col) {
                                     $col = $svg_class->mpdf_ref->ConvertColor('#000000');
                                 }
                                 // In case "transparent" or "inherit" returned
                                 if ($col[0] == 3 || $col[0] == 5) {
                                     // RGB
                                     $color_final = sprintf('%.3F %.3F %.3F', ord($col[1]) / 255, ord($col[2]) / 255, ord($col[3]) / 255);
                                     $svg_class->svg_gradient[$last_gradid]['colorspace'] = 'RGB';
                                 } else {
                                     if ($col[0] == 4 || $col[0] == 6) {
                                         // CMYK
                                         $color_final = sprintf('%.3F %.3F %.3F %.3F', ord($col[1]) / 100, ord($col[2]) / 100, ord($col[3]) / 100, ord($col[4]) / 100);
                                         $svg_class->svg_gradient[$last_gradid]['colorspace'] = 'CMYK';
                                     } else {
                                         if ($col[0] == 1) {
                                             // Grayscale
                                             $color_final = sprintf('%.3F', ord($col[1]) / 255);
                                             $svg_class->svg_gradient[$last_gradid]['colorspace'] = 'Gray';
                                         }
                                     }
                                 }
                                 $stop_opacity = 1;
                                 if (isset($attribs['style']) and preg_match('/stop-opacity:\\s*([0-9.]*)/i', $attribs['style'], $m)) {
                                     $stop_opacity = $m[1];
                                 } else {
                                     if (isset($attribs['stop-opacity'])) {
                                         $stop_opacity = $attribs['stop-opacity'];
                                     } else {
                                         if ($col[0] == 5) {
                                             // RGBa
                                             $stop_opacity = ord($col[4] / 100);
                                         } else {
                                             if ($col[0] == 6) {
                                                 // CMYKa
                                                 $stop_opacity = ord($col[5] / 100);
                                             }
                                         }
                                     }
                                 }
                                 $tmp_color = array('color' => $color_final, 'offset' => isset($attribs['offset']) ? $attribs['offset'] : '', 'opacity' => $stop_opacity);
                                 array_push($svg_class->svg_gradient[$last_gradid]['color'], $tmp_color);
                                 return;
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($svg_class->inDefs) {
         return;
     }
     $svg_class->xbase = 0;
     $svg_class->ybase = 0;
     switch (strtolower($name)) {
         // Don't output stuff inside <defs>
         case 'defs':
             $svg_class->inDefs = true;
             return;
         case 'svg':
             $svg_class->svgOffset($attribs);
             break;
         case 'path':
             $path = $attribs['d'];
             preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\\-.\\d]+)*/', $path, $commands, PREG_SET_ORDER);
             $path_cmd = '';
             $svg_class->subPathInit = true;
             $svg_class->pathBBox = array(999999, 999999, -999999, -999999);
             foreach ($commands as $c) {
                 if (isset($c) && count($c) == 3 || isset($c[2]) && $c[2] == '') {
                     list($tmp, $command, $arguments) = $c;
                 } else {
                     list($tmp, $command) = $c;
                     $arguments = '';
                 }
                 $path_cmd .= $svg_class->svgPath($command, $arguments);
             }
             if ($svg_class->pathBBox[2] == -1999998) {
                 $svg_class->pathBBox[2] = 100;
             }
             if ($svg_class->pathBBox[3] == -1999998) {
                 $svg_class->pathBBox[3] = 100;
             }
             if ($svg_class->pathBBox[0] == 999999) {
                 $svg_class->pathBBox[0] = 0;
             }
             if ($svg_class->pathBBox[1] == 999999) {
                 $svg_class->pathBBox[1] = 0;
             }
             $critere_style = $attribs;
             unset($critere_style['d']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'rect':
             if (!isset($attribs['x'])) {
                 $attribs['x'] = 0;
             }
             if (!isset($attribs['y'])) {
                 $attribs['y'] = 0;
             }
             if (!isset($attribs['rx'])) {
                 $attribs['rx'] = 0;
             }
             if (!isset($attribs['ry'])) {
                 $attribs['ry'] = 0;
             }
             $arguments = array();
             if (isset($attribs['x'])) {
                 $arguments['x'] = $attribs['x'];
             }
             if (isset($attribs['y'])) {
                 $arguments['y'] = $attribs['y'];
             }
             if (isset($attribs['width'])) {
                 $arguments['w'] = $attribs['width'];
             }
             if (isset($attribs['height'])) {
                 $arguments['h'] = $attribs['height'];
             }
             if (isset($attribs['rx'])) {
                 $arguments['rx'] = $attribs['rx'];
             }
             if (isset($attribs['ry'])) {
                 $arguments['ry'] = $attribs['ry'];
             }
             $path_cmd = $svg_class->svgRect($arguments);
             $critere_style = $attribs;
             unset($critere_style['x'], $critere_style['y'], $critere_style['rx'], $critere_style['ry'], $critere_style['height'], $critere_style['width']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'circle':
             if (!isset($attribs['cx'])) {
                 $attribs['cx'] = 0;
             }
             if (!isset($attribs['cy'])) {
                 $attribs['cy'] = 0;
             }
             $arguments = array();
             if (isset($attribs['cx'])) {
                 $arguments['cx'] = $attribs['cx'];
             }
             if (isset($attribs['cy'])) {
                 $arguments['cy'] = $attribs['cy'];
             }
             if (isset($attribs['r'])) {
                 $arguments['rx'] = $attribs['r'];
             }
             if (isset($attribs['r'])) {
                 $arguments['ry'] = $attribs['r'];
             }
             $path_cmd = $svg_class->svgEllipse($arguments);
             $critere_style = $attribs;
             unset($critere_style['cx'], $critere_style['cy'], $critere_style['r']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'ellipse':
             if (!isset($attribs['cx'])) {
                 $attribs['cx'] = 0;
             }
             if (!isset($attribs['cy'])) {
                 $attribs['cy'] = 0;
             }
             $arguments = array();
             if (isset($attribs['cx'])) {
                 $arguments['cx'] = $attribs['cx'];
             }
             if (isset($attribs['cy'])) {
                 $arguments['cy'] = $attribs['cy'];
             }
             if (isset($attribs['rx'])) {
                 $arguments['rx'] = $attribs['rx'];
             }
             if (isset($attribs['ry'])) {
                 $arguments['ry'] = $attribs['ry'];
             }
             $path_cmd = $svg_class->svgEllipse($arguments);
             $critere_style = $attribs;
             unset($critere_style['cx'], $critere_style['cy'], $critere_style['rx'], $critere_style['ry']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'line':
             $arguments = array();
             $arguments[0] = isset($attribs['x1']) ? $attribs['x1'] : '';
             $arguments[1] = isset($attribs['y1']) ? $attribs['y1'] : '';
             $arguments[2] = isset($attribs['x2']) ? $attribs['x2'] : '';
             $arguments[3] = isset($attribs['y2']) ? $attribs['y2'] : '';
             $path_cmd = $svg_class->svgPolyline($arguments, false);
             $critere_style = $attribs;
             unset($critere_style['x1'], $critere_style['y1'], $critere_style['x2'], $critere_style['y2']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'polyline':
             $path = $attribs['points'];
             preg_match_all('/[0-9\\-\\.]*/', $path, $tmp, PREG_SET_ORDER);
             $arguments = array();
             for ($i = 0; $i < count($tmp); $i++) {
                 if ($tmp[$i][0] != '') {
                     array_push($arguments, $tmp[$i][0]);
                 }
             }
             $path_cmd = $svg_class->svgPolyline($arguments);
             $critere_style = $attribs;
             unset($critere_style['points']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
         case 'polygon':
             $path = $attribs['points'];
             preg_match_all('/([\\-]*[0-9\\.]+)/', $path, $tmp);
             $arguments = array();
             for ($i = 0; $i < count($tmp[0]); $i++) {
                 if ($tmp[0][$i] != '') {
                     array_push($arguments, $tmp[0][$i]);
                 }
             }
             $path_cmd = $svg_class->svgPolygon($arguments);
             //	definition du style de la forme:
             $critere_style = $attribs;
             unset($critere_style['points']);
             $path_style = $svg_class->svgDefineStyle($critere_style);
             break;
             // mPDF 5.7.4 Embedded image
         // mPDF 5.7.4 Embedded image
         case 'image':
             if (isset($attribs['xlink:href']) && $attribs['xlink:href']) {
                 $svg_class->svgImage($attribs);
             }
             break;
         case 'a':
             if (isset($attribs['xlink:href'])) {
                 unset($attribs['xlink:href']);
                 // this should be a hyperlink
                 // not handled like a xlink:href in other elements
             }
             // then continue like a <g>
         // then continue like a <g>
         case 'g':
             $array_style = $svg_class->svgDefineStyle($attribs);
             if (isset($array_style['transformations']) && $array_style['transformations']) {
                 // If in the middle of <text> element, add to textoutput, else WriteString
                 if ($svg_class->intext) {
                     $svg_class->textoutput .= ' q ' . $array_style['transformations'];
                 } else {
                     $svg_class->svgWriteString(' q ' . $array_style['transformations']);
                 }
             }
             array_push($svg_class->svg_style, $array_style);
             $svg_class->svgDefineTxtStyle($attribs);
             break;
         case 'text':
             $svg_class->textlength = 0;
             // mPDF 5.7.4
             $svg_class->texttotallength = 0;
             // mPDF 5.7.4
             $svg_class->textoutput = '';
             // mPDF 5.7.4
             $svg_class->textanchor = 'start';
             // mPDF 5.7.4
             $svg_class->textXorigin = 0;
             // mPDF 5.7.4
             $svg_class->textYorigin = 0;
             // mPDF 5.7.4
             $svg_class->intext = true;
             // mPDF 5.7.4
             $styl = '';
             if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) {
                 $classes = preg_split('/\\s+/', trim($attribs['class']));
                 foreach ($classes as $class) {
                     if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>' . strtoupper($class)])) {
                         $c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>' . strtoupper($class)];
                         foreach ($c as $prop => $val) {
                             $styl .= strtolower($prop) . ':' . $val . ';';
                         }
                     }
                 }
             }
             if (_SVG_AUTOFONT && isset($attribs['lang']) && $attribs['lang']) {
                 if (!$svg_class->mpdf_ref->usingCoreFont) {
                     if ($attribs['lang'] != $svg_class->mpdf_ref->default_lang) {
                         list($coreSuitable, $mpdf_unifont) = GetLangOpts($attribs['lang'], $svg_class->mpdf_ref->useAdobeCJK, $svg_class->mpdf_ref->fontdata);
                         if ($mpdf_unifont) {
                             $styl .= 'font-family:' . $mpdf_unifont . ';';
                         }
                     }
                 }
             }
             if ($styl) {
                 if (isset($attribs['style'])) {
                     $attribs['style'] = $styl . $attribs['style'];
                 } else {
                     $attribs['style'] = $styl;
                 }
             }
             $array_style = $svg_class->svgDefineStyle($attribs);
             if ($array_style['transformations']) {
                 $svg_class->textoutput .= ' q ' . $array_style['transformations'];
                 // mPDF 5.7.4
             }
             array_push($svg_class->svg_style, $array_style);
             $svg_class->txt_data = array();
             $x = isset($attribs['x']) ? $svg_class->ConvertSVGSizePixels($attribs['x'], 'x') : 0;
             // mPDF 5.7.4
             $y = isset($attribs['y']) ? $svg_class->ConvertSVGSizePixels($attribs['y'], 'y') : 0;
             // mPDF 5.7.4
             $x += isset($attribs['dx']) ? $svg_class->ConvertSVGSizePixels($attribs['dx'], 'x') : 0;
             // mPDF 5.7.4
             $y += isset($attribs['dy']) ? $svg_class->ConvertSVGSizePixels($attribs['dy'], 'y') : 0;
             // mPDF 5.7.4
             $svg_class->txt_data[0] = $x;
             // mPDF 5.7.4
             $svg_class->txt_data[1] = $y;
             // mPDF 5.7.4
             $critere_style = $attribs;
             unset($critere_style['x'], $critere_style['y']);
             $svg_class->svgDefineTxtStyle($critere_style);
             $svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style) - 1]['text-anchor'];
             // mPDF 5.7.4
             $svg_class->textXorigin = $svg_class->txt_data[0];
             // mPDF 5.7.4
             $svg_class->textYorigin = $svg_class->txt_data[1];
             // mPDF 5.7.4
             $svg_class->textjuststarted = true;
             // mPDF 5.7.4
             break;
             // mPDF 5.7.4
         // mPDF 5.7.4
         case 'tspan':
             // OUTPUT CHUNK(s) UP To NOW (svgText updates $svg_class->textlength)
             $p_cmd = $svg_class->svgText();
             $svg_class->textoutput .= $p_cmd;
             $tmp = count($svg_class->svg_style) - 1;
             $current_style = $svg_class->svg_style[$tmp];
             $styl = '';
             if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) {
                 $classes = preg_split('/\\s+/', trim($attribs['class']));
                 foreach ($classes as $class) {
                     if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>' . strtoupper($class)])) {
                         $c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>' . strtoupper($class)];
                         foreach ($c as $prop => $val) {
                             $styl .= strtolower($prop) . ':' . $val . ';';
                         }
                     }
                 }
             }
             if (_SVG_AUTOFONT && isset($attribs['lang']) && $attribs['lang']) {
                 if (!$svg_class->mpdf_ref->usingCoreFont) {
                     if ($attribs['lang'] != $svg_class->mpdf_ref->default_lang) {
                         list($coreSuitable, $mpdf_unifont) = GetLangOpts($attribs['lang'], $svg_class->mpdf_ref->useAdobeCJK, $svg_class->mpdf_ref->fontdata);
                         if ($mpdf_unifont) {
                             $styl .= 'font-family:' . $mpdf_unifont . ';';
                         }
                     }
                 }
             }
             if ($styl) {
                 if (isset($attribs['style'])) {
                     $attribs['style'] = $styl . $attribs['style'];
                 } else {
                     $attribs['style'] = $styl;
                 }
             }
             $array_style = $svg_class->svgDefineStyle($attribs);
             $svg_class->txt_data = array();
             // If absolute position adjustment (x or y), creates new block of text for text-alignment
             if (isset($attribs['x']) || isset($attribs['y'])) {
                 // If text-anchor middle|end, adjust
                 if ($svg_class->textanchor == 'end') {
                     $tx = -$svg_class->texttotallength;
                 } else {
                     if ($svg_class->textanchor == 'middle') {
                         $tx = -$svg_class->texttotallength / 2;
                     } else {
                         $tx = 0;
                     }
                 }
                 while (preg_match('/mPDF-AXS\\((.*?)\\)/', $svg_class->textoutput, $m)) {
                     if ($tx) {
                         $txk = $m[1] + $tx * $svg_class->kp;
                         $svg_class->textoutput = preg_replace('/mPDF-AXS\\((.*?)\\)/', sprintf('%.4F', $txk), $svg_class->textoutput, 1);
                     } else {
                         $svg_class->textoutput = preg_replace('/mPDF-AXS\\((.*?)\\)/', '\\1', $svg_class->textoutput, 1);
                     }
                 }
                 $svg_class->svgWriteString($svg_class->textoutput);
                 $svg_class->textXorigin += $svg_class->textlength;
                 $currentX = $svg_class->textXorigin;
                 $currentY = $svg_class->textYorigin;
                 $svg_class->textlength = 0;
                 $svg_class->texttotallength = 0;
                 $svg_class->textoutput = '';
                 $x = isset($attribs['x']) ? $svg_class->ConvertSVGSizePixels($attribs['x'], 'x') : $currentX;
                 $y = isset($attribs['y']) ? $svg_class->ConvertSVGSizePixels($attribs['y'], 'y') : $currentY;
                 $svg_class->txt_data[0] = $x;
                 $svg_class->txt_data[1] = $y;
                 $critere_style = $attribs;
                 unset($critere_style['x'], $critere_style['y']);
                 $svg_class->svgDefineTxtStyle($critere_style);
                 $svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style) - 1]['text-anchor'];
                 $svg_class->textXorigin = $x;
                 $svg_class->textYorigin = $y;
             } else {
                 $svg_class->textXorigin += $svg_class->textlength;
                 $currentX = $svg_class->textXorigin;
                 $currentY = $svg_class->textYorigin;
                 $currentX += isset($attribs['dx']) ? $svg_class->ConvertSVGSizePixels($attribs['dx'], 'x') : 0;
                 $currentY += isset($attribs['dy']) ? $svg_class->ConvertSVGSizePixels($attribs['dy'], 'y') : 0;
                 $svg_class->txt_data[0] = $currentX;
                 $svg_class->txt_data[1] = $currentY;
                 $critere_style = $attribs;
                 unset($critere_style['x'], $critere_style['y']);
                 $svg_class->svgDefineTxtStyle($critere_style);
                 $svg_class->textXorigin = $currentX;
                 $svg_class->textYorigin = $currentY;
             }
             if ($array_style['transformations']) {
                 $svg_class->textoutput .= ' q ' . $array_style['transformations'];
             }
             array_push($svg_class->svg_style, $array_style);
             break;
     }
     //
     //insertion des path et du style dans le flux de donné general.
     if (isset($path_cmd) && $path_cmd) {
         // mPDF 5.0
         list($prestyle, $poststyle) = $svg_class->svgStyle($path_style, $attribs, strtolower($name));
         if (isset($path_style['transformations']) && $path_style['transformations']) {
             // transformation on an element
             $svg_class->svgWriteString(" q " . $path_style['transformations'] . $prestyle . $path_cmd . $poststyle . " Q\n");
         } else {
             $svg_class->svgWriteString(" q " . $prestyle . $path_cmd . $poststyle . " Q\n");
             // mPDF 5.7.4
         }
     }
 }