| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | -// svg class modified for mPDF version 6.0 by Ian Back: based on - | |
| 2 | +// svg class modified for mPDF version 4.4.003 by Ian Back: based on - | |
| 3 | 3 | // svg2pdf fpdf class |
| 4 | 4 | // sylvain briand ([email protected]), modified by rick trevino ([email protected]) |
| 5 | 5 | // http://www.godisaduck.com/svg2pdf_with_fpdf |
| 6 | 6 | // http://rhodopsin.blogspot.com |
| @@ -7,33 +7,13 @@ | ||
| 7 | 7 | // |
| 8 | 8 | // cette class etendue est open source, toute modification devra cependant etre repertori�e~ |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -// If you wish to use Automatic Font selection within SVG's. change this definition to true. | |
| 12 | -// This selects different fonts for different scripts used in text. | |
| 13 | -// This can be enabled/disabled independently of the use of Automatic Font selection within mPDF generally. | |
| 14 | -// Choice of font is determined by the config_script2lang.php and config_lang2fonts.php files, the same as for mPDF generally. | |
| 15 | -if (!defined("_SVG_AUTOFONT")) { define("_SVG_AUTOFONT", false); } | |
| 16 | - | |
| 17 | -// Enable a limited use of classes within SVG <text> elements by setting this to true. | |
| 18 | -// This allows recognition of a "class" attribute on a <text> element. | |
| 19 | -// The CSS style for that class should be outside the SVG, and cannot use any other selectors (i.e. only .class {} can be defined) | |
| 20 | -// <style> definitions within the SVG code will be recognised if the SVG is included as an inline item within the HTML code passed to mPDF. | |
| 21 | -// The style property should be pertinent to SVG e.g. use fill:red rather than color:red | |
| 22 | -// Only the properties currently supported for SVG text can be specified: | |
| 23 | -// fill, fill-opacity, stroke, stroke-opacity, stroke-linecap, stroke-linejoin, stroke-width, stroke-dasharray, stroke-dashoffset | |
| 24 | -// font-family, font-size, font-weight, font-variant, font-style, opacity, text-anchor | |
| 25 | -if (!defined("_SVG_CLASSES")) { define("_SVG_CLASSES", false); } | |
| 26 | - | |
| 27 | - | |
| 28 | - | |
| 29 | - | |
| 30 | 11 | // NB UNITS - Works in pixels as main units - converting to PDF units when outputing to PDF string |
| 31 | 12 | // and on returning size |
| 32 | 13 | |
| 33 | 14 | class SVG { |
| 34 | 15 | |
| 35 | - var $svg_font; // array - holds content of SVG fonts defined in image // mPDF 6 | |
| 36 | 16 | var $svg_gradient; // array - contient les infos sur les gradient fill du svg class� par id du svg |
| 37 | 17 | var $svg_shadinglist; // array - contient les ids des objet shading |
| 38 | 18 | var $svg_info; // array contenant les infos du svg voulue par l'utilisateur |
| 39 | 19 | var $svg_attribs; // array - holds all attributes of root <svg> tag |
| @@ -41,35 +21,18 @@ | ||
| 41 | 21 | var $svg_string; // String contenant le tracage du svg en lui m�me. |
| 42 | 22 | var $txt_data; // array - holds string info to write txt to image |
| 43 | 23 | var $txt_style; // array - current text style |
| 44 | 24 | var $mpdf_ref; |
| 45 | - var $xbase; | |
| 46 | - var $ybase; | |
| 47 | - var $svg_error; | |
| 48 | - var $subPathInit; | |
| 49 | - var $spxstart; | |
| 50 | - var $spystart; | |
| 51 | - var $kp; // convert pixels to PDF units | |
| 52 | - var $pathBBox; | |
| 25 | + var $xbase; // mPDF 4.4.003 | |
| 26 | + var $ybase; // mPDF 4.4.003 | |
| 27 | + var $svg_error; // mPDF 4.4.003 | |
| 28 | + var $subPathInit; // mPDF 4.4.003 | |
| 29 | + var $spxstart; // mPDF 4.4.003 | |
| 30 | + var $spystart; // mPDF 4.4.003 | |
| 31 | + var $kp; // mPDF 4.4.003 convert pixels to PDF units | |
| 32 | + var $pathBBox; // mPDF 5.0.039 | |
| 53 | 33 | |
| 54 | - var $script2lang; | |
| 55 | - var $viet; | |
| 56 | - var $pashto; | |
| 57 | - var $urdu; | |
| 58 | - var $persian; | |
| 59 | - var $sindhi; | |
| 60 | - | |
| 61 | - var $textlength; // mPDF 5.7.4 | |
| 62 | - var $texttotallength; // mPDF 5.7.4 | |
| 63 | - var $textoutput; // mPDF 5.7.4 | |
| 64 | - var $textanchor; // mPDF 5.7.4 | |
| 65 | - var $textXorigin; // mPDF 5.7.4 | |
| 66 | - var $textYorigin; // mPDF 5.7.4 | |
| 67 | - var $textjuststarted; // mPDF 5.7.4 | |
| 68 | - var $intext; // mPDF 5.7.4 | |
| 69 | - | |
| 70 | 34 | function SVG(&$mpdf){ |
| 71 | - $this->svg_font = array(); // mPDF 6 | |
| 72 | 35 | $this->svg_gradient = array(); |
| 73 | 36 | $this->svg_shadinglist = array(); |
| 74 | 37 | $this->txt_data = array(); |
| 75 | 38 | $this->svg_string = ''; |
| @@ -77,39 +40,30 @@ | ||
| 77 | 40 | $this->svg_attribs = array(); |
| 78 | 41 | $this->xbase = 0; |
| 79 | 42 | $this->ybase = 0; |
| 80 | 43 | $this->svg_error = false; |
| 81 | - $this->subPathInit = false; | |
| 82 | - $this->dashesUsed = false; | |
| 44 | + $this->subPathInit = false; // mPDF 4.4.003 | |
| 45 | + $this->dashesUsed = false; // mPDF 5.0 | |
| 83 | 46 | $this->mpdf_ref =& $mpdf; |
| 84 | 47 | |
| 85 | - $this->textlength = 0; // mPDF 5.7.4 | |
| 86 | - $this->texttotallength = 0; // mPDF 5.7.4 | |
| 87 | - $this->textoutput = ''; // mPDF 5.7.4 | |
| 88 | - $this->textanchor = 'start'; // mPDF 5.7.4 | |
| 89 | - $this->textXorigin = 0; // mPDF 5.7.4 | |
| 90 | - $this->textYorigin = 0; // mPDF 5.7.4 | |
| 91 | - $this->textjuststarted = false; // mPDF 5.7.4 | |
| 92 | - $this->intext = false; // mPDF 5.7.4 | |
| 48 | + $this->kp = 72 / $mpdf->img_dpi; // mPDF 4.4.003 constant To convert pixels to pts/PDF units | |
| 49 | + $this->kf = 1; // mPDF 5.0.039 constant To convert font size if re-mapped | |
| 50 | + $this->pathBBox = array(); // mPDF 5.0.039 | |
| 93 | 51 | |
| 94 | - $this->kp = 72 / $mpdf->img_dpi; // constant To convert pixels to pts/PDF units | |
| 95 | - $this->kf = 1; // constant To convert font size if re-mapped | |
| 96 | - $this->pathBBox = array(); | |
| 97 | - | |
| 98 | 52 | $this->svg_style = array( |
| 99 | 53 | array( |
| 100 | - 'fill' => 'black', | |
| 54 | + 'fill' => 'black', // mPDF 4.4.008 | |
| 101 | 55 | 'fill-opacity' => 1, // remplissage opaque par defaut |
| 102 | 56 | 'fill-rule' => 'nonzero', // mode de remplissage par defaut |
| 103 | 57 | 'stroke' => 'none', // pas de trait par defaut |
| 104 | 58 | 'stroke-linecap' => 'butt', // style de langle par defaut |
| 105 | - 'stroke-linejoin' => 'miter', | |
| 59 | + 'stroke-linejoin' => 'miter', // | |
| 106 | 60 | 'stroke-miterlimit' => 4, // limite de langle par defaut |
| 107 | 61 | 'stroke-opacity' => 1, // trait opaque par defaut |
| 108 | - 'stroke-width' => 1, | |
| 109 | - 'stroke-dasharray' => 0, | |
| 110 | - 'stroke-dashoffset' => 0, | |
| 111 | - 'color' => '' | |
| 62 | + 'stroke-width' => 1, // mPDF 4.4.011 | |
| 63 | + 'stroke-dasharray' => 0, // mPDF 4.4.003 | |
| 64 | + 'stroke-dashoffset' => 0, // mPDF 4.4.003 | |
| 65 | + 'color' => '' // mPDF 4.4.005 | |
| 112 | 66 | ) |
| 113 | 67 | ); |
| 114 | 68 | |
| 115 | 69 | $this->txt_style = array( |
| @@ -119,14 +73,15 @@ | ||
| 119 | 73 | 'font-size' => $mpdf->default_font_size, // ****** this is pts |
| 120 | 74 | 'font-weight' => 'normal', // normal | bold |
| 121 | 75 | 'font-style' => 'normal', // italic | normal |
| 122 | 76 | 'text-anchor' => 'start', // alignment: start, middle, end |
| 77 | +/* mPDF 5.0.041 */ | |
| 123 | 78 | 'fill-opacity' => 1, // remplissage opaque par defaut |
| 124 | 79 | 'fill-rule' => 'nonzero', // mode de remplissage par defaut |
| 125 | 80 | 'stroke' => 'none', // pas de trait par defaut |
| 126 | 81 | 'stroke-opacity' => 1, // trait opaque par defaut |
| 127 | - 'stroke-width' => 1, | |
| 128 | - 'color' => '' | |
| 82 | + 'stroke-width' => 1, // mPDF 4.4.011 | |
| 83 | + 'color' => '' // mPDF 4.4.005 | |
| 129 | 84 | ) |
| 130 | 85 | ); |
| 131 | 86 | |
| 132 | 87 | |
| @@ -132,125 +87,8 @@ | ||
| 132 | 87 | |
| 133 | 88 | |
| 134 | 89 | } |
| 135 | 90 | |
| 136 | - // mPDF 5.7.4 Embedded image | |
| 137 | - function svgImage($attribs) { | |
| 138 | - // x and y are coordinates | |
| 139 | - $x = (isset($attribs['x']) ? $attribs['x'] : 0); | |
| 140 | - $y = (isset($attribs['y']) ? $attribs['y'] : 0); | |
| 141 | - // preserveAspectRatio | |
| 142 | - $par = (isset($attribs['preserveAspectRatio']) ? $attribs['preserveAspectRatio'] : 'xMidYMid meet'); | |
| 143 | - // width and height are <lengths> - Required attributes | |
| 144 | - $wset = (isset($attribs['width']) ? $attribs['width'] : 0); | |
| 145 | - $hset = (isset($attribs['height']) ? $attribs['height'] : 0); | |
| 146 | - $w = $this->mpdf_ref->ConvertSize($wset,$this->svg_info['w']*(25.4/$this->mpdf_ref->dpi),$this->mpdf_ref->FontSize,false); | |
| 147 | - $h = $this->mpdf_ref->ConvertSize($hset,$this->svg_info['h']*(25.4/$this->mpdf_ref->dpi),$this->mpdf_ref->FontSize,false); | |
| 148 | - if ($w==0 || $h==0) { return; } | |
| 149 | - // Convert to pixels = SVG units | |
| 150 | - $w *= 1/(25.4/$this->mpdf_ref->dpi); | |
| 151 | - $h *= 1/(25.4/$this->mpdf_ref->dpi); | |
| 152 | - | |
| 153 | - $srcpath = $attribs['xlink:href']; | |
| 154 | - $orig_srcpath = ''; | |
| 155 | - if (trim($srcpath) != '' && substr($srcpath,0,4)=='var:') { | |
| 156 | - $orig_srcpath = $srcpath; | |
| 157 | - $this->mpdf_ref->GetFullPath($srcpath); | |
| 158 | - } | |
| 159 | - | |
| 160 | - // Image file (does not allow vector images i.e. WMF/SVG) | |
| 161 | - // mPDF 6 Added $this->mpdf_ref->interpolateImages | |
| 162 | - $info = $this->mpdf_ref->_getImage($srcpath, true, false, $orig_srcpath, $this->mpdf_ref->interpolateImages); | |
| 163 | - if(!$info) return; | |
| 164 | - | |
| 165 | - // x,y,w,h define the reference rectangle | |
| 166 | - $img_h = $h; | |
| 167 | - $img_w = $w; | |
| 168 | - $img_x = $x; | |
| 169 | - $img_y = $y; | |
| 170 | - $meetOrSlice = 'meet'; | |
| 171 | - | |
| 172 | - // preserveAspectRatio | |
| 173 | - $ar = preg_split('/\s+/', strtolower($par)); | |
| 174 | - if ($ar[0]!='none') { // If "none" need to do nothing | |
| 175 | - // Force uniform scaling | |
| 176 | - if (isset($ar[1]) && $ar[1]=='slice') { $meetOrSlice = 'slice'; } | |
| 177 | - else { $meetOrSlice = 'meet'; } | |
| 178 | - if ($info['h']/$info['w'] > $h/$w) { | |
| 179 | - if ($meetOrSlice == 'meet') { // the entire viewBox is visible within the viewport | |
| 180 | - $img_w = $img_h * $info['w']/$info['h']; | |
| 181 | - } | |
| 182 | - else { // the entire viewport is covered by the viewBox | |
| 183 | - $img_h = $img_w * $info['h']/$info['w']; | |
| 184 | - } | |
| 185 | - } | |
| 186 | - else if ($info['h']/$info['w'] < $h/$w) { | |
| 187 | - if ($meetOrSlice == 'meet') { // the entire viewBox is visible within the viewport | |
| 188 | - $img_h = $img_w * $info['h']/$info['w']; | |
| 189 | - } | |
| 190 | - else { // the entire viewport is covered by the viewBox | |
| 191 | - $img_w = $img_h * $info['w']/$info['h']; | |
| 192 | - } | |
| 193 | - } | |
| 194 | - if ($ar[0]=='xminymin') { | |
| 195 | - // do nothing to x | |
| 196 | - // do nothing to y | |
| 197 | - } | |
| 198 | - else if ($ar[0]=='xmidymin') { | |
| 199 | - $img_x += $w/2 - $img_w/2; // xMid | |
| 200 | - // do nothing to y | |
| 201 | - } | |
| 202 | - else if ($ar[0]=='xmaxymin') { | |
| 203 | - $img_x += $w - $img_w; // xMax | |
| 204 | - // do nothing to y | |
| 205 | - } | |
| 206 | - else if ($ar[0]=='xminymid') { | |
| 207 | - // do nothing to x | |
| 208 | - $img_y += $h/2 - $img_h/2; // yMid | |
| 209 | - } | |
| 210 | - else if ($ar[0]=='xmaxymid') { | |
| 211 | - $img_x += $w - $img_w; // xMax | |
| 212 | - $img_y += $h/2 - $img_h/2; // yMid | |
| 213 | - } | |
| 214 | - else if ($ar[0]=='xminymax') { | |
| 215 | - // do nothing to x | |
| 216 | - $img_y += $h - $img_h; // yMax | |
| 217 | - } | |
| 218 | - else if ($ar[0]=='xmidymax') { | |
| 219 | - $img_x += $w/2 - $img_w/2; // xMid | |
| 220 | - $img_y += $h - $img_h; // yMax | |
| 221 | - } | |
| 222 | - else if ($ar[0]=='xmaxymax') { | |
| 223 | - $img_x += $w - $img_w; // xMax | |
| 224 | - $img_y += $h - $img_h; // yMax | |
| 225 | - } | |
| 226 | - else { // xMidYMid (the default) | |
| 227 | - $img_x += $w/2 - $img_w/2; // xMid | |
| 228 | - $img_y += $h/2 - $img_h/2; // yMid | |
| 229 | - } | |
| 230 | - } | |
| 231 | - | |
| 232 | - // Output | |
| 233 | - if ($meetOrSlice == 'slice') { // need to add a clipping path to reference rectangle | |
| 234 | - $s = ' q 0 w '; // Line width=0 | |
| 235 | - $s .= sprintf('%.3F %.3F m ', ($x)*$this->kp, (-($y+$h))*$this->kp); // start point TL before the arc | |
| 236 | - $s .= sprintf('%.3F %.3F l ', ($x)*$this->kp, (-($y))*$this->kp); // line to BL | |
| 237 | - $s .= sprintf('%.3F %.3F l ', ($x+$w)*$this->kp, (-($y))*$this->kp); // line to BR | |
| 238 | - $s .= sprintf('%.3F %.3F l ', ($x+$w)*$this->kp, (-($y+$h))*$this->kp); // line to TR | |
| 239 | - $s .= sprintf('%.3F %.3F l ', ($x)*$this->kp, (-($y+$h))*$this->kp); // line to TL | |
| 240 | - $s .= ' W n '; // Ends path no-op & Sets the clipping path | |
| 241 | - $this->svgWriteString($s); | |
| 242 | - } | |
| 243 | - | |
| 244 | - $outstring = sprintf(" q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q ",$img_w*$this->kp, $img_h*$this->kp, $img_x*$this->kp, -($img_y+$img_h)*$this->kp, $info['i'] ); | |
| 245 | - $this->svgWriteString($outstring); | |
| 246 | - | |
| 247 | - if ($meetOrSlice == 'slice') { // need to end clipping path | |
| 248 | - $this->svgWriteString(' Q '); | |
| 249 | - } | |
| 250 | - } | |
| 251 | - | |
| 252 | - | |
| 253 | 91 | function svgGradient($gradient_info, $attribs, $element){ |
| 254 | 92 | $n = count($this->mpdf_ref->gradients)+1; |
| 255 | 93 | |
| 256 | 94 | // Get bounding dimensions of element |
| @@ -295,8 +133,9 @@ | ||
| 295 | 133 | $x_offset = $minl; |
| 296 | 134 | $y_offset = $mint; |
| 297 | 135 | } |
| 298 | 136 | else if ($element=='path') { |
| 137 | + // mPDF 5.0.039 | |
| 299 | 138 | if (is_array($this->pathBBox) && $this->pathBBox[2]>0) { |
| 300 | 139 | $w = $this->pathBBox[2]; |
| 301 | 140 | $h = $this->pathBBox[3]; |
| 302 | 141 | $x_offset = $this->pathBBox[0]; |
| @@ -342,8 +181,9 @@ | ||
| 342 | 181 | if (!$h || $h==-999999) { $h = 100; } |
| 343 | 182 | if ($x_offset==999999) { $x_offset = 0; } |
| 344 | 183 | if ($y_offset==999999) { $y_offset = 0; } |
| 345 | 184 | |
| 185 | + // mPDF 4.5.010 | |
| 346 | 186 | // TRANSFORMATIONS |
| 347 | 187 | $transformations = ''; |
| 348 | 188 | if (isset($gradient_info['transform'])){ |
| 349 | 189 | preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',$gradient_info['transform'],$m); |
| @@ -352,8 +192,9 @@ | ||
| 352 | 192 | $c = strtolower($m[1][$i]); |
| 353 | 193 | $v = trim($m[2][$i]); |
| 354 | 194 | $vv = preg_split('/[ ,]+/',$v); |
| 355 | 195 | if ($c=='matrix' && count($vv)==6) { |
| 196 | + // mPDF 5.0.039 | |
| 356 | 197 | // Note angle of rotation is reversed (from SVG to PDF), so vv[1] and vv[2] are negated |
| 357 | 198 | // cf svgDefineStyle() |
| 358 | 199 | $transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $vv[0], -$vv[1], -$vv[2], $vv[3], $vv[4]*$this->kp, -$vv[5]*$this->kp); |
| 359 | 200 | } |
| @@ -399,11 +240,13 @@ | ||
| 399 | 240 | |
| 400 | 241 | |
| 401 | 242 | $return = ""; |
| 402 | 243 | |
| 244 | + // mPDF 5.0.039 | |
| 403 | 245 | if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') { |
| 404 | 246 | if ($transformations) { $return .= $transformations; } |
| 405 | 247 | } |
| 248 | + // mPDF 5.0.040 | |
| 406 | 249 | $spread = 'P'; // pad |
| 407 | 250 | if (isset($gradient_info['spread'])) { |
| 408 | 251 | if (strtolower($gradient_info['spread'])=='reflect') { $spread = 'F'; } // reflect |
| 409 | 252 | else if (strtolower($gradient_info['spread'])=='repeat') { $spread = 'R'; } // repeat |
| @@ -411,9 +254,9 @@ | ||
| 411 | 254 | |
| 412 | 255 | |
| 413 | 256 | for ($i=0; $i<(count($gradient_info['color'])); $i++) { |
| 414 | 257 | if (stristr($gradient_info['color'][$i]['offset'], '%')!== false) { $gradient_info['color'][$i]['offset'] = ($gradient_info['color'][$i]['offset']+0)/100; } |
| 415 | - if (isset($gradient_info['color'][($i+1)]['offset']) && stristr($gradient_info['color'][($i+1)]['offset'], '%')!== false) { $gradient_info['color'][($i+1)]['offset'] = ($gradient_info['color'][($i+1)]['offset']+0)/100; } | |
| 258 | + if (stristr($gradient_info['color'][($i+1)]['offset'], '%')!== false) { $gradient_info['color'][($i+1)]['offset'] = ($gradient_info['color'][($i+1)]['offset']+0)/100; } | |
| 416 | 259 | if ($gradient_info['color'][$i]['offset']<0) { $gradient_info['color'][$i]['offset'] = 0; } |
| 417 | 260 | if ($gradient_info['color'][$i]['offset']>1) { $gradient_info['color'][$i]['offset'] = 1; } |
| 418 | 261 | if ($i>0) { |
| 419 | 262 | if ($gradient_info['color'][$i]['offset']<$gradient_info['color'][($i-1)]['offset']) { |
| @@ -421,14 +264,14 @@ | ||
| 421 | 264 | } |
| 422 | 265 | } |
| 423 | 266 | } |
| 424 | 267 | |
| 425 | - if (isset($gradient_info['color'][0]['offset']) && $gradient_info['color'][0]['offset']>0) { | |
| 268 | + if ($gradient_info['color'][0]['offset']>0) { | |
| 426 | 269 | array_unshift($gradient_info['color'], $gradient_info['color'][0]); |
| 427 | 270 | $gradient_info['color'][0]['offset'] = 0; |
| 428 | 271 | } |
| 429 | 272 | $ns = count($gradient_info['color']); |
| 430 | - if (isset($gradient_info['color'][($ns-1)]['offset']) && $gradient_info['color'][($ns-1)]['offset']<1) { | |
| 273 | + if ($gradient_info['color'][($ns-1)]['offset']<1) { | |
| 431 | 274 | $gradient_info['color'][] = $gradient_info['color'][($ns-1)]; |
| 432 | 275 | $gradient_info['color'][($ns)]['offset'] = 1; |
| 433 | 276 | } |
| 434 | 277 | $ns = count($gradient_info['color']); |
| @@ -450,9 +293,9 @@ | ||
| 450 | 293 | else { $y1 = 0; } |
| 451 | 294 | if (isset($gradient_info['info']['x2'])) { $x2 = $gradient_info['info']['x2']; } |
| 452 | 295 | else { $x2 = 1; } |
| 453 | 296 | if (isset($gradient_info['info']['y2'])) { $y2 = $gradient_info['info']['y2']; } |
| 454 | - else { $y2 = 0; } // mPDF 6 | |
| 297 | + else { $y2 = 0; } | |
| 455 | 298 | |
| 456 | 299 | if (stristr($x1, '%')!== false) { $x1 = ($x1+0)/100; } |
| 457 | 300 | if (stristr($x2, '%')!== false) { $x2 = ($x2+0)/100; } |
| 458 | 301 | if (stristr($y1, '%')!== false) { $y1 = ($y1+0)/100; } |
| @@ -488,14 +331,17 @@ | ||
| 488 | 331 | $f = -$usey; // -y-offset |
| 489 | 332 | |
| 490 | 333 | $return .= sprintf('%.3F 0 0 %.3F %.3F %.3F cm ', $a*$this->kp, $d*$this->kp, $e*$this->kp, $f*$this->kp); |
| 491 | 334 | |
| 335 | + // mPDF 5.0.039 | |
| 492 | 336 | if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='objectboundingbox') { |
| 493 | 337 | if ($transformations) { $return .= $transformations; } |
| 494 | 338 | } |
| 495 | 339 | |
| 340 | + // mPDF 5.0.020 | |
| 496 | 341 | $trans = false; |
| 497 | 342 | |
| 343 | + // mPDF 5.0.040 | |
| 498 | 344 | if ($spread=='R' || $spread=='F') { // Repeat / Reflect |
| 499 | 345 | $offs = array(); |
| 500 | 346 | for($i=0;$i<$ns;$i++) { |
| 501 | 347 | $offs[$i] = $gradient_info['color'][$i]['offset']; |
| @@ -579,16 +425,18 @@ | ||
| 579 | 425 | } |
| 580 | 426 | } |
| 581 | 427 | } |
| 582 | 428 | |
| 583 | - // Gradient STOPs | |
| 429 | + // mPDF 4.4.007 Gradient STOPs | |
| 584 | 430 | $stops = count($gradient_info['color']); |
| 585 | 431 | if ($stops < 2) { return ''; } |
| 586 | 432 | |
| 433 | + // mPDF 5.0.042 | |
| 587 | 434 | $range = $gradient_info['color'][count($gradient_info['color'])-1]['offset']-$gradient_info['color'][0]['offset']; |
| 588 | 435 | $min = $gradient_info['color'][0]['offset']; |
| 589 | 436 | |
| 590 | 437 | for ($i=0; $i<($stops); $i++) { |
| 438 | + // mPDF 5.0.051 | |
| 591 | 439 | if (!$gradient_info['color'][$i]['color']) { |
| 592 | 440 | if ($gradient_info['colorspace']=='RGB') $gradient_info['color'][$i]['color'] = '0 0 0'; |
| 593 | 441 | else if ($gradient_info['colorspace']=='Gray') $gradient_info['color'][$i]['color'] = '0'; |
| 594 | 442 | else if ($gradient_info['colorspace']=='CMYK') $gradient_info['color'][$i]['color'] = '1 1 1 1'; |
| @@ -606,9 +454,9 @@ | ||
| 606 | 454 | $gry2 = $y1 + ($y2-$y1)*$gradient_info['color'][count($gradient_info['color'])-1]['offset']; |
| 607 | 455 | |
| 608 | 456 | $this->mpdf_ref->gradients[$n]['coords']=array($grx1, $gry1, $grx2, $gry2); |
| 609 | 457 | |
| 610 | - $this->mpdf_ref->gradients[$n]['colorspace'] = $gradient_info['colorspace']; | |
| 458 | + $this->mpdf_ref->gradients[$n]['colorspace'] = $gradient_info['colorspace']; // mPDF 5.0.051 | |
| 611 | 459 | |
| 612 | 460 | $this->mpdf_ref->gradients[$n]['type'] = 2; |
| 613 | 461 | $this->mpdf_ref->gradients[$n]['fo'] = true; |
| 614 | 462 | |
| @@ -620,8 +468,9 @@ | ||
| 620 | 468 | $return .= ' /Sh'.($n).' sh '; |
| 621 | 469 | $return .= " Q\n"; |
| 622 | 470 | } |
| 623 | 471 | else if ($gradient_info['type'] == 'radial'){ |
| 472 | + // mPDF 4.4.003 | |
| 624 | 473 | if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') { |
| 625 | 474 | if ($w > $h) { $h = $w; } |
| 626 | 475 | else { $w = $h; } |
| 627 | 476 | if (isset($gradient_info['info']['x0'])) { $gradient_info['info']['x0'] = ($gradient_info['info']['x0']-$x_offset) / $w; } |
| @@ -631,21 +480,21 @@ | ||
| 631 | 480 | if (isset($gradient_info['info']['r'])) { $gradient_info['info']['rx'] = $gradient_info['info']['r'] / $w; } |
| 632 | 481 | if (isset($gradient_info['info']['r'])) { $gradient_info['info']['ry'] = $gradient_info['info']['r'] / $h; } |
| 633 | 482 | } |
| 634 | 483 | |
| 635 | - if (isset($gradient_info['info']['x0'])) { $x0 = $gradient_info['info']['x0']; } | |
| 484 | + if ($gradient_info['info']['x0'] || $gradient_info['info']['x0']===0) { $x0 = $gradient_info['info']['x0']; } | |
| 636 | 485 | else { $x0 = 0.5; } |
| 637 | - if (isset($gradient_info['info']['y0'])) { $y0 = $gradient_info['info']['y0']; } | |
| 486 | + if ($gradient_info['info']['y0'] || $gradient_info['info']['y0']===0) { $y0 = $gradient_info['info']['y0']; } | |
| 638 | 487 | else { $y0 = 0.5; } |
| 639 | - if (isset($gradient_info['info']['rx'])) { $rx = $gradient_info['info']['rx']; } | |
| 640 | - else if (isset($gradient_info['info']['r'])) { $rx = $gradient_info['info']['r']; } | |
| 488 | + if ($gradient_info['info']['rx'] || $gradient_info['info']['rx']===0) { $rx = $gradient_info['info']['rx']; } | |
| 489 | + else if ($gradient_info['info']['r'] || $gradient_info['info']['r']===0) { $rx = $gradient_info['info']['r']; } | |
| 641 | 490 | else { $rx = 0.5; } |
| 642 | - if (isset($gradient_info['info']['ry'])) { $ry = $gradient_info['info']['ry']; } | |
| 643 | - else if (isset($gradient_info['info']['r'])) { $ry = $gradient_info['info']['r']; } | |
| 491 | + if ($gradient_info['info']['ry'] || $gradient_info['info']['ry']===0) { $ry = $gradient_info['info']['ry']; } | |
| 492 | + else if ($gradient_info['info']['r'] || $gradient_info['info']['r']===0) { $ry = $gradient_info['info']['r']; } | |
| 644 | 493 | else { $ry = 0.5; } |
| 645 | - if (isset($gradient_info['info']['x1'])) { $x1 = $gradient_info['info']['x1']; } | |
| 494 | + if ($gradient_info['info']['x1'] || $gradient_info['info']['x1']===0) { $x1 = $gradient_info['info']['x1']; } | |
| 646 | 495 | else { $x1 = $x0; } |
| 647 | - if (isset($gradient_info['info']['y1'])) { $y1 = $gradient_info['info']['y1']; } | |
| 496 | + if ($gradient_info['info']['y1'] || $gradient_info['info']['y1']===0) { $y1 = $gradient_info['info']['y1']; } | |
| 648 | 497 | else { $y1 = $y0; } |
| 649 | 498 | |
| 650 | 499 | if (stristr($x1, '%')!== false) { $x1 = ($x1+0)/100; } |
| 651 | 500 | if (stristr($x0, '%')!== false) { $x0 = ($x0+0)/100; } |
| @@ -653,8 +502,9 @@ | ||
| 653 | 502 | if (stristr($y0, '%')!== false) { $y0 = ($y0+0)/100; } |
| 654 | 503 | if (stristr($rx, '%')!== false) { $rx = ($rx+0)/100; } |
| 655 | 504 | if (stristr($ry, '%')!== false) { $ry = ($ry+0)/100; } |
| 656 | 505 | |
| 506 | + // mPDF 5.0.043 | |
| 657 | 507 | $bboxw = $w; |
| 658 | 508 | $bboxh = $h; |
| 659 | 509 | $usex = $x_offset; |
| 660 | 510 | $usey = $y_offset; |
| @@ -695,19 +545,12 @@ | ||
| 695 | 545 | if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='objectboundingbox') { |
| 696 | 546 | if ($transformations) { $return .= $transformations; } |
| 697 | 547 | } |
| 698 | 548 | |
| 699 | - // mPDF 5.7.4 | |
| 700 | - // x1 and y1 (fx, fy) should be inside the circle defined by x0 y0 (cx, cy) | |
| 701 | - // "If the point defined by fx and fy lies outside the circle defined by cx, cy and r, then the user agent shall set | |
| 702 | - // the focal point to the intersection of the line from (cx, cy) to (fx, fy) with the circle defined by cx, cy and r." | |
| 703 | - while (pow(($x1-$x0),2) + pow(($y1 - $y0),2) >= pow($r,2)) { | |
| 704 | - // Gradually move along fx,fy towards cx,cy in 100'ths until meets criteria | |
| 705 | - $x1 -= ($x1-$x0)/100; | |
| 706 | - $y1 -= ($y1-$y0)/100; | |
| 707 | - } | |
| 549 | + // x1 and y1 (fx, fy) should be inside the circle defined by x0 y0 and r else error in mPDF | |
| 550 | + while (pow(($x1-$x0),2) + pow(($y1 - $y0),2) >= pow($r,2)) { $r += 0.05; } | |
| 708 | 551 | |
| 709 | - | |
| 552 | + // mPDF 5.0.040 | |
| 710 | 553 | if ($spread=='R' || $spread=='F') { // Repeat / Reflect |
| 711 | 554 | $offs = array(); |
| 712 | 555 | for($i=0;$i<$ns;$i++) { |
| 713 | 556 | $offs[$i] = $gradient_info['color'][$i]['offset']; |
| @@ -739,16 +582,18 @@ | ||
| 739 | 582 | } |
| 740 | 583 | } |
| 741 | 584 | } |
| 742 | 585 | |
| 743 | - // Gradient STOPs | |
| 586 | + // mPDF 4.4.007 Gradient STOPs | |
| 744 | 587 | $stops = count($gradient_info['color']); |
| 745 | 588 | if ($stops < 2) { return ''; } |
| 746 | 589 | |
| 590 | + // mPDF 5.0.043 | |
| 747 | 591 | $range = $gradient_info['color'][count($gradient_info['color'])-1]['offset']-$gradient_info['color'][0]['offset']; |
| 748 | 592 | $min = $gradient_info['color'][0]['offset']; |
| 749 | 593 | |
| 750 | 594 | for ($i=0; $i<($stops); $i++) { |
| 595 | + // mPDF 5.0.051 | |
| 751 | 596 | if (!$gradient_info['color'][$i]['color']) { |
| 752 | 597 | if ($gradient_info['colorspace']=='RGB') $gradient_info['color'][$i]['color'] = '0 0 0'; |
| 753 | 598 | else if ($gradient_info['colorspace']=='Gray') $gradient_info['color'][$i]['color'] = '0'; |
| 754 | 599 | else if ($gradient_info['colorspace']=='CMYK') $gradient_info['color'][$i]['color'] = '1 1 1 1'; |
| @@ -768,15 +613,21 @@ | ||
| 768 | 613 | $grr = $r*$gradient_info['color'][count($gradient_info['color'])-1]['offset']; |
| 769 | 614 | |
| 770 | 615 | $this->mpdf_ref->gradients[$n]['coords']=array($grx1, $gry1, $grx2, $gry2, abs($grr), abs($grir) ); |
| 771 | 616 | |
| 772 | - $this->mpdf_ref->gradients[$n]['colorspace'] = $gradient_info['colorspace']; | |
| 617 | + $grx1 = $x1 + ($x0-$x1)*$first_stop; | |
| 618 | + $gry1 = $y1 + ($y0-$y1)*$first_stop; | |
| 619 | + $grx2 = $x1 + ($x0-$x1)*$last_stop; | |
| 620 | + $gry2 = $y1 + ($y0-$y1)*$last_stop; | |
| 621 | + $grir = $r*$first_stop; | |
| 622 | + $grr = $r*$last_stop; | |
| 623 | + $this->mpdf_ref->gradients[$n]['colorspace'] = $gradient_info['colorspace']; // mPDF 5.0.051 | |
| 773 | 624 | |
| 774 | 625 | $this->mpdf_ref->gradients[$n]['type'] = 3; |
| 775 | 626 | $this->mpdf_ref->gradients[$n]['fo'] = true; |
| 776 | 627 | |
| 777 | 628 | $this->mpdf_ref->gradients[$n]['extend']=array('true','true'); |
| 778 | - if (isset($trans) && $trans) { | |
| 629 | + if ($trans) { | |
| 779 | 630 | $this->mpdf_ref->gradients[$n]['trans'] = true; |
| 780 | 631 | $return .= ' /TGS'.($n).' gs '; |
| 781 | 632 | } |
| 782 | 633 | $return .= ' /Sh'.($n).' sh '; |
| @@ -798,26 +649,25 @@ | ||
| 798 | 649 | $this->svg_info['x'] = $vb[0]; |
| 799 | 650 | $this->svg_info['y'] = $vb[1]; |
| 800 | 651 | $this->svg_info['w'] = $vb[2]; |
| 801 | 652 | $this->svg_info['h'] = $vb[3]; |
| 802 | -// return; | |
| 653 | +// return; // mPDF 5.0.005 | |
| 803 | 654 | } |
| 804 | 655 | } |
| 805 | - $svg_w = 0; | |
| 806 | - $svg_h = 0; | |
| 807 | - if (isset($attribs['width']) && $attribs['width']) $svg_w = $this->mpdf_ref->ConvertSize($attribs['width']); // mm (interprets numbers as pixels) | |
| 808 | - if (isset($attribs['height']) && $attribs['height']) $svg_h = $this->mpdf_ref->ConvertSize($attribs['height']); // mm | |
| 809 | 656 | |
| 657 | + $svg_w = $this->mpdf_ref->ConvertSize($attribs['width']); // mm (interprets numbers as pixels) | |
| 658 | + $svg_h = $this->mpdf_ref->ConvertSize($attribs['height']); // mm | |
| 659 | + | |
| 810 | 660 | ///* |
| 811 | 661 | // mPDF 5.0.005 |
| 812 | - if (isset($this->svg_info['w']) && $this->svg_info['w']) { // if 'w' set by viewBox | |
| 662 | + if ($this->svg_info['w']) { // if 'w' set by viewBox | |
| 813 | 663 | if ($svg_w) { // if width also set, use these values to determine to set size of "pixel" |
| 814 | 664 | $this->kp *= ($svg_w/0.2645) / $this->svg_info['w']; |
| 815 | - $this->kf = ($svg_w/0.2645) / $this->svg_info['w']; | |
| 665 | + $this->kf = ($svg_w/0.2645) / $this->svg_info['w']; // mPDF 5.0.039 | |
| 816 | 666 | } |
| 817 | 667 | else if ($svg_h) { |
| 818 | 668 | $this->kp *= ($svg_h/0.2645) / $this->svg_info['h']; |
| 819 | - $this->kf = ($svg_h/0.2645) / $this->svg_info['h']; | |
| 669 | + $this->kf = ($svg_h/0.2645) / $this->svg_info['h']; // mPDF 5.0.039 | |
| 820 | 670 | } |
| 821 | 671 | return; |
| 822 | 672 | } |
| 823 | 673 | //*/ |
| @@ -957,107 +807,97 @@ | ||
| 957 | 807 | $current_style['transformations'] = $transformations; |
| 958 | 808 | } |
| 959 | 809 | |
| 960 | 810 | if (isset($critere_style['style'])){ |
| 961 | - if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/i',$critere_style['style'], $m)) { // mPDF 5.7.2 | |
| 811 | + if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) { | |
| 962 | 812 | $current_style['fill'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT); |
| 963 | 813 | } |
| 964 | - else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']); | |
| 965 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill'] = $tmp; } | |
| 814 | + else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']); // mPDF 4.4.003 | |
| 815 | + if ($tmp != $critere_style['style']){ $current_style['fill'] = $tmp; } | |
| 966 | 816 | } |
| 967 | 817 | |
| 968 | - // mPDF 5.7.2 | |
| 969 | - if ((preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m) || | |
| 970 | - preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m)) && $m[1]!='inherit') { | |
| 971 | - $current_style['fill-opacity'] = $m[1]; | |
| 972 | - $current_style['stroke-opacity'] = $m[1]; | |
| 973 | - } | |
| 974 | - | |
| 975 | 818 | $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 976 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill-opacity'] = $tmp;} | |
| 819 | + if ($tmp != $critere_style['style']){ $current_style['fill-opacity'] = $tmp;} | |
| 977 | 820 | |
| 978 | 821 | $tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 979 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill-rule'] = $tmp;} | |
| 822 | + if ($tmp != $critere_style['style']){ $current_style['fill-rule'] = $tmp;} | |
| 980 | 823 | |
| 981 | 824 | if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) { |
| 982 | 825 | $current_style['stroke'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT); |
| 983 | 826 | } |
| 984 | 827 | else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 985 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke'] = $tmp; } | |
| 828 | + if ($tmp != $critere_style['style']){ $current_style['stroke'] = $tmp; } | |
| 986 | 829 | } |
| 987 | 830 | |
| 988 | 831 | $tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 989 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linecap'] = $tmp;} | |
| 832 | + if ($tmp != $critere_style['style']){ $current_style['stroke-linecap'] = $tmp;} | |
| 990 | 833 | |
| 991 | 834 | $tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 992 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;} | |
| 835 | + if ($tmp != $critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;} | |
| 993 | 836 | |
| 994 | 837 | $tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 995 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;} | |
| 838 | + if ($tmp != $critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;} | |
| 996 | 839 | |
| 997 | 840 | $tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 998 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-opacity'] = $tmp; } | |
| 841 | + if ($tmp != $critere_style['style']){ $current_style['stroke-opacity'] = $tmp; } | |
| 999 | 842 | |
| 1000 | 843 | $tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 1001 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-width'] = $tmp;} | |
| 844 | + if ($tmp != $critere_style['style']){ $current_style['stroke-width'] = $tmp;} | |
| 1002 | 845 | |
| 846 | + // mPDF 4.4.003 | |
| 1003 | 847 | $tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",$critere_style['style']); |
| 1004 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;} | |
| 848 | + if ($tmp != $critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;} | |
| 1005 | 849 | |
| 850 | + // mPDF 4.4.003 | |
| 1006 | 851 | $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 1007 | - if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | |
| 852 | + if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | |
| 1008 | 853 | |
| 1009 | 854 | } |
| 1010 | - // mPDF 5.7.2 | |
| 1011 | - if(isset($critere_style['opacity']) && $critere_style['opacity']!= 'inherit'){ | |
| 1012 | - $current_style['fill-opacity'] = $critere_style['opacity']; | |
| 1013 | - $current_style['stroke-opacity'] = $critere_style['opacity']; | |
| 1014 | - } | |
| 1015 | - | |
| 1016 | - if(isset($critere_style['fill']) && $critere_style['fill']!= 'inherit'){ | |
| 855 | + if(isset($critere_style['fill'])){ | |
| 1017 | 856 | $current_style['fill'] = $critere_style['fill']; |
| 1018 | 857 | } |
| 1019 | 858 | |
| 1020 | - if(isset($critere_style['fill-opacity']) && $critere_style['fill-opacity']!= 'inherit'){ | |
| 859 | + if(isset($critere_style['fill-opacity'])){ | |
| 1021 | 860 | $current_style['fill-opacity'] = $critere_style['fill-opacity']; |
| 1022 | 861 | } |
| 1023 | 862 | |
| 1024 | - if(isset($critere_style['fill-rule']) && $critere_style['fill-rule']!= 'inherit'){ | |
| 863 | + if(isset($critere_style['fill-rule'])){ | |
| 1025 | 864 | $current_style['fill-rule'] = $critere_style['fill-rule']; |
| 1026 | 865 | } |
| 1027 | 866 | |
| 1028 | - if(isset($critere_style['stroke']) && $critere_style['stroke']!= 'inherit'){ | |
| 867 | + if(isset($critere_style['stroke'])){ | |
| 1029 | 868 | $current_style['stroke'] = $critere_style['stroke']; |
| 1030 | 869 | } |
| 1031 | 870 | |
| 1032 | - if(isset($critere_style['stroke-linecap']) && $critere_style['stroke-linecap']!= 'inherit'){ | |
| 871 | + if(isset($critere_style['stroke-linecap'])){ | |
| 1033 | 872 | $current_style['stroke-linecap'] = $critere_style['stroke-linecap']; |
| 1034 | 873 | } |
| 1035 | 874 | |
| 1036 | - if(isset($critere_style['stroke-linejoin']) && $critere_style['stroke-linejoin']!= 'inherit'){ | |
| 875 | + if(isset($critere_style['stroke-linejoin'])){ | |
| 1037 | 876 | $current_style['stroke-linejoin'] = $critere_style['stroke-linejoin']; |
| 1038 | 877 | } |
| 1039 | 878 | |
| 1040 | - if(isset($critere_style['stroke-miterlimit']) && $critere_style['stroke-miterlimit']!= 'inherit'){ | |
| 879 | + if(isset($critere_style['stroke-miterlimit'])){ | |
| 1041 | 880 | $current_style['stroke-miterlimit'] = $critere_style['stroke-miterlimit']; |
| 1042 | 881 | } |
| 1043 | 882 | |
| 1044 | - if(isset($critere_style['stroke-opacity']) && $critere_style['stroke-opacity']!= 'inherit'){ | |
| 883 | + if(isset($critere_style['stroke-opacity'])){ | |
| 1045 | 884 | $current_style['stroke-opacity'] = $critere_style['stroke-opacity']; |
| 1046 | 885 | } |
| 1047 | 886 | |
| 1048 | - if(isset($critere_style['stroke-width']) && $critere_style['stroke-width']!= 'inherit'){ | |
| 887 | + if(isset($critere_style['stroke-width'])){ | |
| 1049 | 888 | $current_style['stroke-width'] = $critere_style['stroke-width']; |
| 1050 | 889 | } |
| 1051 | 890 | |
| 1052 | - if(isset($critere_style['stroke-dasharray']) && $critere_style['stroke-dasharray']!= 'inherit'){ | |
| 891 | + // mPDF 4.4.003 | |
| 892 | + if(isset($critere_style['stroke-dasharray'])){ | |
| 1053 | 893 | $current_style['stroke-dasharray'] = $critere_style['stroke-dasharray']; |
| 1054 | 894 | } |
| 1055 | - if(isset($critere_style['stroke-dashoffset']) && $critere_style['stroke-dashoffset']!= 'inherit'){ | |
| 895 | + if(isset($critere_style['stroke-dashoffset'])){ | |
| 1056 | 896 | $current_style['stroke-dashoffset'] = $critere_style['stroke-dashoffset']; |
| 1057 | 897 | } |
| 1058 | 898 | |
| 1059 | - // Used as indirect setting for currentColor | |
| 899 | + // mPDF 4.4.005 Used as indirect setting for currentColor | |
| 1060 | 900 | if(isset($critere_style['color']) && $critere_style['color'] != 'inherit'){ |
| 1061 | 901 | $current_style['color'] = $critere_style['color']; |
| 1062 | 902 | } |
| 1063 | 903 | |
| @@ -1068,12 +908,9 @@ | ||
| 1068 | 908 | // |
| 1069 | 909 | // Cette fonction ecrit le style dans le stream svg. |
| 1070 | 910 | function svgStyle($critere_style, $attribs, $element){ |
| 1071 | 911 | $path_style = ''; |
| 1072 | - $fill_gradient = ''; | |
| 1073 | - $w = ''; | |
| 1074 | - $style = ''; | |
| 1075 | - if (substr_count($critere_style['fill'],'url')>0 && $element != 'line'){ | |
| 912 | + if (substr_count($critere_style['fill'],'url')>0){ | |
| 1076 | 913 | // |
| 1077 | 914 | // couleur degrad� |
| 1078 | 915 | $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['fill']); |
| 1079 | 916 | if ($id_gradient != $critere_style['fill']) { |
| @@ -1078,9 +915,9 @@ | ||
| 1078 | 915 | $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['fill']); |
| 1079 | 916 | if ($id_gradient != $critere_style['fill']) { |
| 1080 | 917 | if (isset($this->svg_gradient[$id_gradient])) { |
| 1081 | 918 | $fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element); |
| 1082 | - if ($fill_gradient) { | |
| 919 | + if ($fill_gradient) { // mPDF 4.4.003 | |
| 1083 | 920 | $path_style = "q "; |
| 1084 | 921 | $w = "W"; |
| 1085 | 922 | $style .= 'N'; |
| 1086 | 923 | } |
| @@ -1087,27 +924,33 @@ | ||
| 1087 | 924 | } |
| 1088 | 925 | } |
| 1089 | 926 | |
| 1090 | 927 | } |
| 1091 | - // Used as indirect setting for currentColor | |
| 1092 | - else if (strtolower($critere_style['fill']) == 'currentcolor' && $element != 'line'){ | |
| 928 | + // mPDF 4.4.005 Used as indirect setting for currentColor | |
| 929 | + else if (strtolower($critere_style['fill']) == 'currentcolor'){ | |
| 1093 | 930 | $col = $this->mpdf_ref->ConvertColor($critere_style['color']); |
| 1094 | 931 | if ($col) { |
| 932 | + // mPDF 5.0.051 | |
| 933 | + // mPDF 5.3.74 | |
| 1095 | 934 | if ($col{0}==5) { $critere_style['fill-opacity'] = ord($col{4}/100); } // RGBa |
| 1096 | 935 | if ($col{0}==6) { $critere_style['fill-opacity'] = ord($col{5}/100); } // CMYKa |
| 1097 | - $path_style .= $this->mpdf_ref->SetFColor($col, true).' '; | |
| 936 | + $path_style .= $this->mpdf_ref->SetFColor($col, true).' '; // mPDF 5.0.051 | |
| 1098 | 937 | $style .= 'F'; |
| 1099 | 938 | } |
| 1100 | 939 | } |
| 1101 | - else if ($critere_style['fill'] != 'none' && $element != 'line'){ | |
| 940 | + else if ($critere_style['fill'] != 'none'){ | |
| 1102 | 941 | $col = $this->mpdf_ref->ConvertColor($critere_style['fill']); |
| 1103 | 942 | if ($col) { |
| 943 | + // mPDF 5.0.051 | |
| 944 | + // mPDF 5.3.74 | |
| 1104 | 945 | if ($col{0}==5) { $critere_style['fill-opacity'] = ord($col{4}/100); } // RGBa |
| 1105 | 946 | if ($col{0}==6) { $critere_style['fill-opacity'] = ord($col{5}/100); } // CMYKa |
| 1106 | - $path_style .= $this->mpdf_ref->SetFColor($col, true).' '; | |
| 947 | + $path_style .= $this->mpdf_ref->SetFColor($col, true).' '; // mPDF 5.0.051 | |
| 1107 | 948 | $style .= 'F'; |
| 1108 | 949 | } |
| 1109 | 950 | } |
| 951 | + | |
| 952 | + // mPDF 5.0.040 | |
| 1110 | 953 | if (substr_count($critere_style['stroke'],'url')>0){ |
| 1111 | 954 | /* |
| 1112 | 955 | // Cannot put a gradient on a "stroke" in PDF? |
| 1113 | 956 | $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['stroke']); |
| @@ -1122,15 +965,17 @@ | ||
| 1122 | 965 | } |
| 1123 | 966 | } |
| 1124 | 967 | */ |
| 1125 | 968 | } |
| 1126 | - // Used as indirect setting for currentColor | |
| 969 | + // mPDF 4.4.005 Used as indirect setting for currentColor | |
| 1127 | 970 | else if (strtolower($critere_style['stroke']) == 'currentcolor'){ |
| 1128 | 971 | $col = $this->mpdf_ref->ConvertColor($critere_style['color']); |
| 1129 | 972 | if ($col) { |
| 973 | + // mPDF 5.0.051 | |
| 974 | + // mPDF 5.3.74 | |
| 1130 | 975 | if ($col{0}==5) { $critere_style['stroke-opacity'] = ord($col{4}/100); } // RGBa |
| 1131 | 976 | if ($col{0}==6) { $critere_style['stroke-opacity'] = ord($col{5}/100); } // CMYKa |
| 1132 | - $path_style .= $this->mpdf_ref->SetDColor($col, true).' '; | |
| 977 | + $path_style .= $this->mpdf_ref->SetDColor($col, true).' '; // mPDF 5.0.051 | |
| 1133 | 978 | $style .= 'D'; |
| 1134 | 979 | $lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']); |
| 1135 | 980 | $path_style .= sprintf('%.3F w ',$lw*$this->kp); |
| 1136 | 981 | } |
| @@ -1141,11 +986,11 @@ | ||
| 1141 | 986 | // mPDF 5.0.051 |
| 1142 | 987 | // mPDF 5.3.74 |
| 1143 | 988 | if ($col{0}==5) { $critere_style['stroke-opacity'] = ord($col{4}/100); } // RGBa |
| 1144 | 989 | if ($col{0}==6) { $critere_style['stroke-opacity'] = ord($col{5}/100); } // CMYKa |
| 1145 | - $path_style .= $this->mpdf_ref->SetDColor($col, true).' '; | |
| 990 | + $path_style .= $this->mpdf_ref->SetDColor($col, true).' '; // mPDF 5.0.051 | |
| 1146 | 991 | $style .= 'D'; |
| 1147 | - $lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']); | |
| 992 | + $lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']); // mPDF 4.4.003 | |
| 1148 | 993 | $path_style .= sprintf('%.3F w ',$lw*$this->kp); |
| 1149 | 994 | } |
| 1150 | 995 | } |
| 1151 | 996 | |
| @@ -1177,8 +1022,9 @@ | ||
| 1177 | 1022 | else if (preg_match('/^[\d.]+$/',$critere_style['stroke-miterlimit'])) { |
| 1178 | 1023 | $path_style .= sprintf('%.2F M ',$critere_style['stroke-miterlimit']); |
| 1179 | 1024 | } |
| 1180 | 1025 | } |
| 1026 | + // mPDF 4.4.003 | |
| 1181 | 1027 | if (isset($critere_style['stroke-dasharray'])){ |
| 1182 | 1028 | $off = 0; |
| 1183 | 1029 | $d = preg_split('/[ ,]/',$critere_style['stroke-dasharray']); |
| 1184 | 1030 | if (count($d) == 1 && $d[0]==0) { |
| @@ -1195,11 +1041,13 @@ | ||
| 1195 | 1041 | } |
| 1196 | 1042 | } |
| 1197 | 1043 | } |
| 1198 | 1044 | |
| 1045 | + // mPDF 4.4.003 | |
| 1199 | 1046 | if ($critere_style['fill-rule']=='evenodd') { $fr = '*'; } |
| 1200 | 1047 | else { $fr = ''; } |
| 1201 | 1048 | |
| 1049 | + // mPDF 4.4.003 | |
| 1202 | 1050 | if (isset($critere_style['fill-opacity'])) { |
| 1203 | 1051 | $opacity = 1; |
| 1204 | 1052 | if ($critere_style['fill-opacity'] == 0) { $opacity = 0; } |
| 1205 | 1053 | else if ($critere_style['fill-opacity'] > 1) { $opacity = 1; } |
| @@ -1205,12 +1053,13 @@ | ||
| 1205 | 1053 | else if ($critere_style['fill-opacity'] > 1) { $opacity = 1; } |
| 1206 | 1054 | else if ($critere_style['fill-opacity'] > 0) { $opacity = $critere_style['fill-opacity']; } |
| 1207 | 1055 | else if ($critere_style['fill-opacity'] < 0) { $opacity = 0; } |
| 1208 | 1056 | $gs = $this->mpdf_ref->AddExtGState(array('ca'=>$opacity, 'BM'=>'/Normal')); |
| 1209 | - $this->mpdf_ref->extgstates[$gs]['fo'] = true; | |
| 1057 | + $this->mpdf_ref->extgstates[$gs]['fo'] = true; // mPDF 5.0.039 | |
| 1210 | 1058 | $path_style .= sprintf(' /GS%d gs ', $gs); |
| 1211 | 1059 | } |
| 1212 | 1060 | |
| 1061 | + // mPDF 4.4.003 | |
| 1213 | 1062 | if (isset($critere_style['stroke-opacity'])) { |
| 1214 | 1063 | $opacity = 1; |
| 1215 | 1064 | if ($critere_style['stroke-opacity'] == 0) { $opacity = 0; } |
| 1216 | 1065 | else if ($critere_style['stroke-opacity'] > 1) { $opacity = 1; } |
| @@ -1216,9 +1065,9 @@ | ||
| 1216 | 1065 | else if ($critere_style['stroke-opacity'] > 1) { $opacity = 1; } |
| 1217 | 1066 | else if ($critere_style['stroke-opacity'] > 0) { $opacity = $critere_style['stroke-opacity']; } |
| 1218 | 1067 | else if ($critere_style['stroke-opacity'] < 0) { $opacity = 0; } |
| 1219 | 1068 | $gs = $this->mpdf_ref->AddExtGState(array('CA'=>$opacity, 'BM'=>'/Normal')); |
| 1220 | - $this->mpdf_ref->extgstates[$gs]['fo'] = true; | |
| 1069 | + $this->mpdf_ref->extgstates[$gs]['fo'] = true; // mPDF 5.0.039 | |
| 1221 | 1070 | $path_style .= sprintf(' /GS%d gs ', $gs); |
| 1222 | 1071 | } |
| 1223 | 1072 | |
| 1224 | 1073 | switch ($style){ |
| @@ -1237,8 +1086,9 @@ | ||
| 1237 | 1086 | default: |
| 1238 | 1087 | $op = 'n'; |
| 1239 | 1088 | } |
| 1240 | 1089 | |
| 1090 | + // mPDF 5.0 | |
| 1241 | 1091 | $prestyle = $path_style.' '; |
| 1242 | 1092 | $poststyle = $w.' '. $op.$fr.' '.$fill_gradient."\n"; |
| 1243 | 1093 | return array($prestyle,$poststyle); |
| 1244 | 1094 | |
| @@ -1243,20 +1093,22 @@ | ||
| 1243 | 1093 | return array($prestyle,$poststyle); |
| 1244 | 1094 | |
| 1245 | 1095 | } |
| 1246 | 1096 | |
| 1097 | + // | |
| 1247 | 1098 | // fonction retracant les <path /> |
| 1248 | 1099 | function svgPath($command, $arguments){ |
| 1249 | 1100 | $path_cmd = ''; |
| 1250 | - $newsubpath = false; | |
| 1101 | + $newsubpath = false; // mPDF 4.4.003 | |
| 1251 | 1102 | // mPDF 5.0.039 |
| 1252 | 1103 | $minl = $this->pathBBox[0]; |
| 1253 | 1104 | $mint = $this->pathBBox[1]; |
| 1254 | 1105 | $maxr = $this->pathBBox[2]+$this->pathBBox[0]; |
| 1255 | 1106 | $maxb = $this->pathBBox[3]+$this->pathBBox[1]; |
| 1256 | - | |
| 1107 | + // mPDF 5.0.040 | |
| 1257 | 1108 | $start = array($this->xbase, -$this->ybase); |
| 1258 | 1109 | |
| 1110 | + // mPDF 4.4.003 | |
| 1259 | 1111 | preg_match_all('/[\-^]?[\d.]+(e[\-]?[\d]+){0,1}/i', $arguments, $a, PREG_SET_ORDER); |
| 1260 | 1112 | |
| 1261 | 1113 | // if the command is a capital letter, the coords go absolute, otherwise relative |
| 1262 | 1114 | if(strtolower($command) == $command) $relative = true; |
| @@ -1284,8 +1136,9 @@ | ||
| 1284 | 1136 | $this->xbase = $x; |
| 1285 | 1137 | $this->ybase = -$y; |
| 1286 | 1138 | } |
| 1287 | 1139 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1140 | + // mPDF 5.0.039 | |
| 1288 | 1141 | $minl = min($minl,$pdf_pt['x']); |
| 1289 | 1142 | $maxr = max($maxr,$pdf_pt['x']); |
| 1290 | 1143 | $mint = min($mint,-$pdf_pt['y']); |
| 1291 | 1144 | $maxb = max($maxb,-$pdf_pt['y']); |
| @@ -1315,8 +1168,9 @@ | ||
| 1315 | 1168 | $this->xbase = $x; |
| 1316 | 1169 | $this->ybase = -$y; |
| 1317 | 1170 | } |
| 1318 | 1171 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1172 | + // mPDF 5.0.039 | |
| 1319 | 1173 | $minl = min($minl,$pdf_pt['x']); |
| 1320 | 1174 | $maxr = max($maxr,$pdf_pt['x']); |
| 1321 | 1175 | $mint = min($mint,-$pdf_pt['y']); |
| 1322 | 1176 | $maxb = max($maxb,-$pdf_pt['y']); |
| @@ -1340,8 +1194,9 @@ | ||
| 1340 | 1194 | $this->xbase = $x; |
| 1341 | 1195 | $this->ybase = -$y; |
| 1342 | 1196 | } |
| 1343 | 1197 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1198 | + // mPDF 5.0.039 | |
| 1344 | 1199 | $minl = min($minl,$pdf_pt['x']); |
| 1345 | 1200 | $maxr = max($maxr,$pdf_pt['x']); |
| 1346 | 1201 | $mint = min($mint,-$pdf_pt['y']); |
| 1347 | 1202 | $maxb = max($maxb,-$pdf_pt['y']); |
| @@ -1365,8 +1220,9 @@ | ||
| 1365 | 1220 | $this->xbase = $x; |
| 1366 | 1221 | $this->ybase = -$y; |
| 1367 | 1222 | } |
| 1368 | 1223 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1224 | + // mPDF 5.0.039 | |
| 1369 | 1225 | $minl = min($minl,$pdf_pt['x']); |
| 1370 | 1226 | $maxr = max($maxr,$pdf_pt['x']); |
| 1371 | 1227 | $mint = min($mint,-$pdf_pt['y']); |
| 1372 | 1228 | $maxb = max($maxb,-$pdf_pt['y']); |
| @@ -1408,8 +1264,9 @@ | ||
| 1408 | 1264 | $this->lastcontrolpoints = array(($pdfx-$pdfx2),-($pdfy-$pdfy2)); // mPDF 4.4.003 always relative |
| 1409 | 1265 | |
| 1410 | 1266 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1411 | 1267 | |
| 1268 | + // mPDF 5.0.040 | |
| 1412 | 1269 | $curves = array($pdfx1,-$pdfy1,$pdfx2,-$pdfy2,$pdfx,-$pdfy); |
| 1413 | 1270 | $bx = calc_bezier_bbox($start, $curves); |
| 1414 | 1271 | $minl = min($minl,$bx[0]); |
| 1415 | 1272 | $maxr = max($maxr,$bx[2]); |
| @@ -1461,8 +1318,9 @@ | ||
| 1461 | 1318 | // $pdf_pt2 = $this->svg_overflow($pdfx2,$pdfy2); |
| 1462 | 1319 | // $pdf_pt1 = $this->svg_overflow($pdfx1,$pdfy1); |
| 1463 | 1320 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1464 | 1321 | |
| 1322 | + // mPDF 5.0.040 | |
| 1465 | 1323 | $curves = array($pdfx1,-$pdfy1,$pdfx2,-$pdfy2,$pdfx,-$pdfy); |
| 1466 | 1324 | $bx = calc_bezier_bbox($start, $curves); |
| 1467 | 1325 | $minl = min($minl,$bx[0]); |
| 1468 | 1326 | $maxr = max($maxr,$bx[2]); |
| @@ -1520,8 +1378,9 @@ | ||
| 1520 | 1378 | $this->lastcontrolpoints = array(($pdfx-$pdfx2),-($pdfy-$pdfy2)); // mPDF 4.4.003 always relative |
| 1521 | 1379 | |
| 1522 | 1380 | $pdf_pt = $this->svg_overflow($pdfx,$pdfy); |
| 1523 | 1381 | |
| 1382 | + // mPDF 5.0.040 | |
| 1524 | 1383 | $curves = array($pdfx1,-$pdfy1,$pdfx2,-$pdfy2,$pdfx,-$pdfy); |
| 1525 | 1384 | $bx = calc_bezier_bbox($start, $curves); |
| 1526 | 1385 | $minl = min($minl,$bx[0]); |
| 1527 | 1386 | $maxr = max($maxr,$bx[2]); |
| @@ -1538,8 +1397,9 @@ | ||
| 1538 | 1397 | } |
| 1539 | 1398 | } |
| 1540 | 1399 | break; |
| 1541 | 1400 | case 't': // bezier quadratic avec point de control simetrique a lancien point de control |
| 1401 | + // mPDF 4.4.003 | |
| 1542 | 1402 | if (!($this->lastcommand == 'Q' || $this->lastcommand == 'q' || $this->lastcommand == 'T' || $this->lastcommand == 't')) { |
| 1543 | 1403 | $this->lastcontrolpoints = array(0,0); |
| 1544 | 1404 | } |
| 1545 | 1405 | for($i = 0; $i<$ile_argumentow; $i += 2){ |
| @@ -1552,10 +1412,10 @@ | ||
| 1552 | 1412 | if($relative){ |
| 1553 | 1413 | $pdfx = ($this->xbase + $x); |
| 1554 | 1414 | $pdfy = ($this->ybase - $y); |
| 1555 | 1415 | |
| 1556 | - $pdfx1 = ($this->xbase + ($x1)); | |
| 1557 | - $pdfy1 = ($this->ybase - ($y1)); | |
| 1416 | + $pdfx1 = ($this->xbase + ($x1)); // mPDF 4.4.003 | |
| 1417 | + $pdfy1 = ($this->ybase - ($y1)); // mPDF 4.4.003 | |
| 1558 | 1418 | // mPDF 4.4.003 |
| 1559 | 1419 | $pdfx2 = $pdfx1 + 1/3 *($x); |
| 1560 | 1420 | $pdfy2 = $pdfy1 + 1/3 *(-$y) ; |
| 1561 | 1421 | |
| @@ -1565,10 +1425,10 @@ | ||
| 1565 | 1425 | else{ |
| 1566 | 1426 | $pdfx = $x; |
| 1567 | 1427 | $pdfy = -$y; |
| 1568 | 1428 | |
| 1569 | - $pdfx1 = ($this->xbase + ($x1)); | |
| 1570 | - $pdfy1 = ($this->ybase - ($y1)); | |
| 1429 | + $pdfx1 = ($this->xbase + ($x1)); // mPDF 4.4.003 | |
| 1430 | + $pdfy1 = ($this->ybase - ($y1)); // mPDF 4.4.003 | |
| 1571 | 1431 | // mPDF 4.4.003 |
| 1572 | 1432 | $pdfx2 = $pdfx1 + 1/3 *($x - $this->xbase); |
| 1573 | 1433 | $pdfy2 = $pdfy1 + 1/3 *(-$y - $this->ybase) ; |
| 1574 | 1434 | |
| @@ -1577,8 +1437,9 @@ | ||
| 1577 | 1437 | } |
| 1578 | 1438 | |
| 1579 | 1439 | $this->lastcontrolpoints = array(($pdfx-$pdfx2),-($pdfy-$pdfy2)); // mPDF 4.4.003 always relative |
| 1580 | 1440 | |
| 1441 | + // mPDF 5.0.040 | |
| 1581 | 1442 | $curves = array($pdfx1,-$pdfy1,$pdfx2,-$pdfy2,$pdfx,-$pdfy); |
| 1582 | 1443 | $bx = calc_bezier_bbox($start, $curves); |
| 1583 | 1444 | $minl = min($minl,$bx[0]); |
| 1584 | 1445 | $maxr = max($maxr,$bx[2]); |
| @@ -1609,8 +1470,9 @@ | ||
| 1609 | 1470 | else{ |
| 1610 | 1471 | $this->xbase = $x2; |
| 1611 | 1472 | $this->ybase = -$y2; |
| 1612 | 1473 | } |
| 1474 | + // mPDF 5.0.039 // mPDF 5.0.040 | |
| 1613 | 1475 | list($pcmd, $bounds) = $this->Arcto($x1, $y1, $x2, $y2, $rx, $ry, $angle, $largeArcFlag, $sweepFlag); |
| 1614 | 1476 | $minl = min($minl,$x2,min($bounds[0])); |
| 1615 | 1477 | $maxr = max($maxr,$x2,max($bounds[0])); |
| 1616 | 1478 | $mint = min($mint,$y2,min($bounds[1])); |
| @@ -1620,8 +1482,9 @@ | ||
| 1620 | 1482 | } |
| 1621 | 1483 | break; |
| 1622 | 1484 | case'z': |
| 1623 | 1485 | $path_cmd .= 'h '; |
| 1486 | + // mPDF 4.4.003 | |
| 1624 | 1487 | $this->subPathInit = true; |
| 1625 | 1488 | $newsubpath = true; |
| 1626 | 1489 | $this->xbase = $this->spxstart; |
| 1627 | 1490 | $this->ybase = $this->spystart; |
| @@ -1629,9 +1492,9 @@ | ||
| 1629 | 1492 | default: |
| 1630 | 1493 | break; |
| 1631 | 1494 | } |
| 1632 | 1495 | |
| 1633 | - if (!$newsubpath) { $this->subPathInit = false; } | |
| 1496 | + if (!$newsubpath) { $this->subPathInit = false; } // mPDF 4.4.003 | |
| 1634 | 1497 | $this->lastcommand = $command; |
| 1635 | 1498 | // mPDF 5.0.039 |
| 1636 | 1499 | $this->pathBBox[0] = $minl; |
| 1637 | 1500 | $this->pathBBox[1] = $mint; |
| @@ -1642,8 +1505,9 @@ | ||
| 1642 | 1505 | } |
| 1643 | 1506 | |
| 1644 | 1507 | function Arcto($x1, $y1, $x2, $y2, $rx, $ry, $angle, $largeArcFlag, $sweepFlag) { |
| 1645 | 1508 | |
| 1509 | + // mPDF 5.0.040 | |
| 1646 | 1510 | $bounds = array(0=>array($x1,$x2),1=>array($y1,$y2)); |
| 1647 | 1511 | // 1. Treat out-of-range parameters as described in |
| 1648 | 1512 | // http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes |
| 1649 | 1513 | // If the endpoints (x1, y1) and (x2, y2) are identical, then this |
| @@ -1652,9 +1516,9 @@ | ||
| 1652 | 1516 | |
| 1653 | 1517 | // If rX = 0 or rY = 0 then this arc is treated as a straight line |
| 1654 | 1518 | // segment (a "lineto") joining the endpoints. |
| 1655 | 1519 | if ($rx == 0.0 || $ry == 0.0) { |
| 1656 | - // return array(Lineto(x2, y2), $bounds); | |
| 1520 | + // return array(Lineto(x2, y2), $bounds); // mPD 5.0.040 | |
| 1657 | 1521 | } |
| 1658 | 1522 | |
| 1659 | 1523 | // If rX or rY have negative signs, these are dropped; the absolute |
| 1660 | 1524 | // value is used instead. |
| @@ -1762,8 +1626,9 @@ | ||
| 1762 | 1626 | return (6.28318530718 - ($ta-$tb)); |
| 1763 | 1627 | } |
| 1764 | 1628 | |
| 1765 | 1629 | |
| 1630 | + // mPDF 4.4.003 | |
| 1766 | 1631 | function ConvertSVGSizePixels($size=5,$maxsize='x'){ |
| 1767 | 1632 | // maxsize in pixels (user units) or 'y' or 'x' |
| 1768 | 1633 | // e.g. $w = $this->ConvertSVGSizePixels($arguments['w'],$this->svg_info['w']*(25.4/$this->mpdf_ref->dpi)); |
| 1769 | 1634 | // usefontsize - setfalse for e.g. margins - will ignore fontsize for % values |
| @@ -1773,14 +1638,15 @@ | ||
| 1773 | 1638 | |
| 1774 | 1639 | if ($maxsize == 'y') { $maxsize = $this->svg_info['h']; } |
| 1775 | 1640 | else if ($maxsize == 'x') { $maxsize = $this->svg_info['w']; } |
| 1776 | 1641 | $maxsize *= (25.4/$this->mpdf_ref->dpi); // convert pixels to mm |
| 1777 | - $fontsize=$this->mpdf_ref->FontSize / $this->kf; | |
| 1642 | + $fontsize=$this->mpdf_ref->FontSize; | |
| 1778 | 1643 | //Return as pixels |
| 1779 | 1644 | $size = $this->mpdf_ref->ConvertSize($size,$maxsize,$fontsize,false) * 1/(25.4/$this->mpdf_ref->dpi); |
| 1780 | 1645 | return $size; |
| 1781 | 1646 | } |
| 1782 | 1647 | |
| 1648 | + // mPDF 4.4.003 | |
| 1783 | 1649 | function ConvertSVGSizePts($size=5){ |
| 1784 | 1650 | // usefontsize - setfalse for e.g. margins - will ignore fontsize for % values |
| 1785 | 1651 | // Depends of maxsize value to make % work properly. Usually maxsize == pagewidth |
| 1786 | 1652 | // For text $maxsize = Fontsize |
| @@ -1795,9 +1661,9 @@ | ||
| 1795 | 1661 | // |
| 1796 | 1662 | // fonction retracant les <rect /> |
| 1797 | 1663 | function svgRect($arguments){ |
| 1798 | 1664 | |
| 1799 | - if ($arguments['h']==0 || $arguments['w']==0) { return ''; } | |
| 1665 | + if ($arguments['h']==0 || $arguments['w']==0) { return ''; } // mPDF 4.4.003 | |
| 1800 | 1666 | |
| 1801 | 1667 | $x = $this->ConvertSVGSizePixels($arguments['x'],'x'); // mPDF 4.4.003 |
| 1802 | 1668 | $y = $this->ConvertSVGSizePixels($arguments['y'],'y'); // mPDF 4.4.003 |
| 1803 | 1669 | $h = $this->ConvertSVGSizePixels($arguments['h'],'y'); // mPDF 4.4.003 |
| @@ -1849,16 +1715,16 @@ | ||
| 1849 | 1715 | // fonction retracant les <ellipse /> et <circle /> |
| 1850 | 1716 | // le cercle est trac� grave a 4 bezier cubic, les poitn de controles |
| 1851 | 1717 | // sont deduis grace a la constante kappa * rayon |
| 1852 | 1718 | function svgEllipse($arguments){ |
| 1853 | - if ($arguments['rx']==0 || $arguments['ry']==0) { return ''; } | |
| 1719 | + if ($arguments['rx']==0 || $arguments['ry']==0) { return ''; } // mPDF 4.4.003 | |
| 1854 | 1720 | |
| 1855 | 1721 | $kappa = 4*(sqrt(2)-1)/3; |
| 1856 | 1722 | |
| 1857 | - $cx = $this->ConvertSVGSizePixels($arguments['cx'],'x'); | |
| 1858 | - $cy = $this->ConvertSVGSizePixels($arguments['cy'],'y'); | |
| 1859 | - $rx = $this->ConvertSVGSizePixels($arguments['rx'],'x'); | |
| 1860 | - $ry = $this->ConvertSVGSizePixels($arguments['ry'],'y'); | |
| 1723 | + $cx = $this->ConvertSVGSizePixels($arguments['cx'],'x'); // mPDF 4.4.003 | |
| 1724 | + $cy = $this->ConvertSVGSizePixels($arguments['cy'],'y'); // mPDF 4.4.003 | |
| 1725 | + $rx = $this->ConvertSVGSizePixels($arguments['rx'],'x'); // mPDF 4.4.003 | |
| 1726 | + $ry = $this->ConvertSVGSizePixels($arguments['ry'],'y'); // mPDF 4.4.003 | |
| 1861 | 1727 | |
| 1862 | 1728 | $x1 = $cx; |
| 1863 | 1729 | $y1 = -$cy+$ry; |
| 1864 | 1730 | |
| @@ -1889,11 +1755,11 @@ | ||
| 1889 | 1755 | $xbase = $arguments[0] ; |
| 1890 | 1756 | $ybase = - $arguments[1] ; |
| 1891 | 1757 | } |
| 1892 | 1758 | else { |
| 1893 | - if ($arguments[0]==$arguments[2] && $arguments[1]==$arguments[3]) { return ''; } // Zero length line | |
| 1894 | - $xbase = $this->ConvertSVGSizePixels($arguments[0],'x'); | |
| 1895 | - $ybase = - $this->ConvertSVGSizePixels($arguments[1],'y'); | |
| 1759 | + if ($arguments[0]==$arguments[2] && $arguments[1]==$arguments[3]) { return ''; } // mPDF 4.4.003 Zero length line | |
| 1760 | + $xbase = $this->ConvertSVGSizePixels($arguments[0],'x'); // mPDF 4.4.003 | |
| 1761 | + $ybase = - $this->ConvertSVGSizePixels($arguments[1],'y'); // mPDF 4.4.003 | |
| 1896 | 1762 | } |
| 1897 | 1763 | $path_cmd = sprintf('%.3F %.3F m ', $xbase*$this->kp, $ybase*$this->kp); |
| 1898 | 1764 | for ($i = 2; $i<count($arguments);$i += 2) { |
| 1899 | 1765 | if ($ispolyline) { |
| @@ -1900,10 +1766,10 @@ | ||
| 1900 | 1766 | $tmp_x = $arguments[$i] ; |
| 1901 | 1767 | $tmp_y = - $arguments[($i+1)] ; |
| 1902 | 1768 | } |
| 1903 | 1769 | else { |
| 1904 | - $tmp_x = $this->ConvertSVGSizePixels($arguments[$i],'x') ; | |
| 1905 | - $tmp_y = - $this->ConvertSVGSizePixels($arguments[($i+1)],'y') ; | |
| 1770 | + $tmp_x = $this->ConvertSVGSizePixels($arguments[$i],'x') ; // mPDF 4.4.003 | |
| 1771 | + $tmp_y = - $this->ConvertSVGSizePixels($arguments[($i+1)],'y') ; // mPDF 4.4.003 | |
| 1906 | 1772 | } |
| 1907 | 1773 | $path_cmd .= sprintf('%.3F %.3F l ', $tmp_x*$this->kp, $tmp_y*$this->kp); |
| 1908 | 1774 | } |
| 1909 | 1775 | |
| @@ -1934,187 +1800,41 @@ | ||
| 1934 | 1800 | // |
| 1935 | 1801 | // write string to image |
| 1936 | 1802 | function svgText() { |
| 1937 | 1803 | // $tmp = count($this->txt_style)-1; |
| 1938 | - $current_style = $this->txt_style[count($this->txt_style)-1]; // mPDF 5.7.4 | |
| 1804 | + $current_style = array_pop($this->txt_style); | |
| 1939 | 1805 | $style = ''; |
| 1940 | - $op = ''; | |
| 1941 | 1806 | $render = -1; |
| 1942 | - if(isset($this->txt_data[2])) { | |
| 1943 | - // mPDF 6 | |
| 1944 | - // If using SVG Font | |
| 1945 | - if (isset($this->svg_font[$current_style['font-family']])) { | |
| 1946 | - // select font | |
| 1947 | - $style = 'R'; | |
| 1948 | - $style .= (isset($current_style['font-weight']) && $current_style['font-weight'] == 'bold')?'B':''; | |
| 1949 | - $style .= (isset($current_style['font-style']) && $current_style['font-style'] == 'italic')?'I':''; | |
| 1950 | - $style .= (isset($current_style['font-variant']) && $current_style['font-variant'] == 'small-caps')?'S':''; | |
| 1951 | - | |
| 1952 | - $fontsize = $current_style['font-size'] * $this->mpdf_ref->dpi / 72; | |
| 1953 | - if (isset($this->svg_font[$current_style['font-family']][$style])) { | |
| 1954 | - $svg_font = $this->svg_font[$current_style['font-family']][$style]; | |
| 1955 | - } | |
| 1956 | - else if (isset($this->svg_font[$current_style['font-family']]['R'])) { | |
| 1957 | - $svg_font = $this->svg_font[$current_style['font-family']]['R']; | |
| 1958 | - } | |
| 1959 | - | |
| 1960 | - if (!isset($svg_font['units-per-em']) || $svg_font['units-per-em']<1) { $svg_font['units-per-em'] = 1000; } | |
| 1961 | - $units_per_em = $svg_font['units-per-em']; | |
| 1962 | - $scale = $fontsize / $units_per_em; | |
| 1963 | - $stroke_width = $current_style['stroke-width']; | |
| 1964 | - $stroke_width /= $scale; | |
| 1965 | - | |
| 1966 | - $opacitystr = ''; | |
| 1967 | - $fopacity = 1; | |
| 1968 | - if (isset($current_style['fill-opacity'])) { | |
| 1969 | - if ($current_style['fill-opacity'] == 0) { $fopacity = 0; } | |
| 1970 | - else if ($current_style['fill-opacity'] > 1) { $fopacity = 1; } | |
| 1971 | - else if ($current_style['fill-opacity'] > 0) { $fopacity = $current_style['fill-opacity']; } | |
| 1972 | - else if ($current_style['fill-opacity'] < 0) { $fopacity = 0; } | |
| 1973 | - } | |
| 1974 | - $sopacity = 1; | |
| 1975 | - if (isset($current_style['stroke-opacity'])) { | |
| 1976 | - if ($current_style['stroke-opacity'] == 0) { $sopacity = 0; } | |
| 1977 | - else if ($current_style['stroke-opacity'] > 1) { $sopacity = 1; } | |
| 1978 | - else if ($current_style['stroke-opacity'] > 0) { $sopacity = $current_style['stroke-opacity']; } | |
| 1979 | - else if ($current_style['stroke-opacity'] < 0) { $sopacity = 0; } | |
| 1980 | - } | |
| 1981 | - $gs = $this->mpdf_ref->AddExtGState(array('ca'=>$fopacity, 'CA'=>$sopacity, 'BM'=>'/Normal')); | |
| 1982 | - $this->mpdf_ref->extgstates[$gs]['fo'] = true; | |
| 1983 | - $opacitystr = sprintf(' /GS%d gs ', $gs); | |
| 1984 | - | |
| 1985 | - $fillstr = ''; | |
| 1986 | - if (isset($current_style['fill']) && $current_style['fill']!='none') { | |
| 1987 | - $col = $this->mpdf_ref->ConvertColor($current_style['fill']); | |
| 1988 | - $fillstr = $this->mpdf_ref->SetFColor($col, true); | |
| 1989 | - $render = "0"; // Fill (only) | |
| 1990 | - $op = 'f'; | |
| 1991 | - } | |
| 1992 | - $strokestr = ''; | |
| 1993 | - if ($stroke_width>0 && $current_style['stroke']!='none') { | |
| 1994 | - $scol = $this->mpdf_ref->ConvertColor($current_style['stroke']); | |
| 1995 | - if ($scol) { | |
| 1996 | - $strokestr .= $this->mpdf_ref->SetDColor($scol, true).' '; | |
| 1997 | - } | |
| 1998 | - $linewidth = $this->ConvertSVGSizePixels($stroke_width); | |
| 1999 | - if ($linewidth > 0) { | |
| 2000 | - $strokestr .= sprintf('%.3F w 0 J 0 j ',$linewidth*$this->kp); | |
| 2001 | - if ($render == -1) { $render = "1"; } // stroke only | |
| 2002 | - else { $render = "2"; } // fill and stroke | |
| 2003 | - $op .= 'S'; | |
| 2004 | - } | |
| 2005 | - } | |
| 2006 | - if ($render == -1) { return ''; } | |
| 2007 | - if ($op == 'fS') { $op = 'B'; } | |
| 2008 | - | |
| 2009 | - $x = $this->txt_data[0]; // mPDF 5.7.4 | |
| 2010 | - $y = $this->txt_data[1]; // mPDF 5.7.4 | |
| 2011 | - $txt = $this->txt_data[2]; | |
| 2012 | - | |
| 2013 | - $txt = preg_replace('/\f/','',$txt); | |
| 2014 | - $txt = preg_replace('/\r/','',$txt); | |
| 2015 | - $txt = preg_replace('/\n/',' ',$txt); | |
| 2016 | - $txt = preg_replace('/\t/',' ',$txt); | |
| 2017 | - $txt = preg_replace("/[ ]+/u",' ',$txt); | |
| 2018 | - | |
| 2019 | - if ($this->textjuststarted) { $txt = ltrim($txt); } // mPDF 5.7.4 | |
| 2020 | - $this->textjuststarted = false; // mPDF 5.7.4 | |
| 2021 | - | |
| 2022 | - $txt = $this->mpdf_ref->purify_utf8_text($txt); | |
| 2023 | - if ($this->mpdf_ref->text_input_as_HTML) { | |
| 2024 | - $txt = $this->mpdf_ref->all_entities_to_utf8($txt); | |
| 2025 | - } | |
| 2026 | - | |
| 2027 | - $nb=mb_strlen($txt, 'UTF-8'); | |
| 2028 | - $i=0; | |
| 2029 | - $sw = 0; | |
| 2030 | - $subpath_cmd = ''; | |
| 2031 | - while($i<$nb) { | |
| 2032 | - //Get next character | |
| 2033 | - $char = mb_substr($txt,$i,1,'UTF-8'); | |
| 2034 | - | |
| 2035 | - | |
| 2036 | - if (isset($svg_font['glyphs'][$char])) { | |
| 2037 | - $d = $svg_font['glyphs'][$char]['d']; | |
| 2038 | - if (isset($svg_font['glyphs'][$char]['horiz-adv-x'])) { $horiz_adv_x = $svg_font['glyphs'][$char]['horiz-adv-x']; } | |
| 2039 | - else { $horiz_adv_x = $svg_font['horiz-adv-x']; } // missing glyph width | |
| 2040 | - } | |
| 2041 | - else { | |
| 2042 | - $d = $svg_font['d']; | |
| 2043 | - $horiz_adv_x = $svg_font['horiz-adv-x']; // missing glyph width | |
| 2044 | - } | |
| 2045 | - preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $d, $commands, PREG_SET_ORDER); | |
| 2046 | - $subpath_cmd .= sprintf('q %.4F 0 0 %.4F mPDF-AXS(%.4F) %.4F cm ', $scale, -$scale, ($x + $sw*$scale)*$this->kp, -$y*$this->kp); | |
| 2047 | - | |
| 2048 | - $this->subPathInit = true; | |
| 2049 | - $this->pathBBox = array(999999,999999,-999999,-999999); | |
| 2050 | - foreach($commands as $cmd){ | |
| 2051 | - if(count($cmd)==3 || (isset($cmd[2]) && $cmd[2]=='')){ | |
| 2052 | - list($tmp, $command, $arguments) = $cmd; | |
| 2053 | - } | |
| 2054 | - else{ | |
| 2055 | - list($tmp, $command) = $cmd; | |
| 2056 | - $arguments = ''; | |
| 2057 | - } | |
| 2058 | - | |
| 2059 | - $subpath_cmd .= $this->svgPath($command, $arguments); | |
| 2060 | - } | |
| 2061 | - $subpath_cmd .= $op . ' Q '; | |
| 2062 | - if ($this->pathBBox[2]==-1999998) { $this->pathBBox[2] = 100; } | |
| 2063 | - if ($this->pathBBox[3]==-1999998) { $this->pathBBox[3] = 100; } | |
| 2064 | - if ($this->pathBBox[0]==999999) { $this->pathBBox[0] = 0; } | |
| 2065 | - if ($this->pathBBox[1]==999999) { $this->pathBBox[1] = 0; } | |
| 2066 | - | |
| 2067 | - | |
| 2068 | - $sw += $horiz_adv_x; | |
| 2069 | - $i++; | |
| 2070 | - } | |
| 2071 | - | |
| 2072 | - $sw *= $scale; // convert stringwidth to units | |
| 2073 | - | |
| 2074 | - // mPDF 5.7.4 | |
| 2075 | - $this->textlength = $sw; | |
| 2076 | - $this->texttotallength += $this->textlength; | |
| 2077 | - | |
| 2078 | - $path_cmd = sprintf('q %s %s Tr %s %s ',$opacitystr,$render,$fillstr,$strokestr); | |
| 2079 | - $path_cmd .= $subpath_cmd; | |
| 2080 | - $path_cmd .= 'Q '; | |
| 2081 | - | |
| 2082 | - unset($this->txt_data[0], $this->txt_data[1], $this->txt_data[2]); | |
| 2083 | - return $path_cmd; | |
| 2084 | - } | |
| 2085 | - | |
| 1807 | + if(isset($this->txt_data[2])) | |
| 1808 | + { | |
| 2086 | 1809 | // select font |
| 2087 | 1810 | $style .= ($current_style['font-weight'] == 'bold')?'B':''; |
| 2088 | 1811 | $style .= ($current_style['font-style'] == 'italic')?'I':''; |
| 2089 | - $size = $current_style['font-size']*$this->kf; | |
| 1812 | + $size = $current_style['font-size']*$this->kf; // mPDF 5.0.039 | |
| 2090 | 1813 | |
| 1814 | + // mPDF 5.0 | |
| 2091 | 1815 | $current_style['font-family'] = $this->mpdf_ref->SetFont($current_style['font-family'],$style,$size,false); |
| 2092 | - $this->mpdf_ref->CurrentFont['fo'] = true; | |
| 1816 | + $this->mpdf_ref->CurrentFont['fo'] = true; // mPDF 5.0.039 | |
| 2093 | 1817 | |
| 1818 | + | |
| 1819 | + // mPDF 5.0.041 | |
| 2094 | 1820 | $opacitystr = ''; |
| 2095 | - // mPDF 6 | |
| 2096 | - $fopacity = 1; | |
| 1821 | + $opacity = 1; | |
| 2097 | 1822 | if (isset($current_style['fill-opacity'])) { |
| 2098 | - if ($current_style['fill-opacity'] == 0) { $fopacity = 0; } | |
| 2099 | - else if ($current_style['fill-opacity'] > 1) { $fopacity = 1; } | |
| 2100 | - else if ($current_style['fill-opacity'] > 0) { $fopacity = $current_style['fill-opacity']; } | |
| 2101 | - else if ($current_style['fill-opacity'] < 0) { $fopacity = 0; } | |
| 1823 | + if ($current_style['fill-opacity'] == 0) { $opacity = 0; } | |
| 1824 | + else if ($current_style['fill-opacity'] > 1) { $opacity = 1; } | |
| 1825 | + else if ($current_style['fill-opacity'] > 0) { $opacity = $current_style['fill-opacity']; } | |
| 1826 | + else if ($current_style['fill-opacity'] < 0) { $opacity = 0; } | |
| 2102 | 1827 | } |
| 2103 | - $sopacity = 1; | |
| 2104 | - if (isset($current_style['stroke-opacity'])) { | |
| 2105 | - if ($current_style['stroke-opacity'] == 0) { $sopacity = 0; } | |
| 2106 | - else if ($current_style['stroke-opacity'] > 1) { $sopacity = 1; } | |
| 2107 | - else if ($current_style['stroke-opacity'] > 0) { $sopacity = $current_style['stroke-opacity']; } | |
| 2108 | - else if ($current_style['stroke-opacity'] < 0) { $sopacity = 0; } | |
| 2109 | - } | |
| 2110 | - $gs = $this->mpdf_ref->AddExtGState(array('ca'=>$fopacity, 'CA'=>$sopacity, 'BM'=>'/Normal')); | |
| 2111 | - $this->mpdf_ref->extgstates[$gs]['fo'] = true; | |
| 1828 | + $gs = $this->mpdf_ref->AddExtGState(array('ca'=>$opacity, 'BM'=>'/Normal')); | |
| 1829 | + $this->mpdf_ref->extgstates[$gs]['fo'] = true; // mPDF 5.0.039 | |
| 2112 | 1830 | $opacitystr = sprintf(' /GS%d gs ', $gs); |
| 2113 | 1831 | |
| 1832 | + // mPDF 5.0.051 | |
| 2114 | 1833 | $fillstr = ''; |
| 2115 | 1834 | if (isset($current_style['fill']) && $current_style['fill']!='none') { |
| 2116 | 1835 | $col = $this->mpdf_ref->ConvertColor($current_style['fill']); |
| 1836 | + // mPDF 5.0.051 | |
| 2117 | 1837 | $fillstr = $this->mpdf_ref->SetFColor($col, true); |
| 2118 | 1838 | $render = "0"; // Fill (only) |
| 2119 | 1839 | } |
| 2120 | 1840 | $strokestr = ''; |
| @@ -2120,9 +1840,9 @@ | ||
| 2120 | 1840 | $strokestr = ''; |
| 2121 | 1841 | if (isset($current_style['stroke-width']) && $current_style['stroke-width']>0 && $current_style['stroke']!='none') { |
| 2122 | 1842 | $scol = $this->mpdf_ref->ConvertColor($current_style['stroke']); |
| 2123 | 1843 | if ($scol) { |
| 2124 | - $strokestr .= $this->mpdf_ref->SetDColor($scol, true).' '; | |
| 1844 | + $strokestr .= $this->mpdf_ref->SetDColor($scol, true).' '; // mPDF 5.0.051 | |
| 2125 | 1845 | } |
| 2126 | 1846 | $linewidth = $this->ConvertSVGSizePixels($current_style['stroke-width']); |
| 2127 | 1847 | if ($linewidth > 0) { |
| 2128 | 1848 | $strokestr .= sprintf('%.3F w 1 J 1 j ',$linewidth*$this->kp); |
| @@ -2131,12 +1851,13 @@ | ||
| 2131 | 1851 | } |
| 2132 | 1852 | } |
| 2133 | 1853 | if ($render == -1) { return ''; } |
| 2134 | 1854 | |
| 2135 | - $x = $this->txt_data[0]; // mPDF 5.7.4 | |
| 2136 | - $y = $this->txt_data[1]; // mPDF 5.7.4 | |
| 1855 | + $x = $this->ConvertSVGSizePixels($this->txt_data[0],'x'); // mPDF 4.4.003 | |
| 1856 | + $y = $this->ConvertSVGSizePixels($this->txt_data[1],'y'); // mPDF 4.4.003 | |
| 2137 | 1857 | $txt = $this->txt_data[2]; |
| 2138 | 1858 | |
| 1859 | + // mPDF 4.4.003 | |
| 2139 | 1860 | $txt = preg_replace('/\f/','',$txt); |
| 2140 | 1861 | $txt = preg_replace('/\r/','',$txt); |
| 2141 | 1862 | $txt = preg_replace('/\n/',' ',$txt); |
| 2142 | 1863 | $txt = preg_replace('/\t/',' ',$txt); |
| @@ -2141,10 +1862,9 @@ | ||
| 2141 | 1862 | $txt = preg_replace('/\n/',' ',$txt); |
| 2142 | 1863 | $txt = preg_replace('/\t/',' ',$txt); |
| 2143 | 1864 | $txt = preg_replace("/[ ]+/u",' ',$txt); |
| 2144 | 1865 | |
| 2145 | - if ($this->textjuststarted) { $txt = ltrim($txt); } // mPDF 5.7.4 | |
| 2146 | - $this->textjuststarted = false; // mPDF 5.7.4 | |
| 1866 | + $txt = trim($txt); | |
| 2147 | 1867 | |
| 2148 | 1868 | $txt = $this->mpdf_ref->purify_utf8_text($txt); |
| 2149 | 1869 | if ($this->mpdf_ref->text_input_as_HTML) { |
| 2150 | 1870 | $txt = $this->mpdf_ref->all_entities_to_utf8($txt); |
| @@ -2149,63 +1869,46 @@ | ||
| 2149 | 1869 | if ($this->mpdf_ref->text_input_as_HTML) { |
| 2150 | 1870 | $txt = $this->mpdf_ref->all_entities_to_utf8($txt); |
| 2151 | 1871 | } |
| 2152 | 1872 | |
| 1873 | + // mPDF 5.0 | |
| 2153 | 1874 | if ($this->mpdf_ref->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mpdf_ref->mb_enc,'UTF-8'); } |
| 2154 | - if (preg_match("/([".$this->mpdf_ref->pregRTLchars."])/u", $txt)) { $this->mpdf_ref->biDirectional = true; } | |
| 1875 | + if (preg_match("/([".$this->mpdf_ref->pregRTLchars."])/u", $txt)) { $this->mpdf_ref->biDirectional = true; } // mPDF 4.4.003 | |
| 2155 | 1876 | |
| 2156 | - $textvar = 0; | |
| 2157 | - $save_OTLtags = $this->mpdf_ref->OTLtags; | |
| 2158 | - $this->mpdf_ref->OTLtags = array(); | |
| 2159 | - if ($this->mpdf_ref->useKerning) { | |
| 2160 | - if ($this->mpdf_ref->CurrentFont['haskernGPOS']) { | |
| 2161 | - if (isset($this->mpdf_ref->OTLtags['Plus'])) { $this->mpdf_ref->OTLtags['Plus'] .= ' kern'; } | |
| 2162 | - else { $this->mpdf_ref->OTLtags['Plus'] = ' kern'; } | |
| 2163 | - } | |
| 2164 | - else { $textvar = ($textvar | FC_KERNING); } | |
| 1877 | + $this->mpdf_ref->magic_reverse_dir($txt, true, 'ltr'); // mPDF 5.0.054 | |
| 1878 | + $this->mpdf_ref->ConvertIndic($txt); | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + if ($current_style['text-anchor']=='middle') { | |
| 1882 | + $tw = $this->mpdf_ref->GetStringWidth($txt)*$this->mpdf_ref->k/2; // mPDF 4.4.003 | |
| 2165 | 1883 | } |
| 1884 | + else if ($current_style['text-anchor']=='end') { | |
| 1885 | + $tw = $this->mpdf_ref->GetStringWidth($txt)*$this->mpdf_ref->k; // mPDF 4.4.003 | |
| 1886 | + } | |
| 1887 | + else $tw = 0; | |
| 2166 | 1888 | |
| 2167 | - // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 2168 | - if (isset($this->mpdf_ref->CurrentFont['useOTL']) && $this->mpdf_ref->CurrentFont['useOTL']) { | |
| 2169 | - $txt = $this->mpdf_ref->otl->applyOTL($txt, $this->mpdf_ref->CurrentFont['useOTL']); | |
| 2170 | - $OTLdata = $this->mpdf_ref->otl->OTLdata; | |
| 1889 | + if (!$this->mpdf_ref->usingCoreFont) { | |
| 1890 | + $this->mpdf_ref->UTF8StringToArray($txt); // mPDF 5.0 adds chars to subset list | |
| 1891 | + $txt= $this->mpdf_ref->UTF8ToUTF16BE($txt, false); | |
| 2171 | 1892 | } |
| 2172 | - $this->mpdf_ref->OTLtags = $save_OTLtags ; | |
| 2173 | - | |
| 2174 | - $this->mpdf_ref->magic_reverse_dir($txt, $this->mpdf_ref->directionality, $OTLdata); | |
| 2175 | - | |
| 1893 | + $txt='('.$this->mpdf_ref->_escape($txt).')'; | |
| 2176 | 1894 | $this->mpdf_ref->CurrentFont['used']= true; |
| 2177 | 1895 | |
| 2178 | - $sw = $this->mpdf_ref->GetStringWidth($txt, true, $OTLdata, $textvar); // also adds characters to subset | |
| 1896 | + $pdfx = $x - $tw/$this->kp; // mPDF 4.4.009 | |
| 1897 | + $pdfy = -$y ; | |
| 1898 | + $xbase = $x; | |
| 1899 | + $ybase = -$y; | |
| 2179 | 1900 | |
| 2180 | - // mPDF 5.7.4 | |
| 2181 | - $this->textlength = $sw * 1/(25.4/$this->mpdf_ref->dpi); | |
| 2182 | - $this->texttotallength += $this->textlength; | |
| 2183 | - | |
| 2184 | - $pdfx = $x *$this->kp; | |
| 2185 | - $pdfy = -$y *$this->kp; | |
| 2186 | - | |
| 2187 | - $aixextra = sprintf(' /F%d %.3F Tf %s %s Tr %s %s ',$this->mpdf_ref->CurrentFont['i'],$this->mpdf_ref->FontSizePt,$opacitystr,$render,$fillstr,$strokestr); | |
| 2188 | - | |
| 2189 | - $path_cmd = 'q 1 0 0 1 mPDF-AXS(0.00) 0 cm '; // Align X-shift | |
| 2190 | - $path_cmd .= $this->mpdf_ref->Text($pdfx,$pdfy,$txt,$OTLdata,$textvar,$aixextra,'SVG',true); | |
| 2191 | - $path_cmd .= " Q\n"; | |
| 2192 | - | |
| 2193 | - unset($this->txt_data[0], $this->txt_data[1], $this->txt_data[2]); | |
| 2194 | - | |
| 2195 | - if (isset($current_style['font-size-parent'])) { | |
| 2196 | - $this->mpdf_ref->SetFontSize($current_style['font-size-parent']); | |
| 2197 | - } | |
| 1901 | + // mPDF 5.0.041 | |
| 1902 | + // mPDF 5.0.051 | |
| 1903 | + $path_cmd = sprintf('q BT /F%d %s %.3F Tf %.3F %.3F Td %s Tr %s %s %s Tj ET Q ',$this->mpdf_ref->CurrentFont['i'],$opacitystr, $this->mpdf_ref->FontSizePt,$pdfx*$this->kp,$pdfy*$this->kp,$render,$fillstr,$strokestr,$txt)."\n"; | |
| 1904 | + unset($this->txt_data[0], $this->txt_data[1],$this->txt_data[2]); | |
| 2198 | 1905 | } |
| 2199 | - else { return ' '; } | |
| 2200 | - // Reset font // mPDF 5.7.4 | |
| 2201 | - $prev_style = $this->txt_style[count($this->txt_style)-1]; | |
| 2202 | - $style = ''; | |
| 2203 | - $style .= ($prev_style['font-weight'] == 'bold')?'B':''; | |
| 2204 | - $style .= ($prev_style['font-style'] == 'italic')?'I':''; | |
| 2205 | - $size = $prev_style['font-size']*$this->kf; | |
| 2206 | - $this->mpdf_ref->SetFont($prev_style['font-family'],$style,$size,false); | |
| 2207 | - | |
| 1906 | + else | |
| 1907 | + { | |
| 1908 | + return ' '; | |
| 1909 | + } | |
| 1910 | +// $path_cmd .= 'h '; // mPDF 5.0 | |
| 2208 | 1911 | return $path_cmd; |
| 2209 | 1912 | } |
| 2210 | 1913 | |
| 2211 | 1914 | |
| @@ -2218,71 +1921,60 @@ | ||
| 2218 | 1921 | if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) { |
| 2219 | 1922 | $current_style['fill'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT); |
| 2220 | 1923 | } |
| 2221 | 1924 | else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']); |
| 2222 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['fill'] = $tmp; } | |
| 1925 | + if ($tmp != $critere_style['style']){ $current_style['fill'] = $tmp; } | |
| 2223 | 1926 | } |
| 2224 | 1927 | |
| 2225 | - // mPDF 6 | |
| 2226 | - if (preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m) || | |
| 2227 | - preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m)) { | |
| 2228 | - $current_style['fill-opacity'] = $m[1]; | |
| 2229 | - $current_style['stroke-opacity'] = $m[1]; | |
| 2230 | - } | |
| 2231 | - | |
| 2232 | 1928 | $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 2233 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['fill-opacity'] = $tmp;} | |
| 1929 | + if ($tmp != $critere_style['style']){ $current_style['fill-opacity'] = $tmp;} | |
| 2234 | 1930 | |
| 2235 | 1931 | $tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 2236 | - if ($tmp != $critere_style['style'] && $tmp!=$critere_style['style']){ $current_style['fill-rule'] = $tmp;} | |
| 1932 | + if ($tmp != $critere_style['style']){ $current_style['fill-rule'] = $tmp;} | |
| 2237 | 1933 | |
| 2238 | 1934 | if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) { |
| 2239 | 1935 | $current_style['stroke'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT); |
| 2240 | 1936 | } |
| 2241 | 1937 | else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 2242 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke'] = $tmp; } | |
| 1938 | + if ($tmp != $critere_style['style']){ $current_style['stroke'] = $tmp; } | |
| 2243 | 1939 | } |
| 2244 | 1940 | |
| 2245 | 1941 | $tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 2246 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linecap'] = $tmp;} | |
| 1942 | + if ($tmp != $critere_style['style']){ $current_style['stroke-linecap'] = $tmp;} | |
| 2247 | 1943 | |
| 2248 | 1944 | $tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 2249 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;} | |
| 1945 | + if ($tmp != $critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;} | |
| 2250 | 1946 | |
| 2251 | 1947 | $tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']); |
| 2252 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;} | |
| 1948 | + if ($tmp != $critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;} | |
| 2253 | 1949 | |
| 2254 | 1950 | $tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 2255 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-opacity'] = $tmp; } | |
| 1951 | + if ($tmp != $critere_style['style']){ $current_style['stroke-opacity'] = $tmp; } | |
| 2256 | 1952 | |
| 2257 | 1953 | $tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 2258 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-width'] = $tmp;} | |
| 1954 | + if ($tmp != $critere_style['style']){ $current_style['stroke-width'] = $tmp;} | |
| 2259 | 1955 | |
| 2260 | 1956 | $tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",$critere_style['style']); |
| 2261 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;} | |
| 1957 | + if ($tmp != $critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;} | |
| 2262 | 1958 | |
| 2263 | 1959 | $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 2264 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | |
| 1960 | + if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | |
| 2265 | 1961 | |
| 2266 | - $tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.\"' ,\-]*|none)(.*)/i","$2",$critere_style['style']); | |
| 2267 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-family'] = $tmp;} | |
| 1962 | + // mPDF 5.0.039 | |
| 1963 | + $tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | |
| 1964 | + if ($tmp != $critere_style['style']){ $critere_style['font-family'] = $tmp;} | |
| 2268 | 1965 | |
| 2269 | 1966 | $tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
| 2270 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-size'] = $tmp;} | |
| 1967 | + if ($tmp != $critere_style['style']){ $critere_style['font-size'] = $tmp;} | |
| 2271 | 1968 | |
| 2272 | - $tmp = preg_replace("/(.*)font-weight:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']); | |
| 2273 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-weight'] = $tmp;} | |
| 1969 | + $tmp = preg_replace("/(.*)font-weight:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | |
| 1970 | + if ($tmp != $critere_style['style']){ $critere_style['font-weight'] = $tmp;} | |
| 2274 | 1971 | |
| 2275 | - $tmp = preg_replace("/(.*)font-style:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']); | |
| 2276 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-style'] = $tmp;} | |
| 1972 | + $tmp = preg_replace("/(.*)font-style:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | |
| 1973 | + if ($tmp != $critere_style['style']){ $critere_style['font-style'] = $tmp;} | |
| 2277 | 1974 | |
| 2278 | - $tmp = preg_replace("/(.*)font-variant:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']); | |
| 2279 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-variant'] = $tmp;} | |
| 1975 | + } | |
| 2280 | 1976 | |
| 2281 | - $tmp = preg_replace("/(.*)text-anchor:\s*(start|middle|end)(.*)/i","$2",$critere_style['style']); | |
| 2282 | - if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['text-anchor'] = $tmp;} | |
| 2283 | - | |
| 2284 | - } | |
| 2285 | 1977 | if (isset($critere_style['font'])){ |
| 2286 | 1978 | |
| 2287 | 1979 | // [ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]?<'font-size'> [ / <'line-height'> ]? <'font-family'> ] |
| 2288 | 1980 | |
| @@ -2300,16 +1992,12 @@ | ||
| 2300 | 1992 | } |
| 2301 | 1993 | $current_style['font-weight'] = $tmp; |
| 2302 | 1994 | } |
| 2303 | 1995 | |
| 2304 | - $tmp = preg_replace("/(.*)(small\-caps)(.*)/i","$2",$critere_style['font']); | |
| 2305 | - if ($tmp != $critere_style['font']){ | |
| 2306 | - $current_style['font-variant'] = $tmp; | |
| 2307 | - } | |
| 2308 | - | |
| 2309 | 1996 | // select digits not followed by percent sign nor preceeded by forward slash |
| 2310 | 1997 | $tmp = preg_replace("/(.*)\b(\d+)[\b|\/](.*)/i","$2",$critere_style['font']); |
| 2311 | 1998 | if ($tmp != $critere_style['font']){ |
| 1999 | + // mPDF 4.4.003 | |
| 2312 | 2000 | $current_style['font-size'] = $this->ConvertSVGSizePts($tmp); |
| 2313 | 2001 | $this->mpdf_ref->SetFont('','',$current_style['font-size'],false); |
| 2314 | 2002 | } |
| 2315 | 2003 | |
| @@ -2314,32 +2002,20 @@ | ||
| 2314 | 2002 | } |
| 2315 | 2003 | |
| 2316 | 2004 | } |
| 2317 | 2005 | |
| 2318 | - // mPDF 6 | |
| 2319 | - if(isset($critere_style['opacity']) && $critere_style['opacity']!='inherit'){ | |
| 2320 | - $current_style['fill-opacity'] = $critere_style['opacity']; | |
| 2321 | - $current_style['stroke-opacity'] = $critere_style['opacity']; | |
| 2322 | - } | |
| 2323 | - // mPDF 6 | |
| 2324 | - if(isset($critere_style['stroke-opacity']) && $critere_style['stroke-opacity']!='inherit'){ | |
| 2325 | - $current_style['stroke-opacity'] = $critere_style['stroke-opacity']; | |
| 2326 | - } | |
| 2327 | - // mPDF 6 | |
| 2328 | - if(isset($critere_style['fill-opacity']) && $critere_style['fill-opacity']!='inherit'){ | |
| 2329 | - $current_style['fill-opacity'] = $critere_style['fill-opacity']; | |
| 2330 | - } | |
| 2331 | - if(isset($critere_style['fill']) && $critere_style['fill']!='inherit'){ | |
| 2006 | + if(isset($critere_style['fill'])){ | |
| 2332 | 2007 | $current_style['fill'] = $critere_style['fill']; |
| 2333 | 2008 | } |
| 2334 | - if(isset($critere_style['stroke']) && $critere_style['stroke']!='inherit'){ | |
| 2009 | + // mPDF 4.4.003 | |
| 2010 | + if(isset($critere_style['stroke'])){ | |
| 2335 | 2011 | $current_style['stroke'] = $critere_style['stroke']; |
| 2336 | 2012 | } |
| 2337 | - if(isset($critere_style['stroke-width']) && $critere_style['stroke-width']!='inherit'){ | |
| 2013 | + if(isset($critere_style['stroke-width'])){ | |
| 2338 | 2014 | $current_style['stroke-width'] = $critere_style['stroke-width']; |
| 2339 | 2015 | } |
| 2340 | 2016 | |
| 2341 | - if(isset($critere_style['font-style']) && $critere_style['font-style']!='inherit'){ | |
| 2017 | + if(isset($critere_style['font-style'])){ | |
| 2342 | 2018 | if(strtolower($critere_style['font-style']) == 'oblique') |
| 2343 | 2019 | { |
| 2344 | 2020 | $critere_style['font-style'] = 'italic'; |
| 2345 | 2021 | } |
| @@ -2345,9 +2021,9 @@ | ||
| 2345 | 2021 | } |
| 2346 | 2022 | $current_style['font-style'] = $critere_style['font-style']; |
| 2347 | 2023 | } |
| 2348 | 2024 | |
| 2349 | - if(isset($critere_style['font-weight']) && $critere_style['font-weight']!='inherit'){ | |
| 2025 | + if(isset($critere_style['font-weight'])){ | |
| 2350 | 2026 | if(strtolower($critere_style['font-weight']) == 'bolder') |
| 2351 | 2027 | { |
| 2352 | 2028 | $critere_style['font-weight'] = 'bold'; |
| 2353 | 2029 | } |
| @@ -2353,30 +2029,19 @@ | ||
| 2353 | 2029 | } |
| 2354 | 2030 | $current_style['font-weight'] = $critere_style['font-weight']; |
| 2355 | 2031 | } |
| 2356 | 2032 | |
| 2357 | - if(isset($critere_style['font-variant']) && $critere_style['font-variant']!='inherit'){ | |
| 2358 | - $current_style['font-variant'] = $critere_style['font-variant']; | |
| 2359 | - } | |
| 2360 | - | |
| 2361 | - if(isset($critere_style['font-size']) && $critere_style['font-size']!='inherit'){ | |
| 2362 | - if (strpos($critere_style['font-size'], '%')!==false) { | |
| 2363 | - $current_style['font-size-parent'] = $current_style['font-size']; | |
| 2364 | - } | |
| 2033 | + if(isset($critere_style['font-size'])){ | |
| 2034 | + // mPDF 4.4.003 | |
| 2365 | 2035 | $current_style['font-size'] = $this->ConvertSVGSizePts($critere_style['font-size']); |
| 2366 | 2036 | $this->mpdf_ref->SetFont('','',$current_style['font-size'],false); |
| 2367 | 2037 | } |
| 2368 | 2038 | |
| 2369 | - if(isset($critere_style['font-family']) && $critere_style['font-family']!='inherit'){ | |
| 2039 | + if(isset($critere_style['font-family'])){ | |
| 2040 | + // mPDF 4.4.003 | |
| 2370 | 2041 | $v = $critere_style['font-family']; |
| 2371 | 2042 | $aux_fontlist = explode(",",$v); |
| 2372 | 2043 | $found = 0; |
| 2373 | - | |
| 2374 | - $svgfontstyle = 'R'; | |
| 2375 | - $svgfontstyle .= (isset($current_style['font-weight']) && $current_style['font-weight'] == 'bold')?'B':''; | |
| 2376 | - $svgfontstyle .= (isset($current_style['font-style']) && $current_style['font-style'] == 'italic')?'I':''; | |
| 2377 | - $svgfontstyle .= (isset($current_style['font-variant']) && $current_style['font-variant'] == 'small-caps')?'S':''; | |
| 2378 | - | |
| 2379 | 2044 | foreach($aux_fontlist AS $f) { |
| 2380 | 2045 | $fonttype = trim($f); |
| 2381 | 2046 | $fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype); |
| 2382 | 2047 | $fonttype = preg_replace('/ /','',$fonttype); |
| @@ -2383,9 +2048,9 @@ | ||
| 2383 | 2048 | $v = strtolower(trim($fonttype)); |
| 2384 | 2049 | if (isset($this->mpdf_ref->fonttrans[$v]) && $this->mpdf_ref->fonttrans[$v]) { $v = $this->mpdf_ref->fonttrans[$v]; } |
| 2385 | 2050 | if ((!$this->mpdf_ref->usingCoreFont && in_array($v,$this->mpdf_ref->available_unifonts)) || |
| 2386 | 2051 | ($this->mpdf_ref->usingCoreFont && in_array($v,array('courier','times','helvetica','arial'))) || |
| 2387 | - in_array($v, array('sjis','uhc','big5','gb')) || isset($this->svg_font[$v][$svgfontstyle ])) { // mPDF 6 | |
| 2052 | + in_array($v, array('sjis','uhc','big5','gb'))) { | |
| 2388 | 2053 | $current_style['font-family'] = $v; |
| 2389 | 2054 | $found = 1; |
| 2390 | 2055 | break; |
| 2391 | 2056 | } |
| @@ -2396,9 +2061,9 @@ | ||
| 2396 | 2061 | $fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype); |
| 2397 | 2062 | $fonttype = preg_replace('/ /','',$fonttype); |
| 2398 | 2063 | $v = strtolower(trim($fonttype)); |
| 2399 | 2064 | if (isset($this->mpdf_ref->fonttrans[$v]) && $this->mpdf_ref->fonttrans[$v]) { $v = $this->mpdf_ref->fonttrans[$v]; } |
| 2400 | - if (in_array($v,$this->mpdf_ref->sans_fonts) || in_array($v,$this->mpdf_ref->serif_fonts) || in_array($v,$this->mpdf_ref->mono_fonts) || isset($this->svg_font[$v][$svgfontstyle ])) { // mPDF 6 | |
| 2065 | + if (in_array($v,$this->mpdf_ref->sans_fonts) || in_array($v,$this->mpdf_ref->serif_fonts) || in_array($v,$this->mpdf_ref->mono_fonts) ) { | |
| 2401 | 2066 | $current_style['font-family'] = $v; |
| 2402 | 2067 | break; |
| 2403 | 2068 | } |
| 2404 | 2069 | } |
| @@ -2403,9 +2068,10 @@ | ||
| 2403 | 2068 | } |
| 2404 | 2069 | } |
| 2405 | 2070 | } |
| 2406 | 2071 | } |
| 2407 | - if(isset($critere_style['text-anchor']) && $critere_style['text-anchor']!='inherit'){ | |
| 2072 | + | |
| 2073 | + if(isset($critere_style['text-anchor'])){ | |
| 2408 | 2074 | $current_style['text-anchor'] = $critere_style['text-anchor']; |
| 2409 | 2075 | } |
| 2410 | 2076 | |
| 2411 | 2077 | // add current style to text style array (will remove it later after writing text to svg_string) |
| @@ -2435,34 +2101,11 @@ | ||
| 2435 | 2101 | |
| 2436 | 2102 | |
| 2437 | 2103 | // analise le svg et renvoie aux fonctions precedente our le traitement |
| 2438 | 2104 | function ImageSVG($data){ |
| 2439 | - // Try to clean up the start of the file | |
| 2440 | - // removing DOCTYPE fails with this: | |
| 2441 | -/* | |
| 2442 | -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd" | |
| 2443 | -[ | |
| 2444 | - <!ELEMENT Paragraph (#PCDATA)> | |
| 2445 | -]> | |
| 2446 | -*/ | |
| 2447 | - //$data = preg_replace('/<!DOCTYPE.*? >/is', '', $data); | |
| 2448 | - //$data = preg_replace('/<\?xml.*? >/is', '', $data); | |
| 2449 | - | |
| 2450 | - $data = preg_replace('/^.*?<svg([> ])/is', '<svg\\1', $data); // mPDF 5.7.4 | |
| 2451 | - | |
| 2452 | - $data = preg_replace('/<!--.*?-->/is', '', $data); // mPDF 5.7.4 | |
| 2453 | - | |
| 2454 | - // Converts < to < when not a tag | |
| 2455 | - $data = preg_replace('/<([^!?\/a-zA-Z_:])/i','<\\1',$data ); // mPDF 5.7.4 | |
| 2456 | - | |
| 2457 | - if (_SVG_AUTOFONT) { $data = $this->markScriptToLang($data); } | |
| 2458 | - | |
| 2459 | 2105 | $this->svg_info = array(); |
| 2460 | - $last_gradid = ''; // mPDF 6 | |
| 2461 | - $last_svg_fontid = ''; // mPDF 6 | |
| 2462 | - $last_svg_fontdefw = ''; // mPDF 6 | |
| 2463 | - $last_svg_fontstyle = ''; // mPDF 6 | |
| 2464 | 2106 | |
| 2107 | + // mPDF 4.4.006 | |
| 2465 | 2108 | if (preg_match('/<!ENTITY/si',$data)) { |
| 2466 | 2109 | // Get User-defined entities |
| 2467 | 2110 | preg_match_all('/<!ENTITY\s+([a-z]+)\s+\"(.*?)\">/si',$data, $ent); |
| 2468 | 2111 | // Replace entities |
| @@ -2470,20 +2113,21 @@ | ||
| 2470 | 2113 | $data = preg_replace('/&'.preg_quote($ent[1][$i],'/').';/is', $ent[2][$i], $data); |
| 2471 | 2114 | } |
| 2472 | 2115 | } |
| 2473 | 2116 | |
| 2474 | - if (preg_match('/xlink:href\s*=/si',$data)) { | |
| 2475 | - // GRADIENTS | |
| 2117 | + | |
| 2118 | + // mPDF 4.4.003 | |
| 2119 | + if (preg_match('/xlink:href=/si',$data)) { | |
| 2476 | 2120 | // Get links |
| 2477 | - preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href\s*=\s*["\']#(.*?)["\'](.*?)\/>/si',$data, $links); | |
| 2478 | - if (count($links[0])) { $links[5] = array(); } | |
| 2121 | + preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href=["\']#(.*?)["\'](.*?)\/>/si',$data, $links); | |
| 2122 | + if (count($links[0])) { $links[5] = array(); } // mPDF 4.5.010 | |
| 2479 | 2123 | // Delete links from data - keeping in $links |
| 2480 | 2124 | for ($i=0; $i<count($links[0]); $i++) { |
| 2481 | - $links[5][$i] = 'tmpLink'.RAND(100000,9999999); | |
| 2482 | - $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', '<MYLINKS'.$links[5][$i].'>' , $data); | |
| 2125 | + $links[5][$i] = 'tmpLink'.RAND(100000,9999999); // mPDF 4.5.010 | |
| 2126 | + $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', '<MYLINKS'.$links[5][$i].'>' , $data); // mPDF 4.5.010 | |
| 2483 | 2127 | } |
| 2484 | 2128 | // Get targets |
| 2485 | - preg_match_all('/<(linearGradient|radialgradient)([^>]*)id\s*=\s*["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',$data, $m); | |
| 2129 | + preg_match_all('/<(linearGradient|radialgradient)([^>]*)id=["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',$data, $m); | |
| 2486 | 2130 | $targets = array(); |
| 2487 | 2131 | $stops = array(); |
| 2488 | 2132 | // keeping in $targets |
| 2489 | 2133 | for ($i=0; $i<count($m[0]); $i++) { |
| @@ -2490,128 +2134,15 @@ | ||
| 2490 | 2134 | $stops[$m[3][$i]] = $m[5][$i]; |
| 2491 | 2135 | } |
| 2492 | 2136 | // Add back links this time as targets (gradients) |
| 2493 | 2137 | for ($i=0; $i<count($links[0]); $i++) { |
| 2494 | - $def = $links[1][$i] .' '.$links[4][$i].'>'. $stops[$links[3][$i]].'</'.$links[2][$i] .'>' ; | |
| 2495 | - $data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', $def , $data); | |
| 2138 | + $def = $links[1][$i] .' '.$links[4][$i].'>'. $stops[$links[3][$i]].'</'.$links[2][$i] .'>' ; // mPDF 4.5.010 | |
| 2139 | + $data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', $def , $data); // mPDF 4.5.010 | |
| 2496 | 2140 | } |
| 2497 | - | |
| 2498 | - // mPDF 5.7.4 | |
| 2499 | - // <TREF> | |
| 2500 | - preg_match_all('/<tref ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',$data, $links); | |
| 2501 | - for ($i=0; $i<count($links[0]); $i++) { | |
| 2502 | - | |
| 2503 | - // Get the item to use from defs | |
| 2504 | - $insert = ''; | |
| 2505 | - if (preg_match('/<text [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>(.*?)<\/text>/si',$data, $m)) { | |
| 2506 | - $insert = $m[1]; | |
| 2507 | - } | |
| 2508 | - if ($insert) { | |
| 2509 | - $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $insert, $data); | |
| 2510 | - } | |
| 2511 | - } | |
| 2512 | - | |
| 2513 | - // mPDF 5.7.2 | |
| 2514 | - // <USE> | |
| 2515 | - preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',$data, $links); | |
| 2516 | - for ($i=0; $i<count($links[0]); $i++) { | |
| 2517 | - | |
| 2518 | - // Get the item to use from defs | |
| 2519 | - $insert = ''; | |
| 2520 | - if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) { | |
| 2521 | - $insert = $m[0]; | |
| 2522 | - } | |
| 2523 | - if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',$data, $m)) { | |
| 2524 | - | |
| 2525 | - if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) { | |
| 2526 | - $insert = $m[0]; | |
| 2527 | - } | |
| 2528 | - } | |
| 2529 | - | |
| 2530 | - if ($insert) { | |
| 2531 | - | |
| 2532 | - $inners = $links[1][$i] . ' ' . $links[3][$i]; | |
| 2533 | - // Change x,y coords to translate() | |
| 2534 | - if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; } | |
| 2535 | - else { $y = 0; } | |
| 2536 | - if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; } | |
| 2537 | - else { $x = 0; } | |
| 2538 | - if ($x || $y) { | |
| 2539 | - $inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners); | |
| 2540 | - if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { | |
| 2541 | - if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) { | |
| 2542 | - $transform = $m[1]; // transform="...." | |
| 2543 | - $x += $mm[1]; | |
| 2544 | - $y += $mm[2]; | |
| 2545 | - $transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform); | |
| 2546 | - $transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"'; | |
| 2547 | - $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners); | |
| 2548 | - } | |
| 2549 | - else { | |
| 2550 | - $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners); | |
| 2551 | - } | |
| 2552 | - } | |
| 2553 | - else { | |
| 2554 | - $inners .= ' transform="translate('.$x.', '.$y.')"'; | |
| 2555 | - } | |
| 2556 | - } | |
| 2557 | - } | |
| 2558 | - $replacement = '<g '.$inners.'>'.$insert.'</g>'; | |
| 2559 | - $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data); | |
| 2560 | - } | |
| 2561 | - preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)>\s*<\/use>/si',$data, $links); | |
| 2562 | - for ($i=0; $i<count($links[0]); $i++) { | |
| 2563 | - | |
| 2564 | - // Get the item to use from defs | |
| 2565 | - $insert = ''; | |
| 2566 | - if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) { | |
| 2567 | - $insert = $m[0]; | |
| 2568 | - } | |
| 2569 | - if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',$data, $m)) { | |
| 2570 | - | |
| 2571 | - if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) { | |
| 2572 | - $insert = $m[0]; | |
| 2573 | - } | |
| 2574 | - } | |
| 2575 | - | |
| 2576 | - if ($insert) { | |
| 2577 | - | |
| 2578 | - $inners = $links[1][$i] . ' ' . $links[3][$i]; | |
| 2579 | - // Change x,y coords to translate() | |
| 2580 | - if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; } | |
| 2581 | - else { $y = 0; } | |
| 2582 | - if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; } | |
| 2583 | - else { $x = 0; } | |
| 2584 | - if ($x || $y) { | |
| 2585 | - $inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners); | |
| 2586 | - if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { | |
| 2587 | - if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) { | |
| 2588 | - $transform = $m[1]; // transform="...." | |
| 2589 | - $x += $mm[1]; | |
| 2590 | - $y += $mm[2]; | |
| 2591 | - $transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform); | |
| 2592 | - $transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"'; | |
| 2593 | - $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners); | |
| 2594 | - } | |
| 2595 | - else { | |
| 2596 | - $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners); | |
| 2597 | - } | |
| 2598 | - } | |
| 2599 | - else { | |
| 2600 | - $inners .= ' transform="translate('.$x.', '.$y.')"'; | |
| 2601 | - } | |
| 2602 | - } | |
| 2603 | - $replacement = '<g '.$inners.'>'.$insert.'</g>'; | |
| 2604 | - $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data); | |
| 2605 | - | |
| 2606 | - | |
| 2607 | - } | |
| 2608 | - } | |
| 2609 | 2141 | } |
| 2610 | - | |
| 2611 | - // Removes <pattern> | |
| 2142 | + // mPDF 4.4.003 - Removes <pattern> | |
| 2612 | 2143 | $data = preg_replace('/<pattern.*?<\/pattern>/is', '', $data); |
| 2613 | - // Removes <marker> | |
| 2144 | + // mPDF 4.4.003 - Removes <marker> | |
| 2614 | 2145 | $data = preg_replace('/<marker.*?<\/marker>/is', '', $data); |
| 2615 | 2146 | |
| 2616 | 2147 | $this->svg_info['data'] = $data; |
| 2617 | 2148 | |
| @@ -2618,146 +2149,21 @@ | ||
| 2618 | 2149 | $this->svg_string = ''; |
| 2619 | 2150 | |
| 2620 | 2151 | // |
| 2621 | 2152 | // chargement unique des fonctions |
| 2622 | - if(!function_exists("xml_svg2pdf_start")){ | |
| 2153 | + if(!function_exists("xml_svg2pdf_start")){ // mPDF 5.3.76 | |
| 2623 | 2154 | |
| 2624 | 2155 | function xml_svg2pdf_start($parser, $name, $attribs){ |
| 2625 | 2156 | // |
| 2626 | 2157 | // definition |
| 2627 | - global $svg_class, $last_gradid, $last_svg_fontid, $last_svg_fontdefw, $last_svg_fontstyle; // mPDF 6 | |
| 2158 | + global $svg_class, $last_gradid; | |
| 2628 | 2159 | |
| 2629 | - // mPDF 6 | |
| 2630 | - if (strtolower($name) == 'font'){ | |
| 2631 | - $last_svg_fontid = ''; | |
| 2632 | - if (isset($attribs['horiz-adv-x']) && $attribs['horiz-adv-x']) { | |
| 2633 | - $last_svg_fontdefw = $attribs['horiz-adv-x']; | |
| 2634 | - } | |
| 2635 | - return; | |
| 2636 | - } | |
| 2637 | - // mPDF 6 | |
| 2638 | - else if (strtolower($name) == 'font-face'){ | |
| 2639 | - $last_svg_fontstyle = 'R'; | |
| 2640 | - $last_svg_fontstyle .= (isset($attribs['font-weight']) && $attribs['font-weight'] == 'bold')?'B':''; | |
| 2641 | - $last_svg_fontstyle .= (isset($attribs['font-style']) && $attribs['font-style'] == 'italic')?'I':''; | |
| 2642 | - $last_svg_fontstyle .= (isset($attribs['font-variant']) && $attribs['font-variant'] == 'small-caps')?'S':''; | |
| 2643 | - | |
| 2644 | - if (isset($attribs['font-family']) && $attribs['font-family']) { | |
| 2645 | - $tmp_svg_font = array( | |
| 2646 | - 'units-per-em' => (isset($attribs['units-per-em']) ? $attribs['units-per-em'] : ''), | |
| 2647 | - 'd' => '', | |
| 2648 | - 'glyphs' => array() | |
| 2649 | - ); | |
| 2650 | - $last_svg_fontid = strtolower($attribs['font-family']); | |
| 2651 | - if ($last_svg_fontdefw) { $tmp_svg_font['horiz-adv-x'] = $last_svg_fontdefw; } | |
| 2652 | - else { $tmp_svg_font['horiz-adv-x'] = 500; } | |
| 2653 | - $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle] = $tmp_svg_font; | |
| 2654 | - } | |
| 2655 | - return; | |
| 2656 | - } | |
| 2657 | - // mPDF 6 | |
| 2658 | - else if (strtolower($name) == 'missing-glyph'){ | |
| 2659 | - if ($last_svg_fontid && isset($attribs['horiz-adv-x'])) { | |
| 2660 | - $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['horiz-adv-x'] = (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : ''); | |
| 2661 | - $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['d'] = (isset($attribs['d']) ? $attribs['d'] : ''); | |
| 2662 | - } | |
| 2663 | - return; | |
| 2664 | - } | |
| 2665 | - // mPDF 6 | |
| 2666 | - else if (strtolower($name) == 'glyph'){ | |
| 2667 | - if ($last_svg_fontid && isset($attribs['unicode'])) { | |
| 2668 | - $svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['glyphs'][$attribs['unicode']] = array( | |
| 2669 | - 'horiz-adv-x' => (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : $last_svg_fontdefw), | |
| 2670 | - 'd' => (isset($attribs['d']) ? $attribs['d'] : ''), | |
| 2671 | - ); | |
| 2672 | - } | |
| 2673 | - return; | |
| 2674 | - } | |
| 2675 | - // mPDF 5.7.2 | |
| 2676 | - else if (strtolower($name) == 'lineargradient'){ | |
| 2677 | - $tmp_gradient = array( | |
| 2678 | - 'type' => 'linear', | |
| 2679 | - 'transform' => (isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : ''), | |
| 2680 | - 'units' => (isset($attribs['gradientUnits']) ? $attribs['gradientUnits'] : ''), | |
| 2681 | - 'spread' => (isset($attribs['spreadMethod']) ? $attribs['spreadMethod'] : ''), | |
| 2682 | - 'color' => array() | |
| 2683 | - ); | |
| 2684 | - if (isset($attribs['x1'])) $tmp_gradient['info']['x1'] = $attribs['x1'] ; | |
| 2685 | - if (isset($attribs['y1'])) $tmp_gradient['info']['y1'] = $attribs['y1'] ; | |
| 2686 | - if (isset($attribs['x2'])) $tmp_gradient['info']['x2'] = $attribs['x2'] ; | |
| 2687 | - if (isset($attribs['y2'])) $tmp_gradient['info']['y2'] = $attribs['y2'] ; | |
| 2688 | - $last_gradid = $attribs['id']; | |
| 2689 | - $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | |
| 2690 | - return; | |
| 2691 | - } | |
| 2692 | - else if (strtolower($name) == 'radialgradient'){ | |
| 2693 | - $tmp_gradient = array( | |
| 2694 | - 'type' => 'radial', | |
| 2695 | - 'transform' => (isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : ''), | |
| 2696 | - 'units' => (isset($attribs['gradientUnits']) ? $attribs['gradientUnits'] : ''), | |
| 2697 | - 'spread' => (isset($attribs['spreadMethod']) ? $attribs['spreadMethod'] : ''), | |
| 2698 | - 'color' => array() | |
| 2699 | - ); | |
| 2700 | - if (isset($attribs['cx'])) $tmp_gradient['info']['x0'] = $attribs['cx'] ; | |
| 2701 | - if (isset($attribs['cy'])) $tmp_gradient['info']['y0'] = $attribs['cy'] ; | |
| 2702 | - if (isset($attribs['fx'])) $tmp_gradient['info']['x1'] = $attribs['fx'] ; | |
| 2703 | - if (isset($attribs['fy'])) $tmp_gradient['info']['y1'] = $attribs['fy'] ; | |
| 2704 | - if (isset($attribs['r'])) $tmp_gradient['info']['r'] = $attribs['r'] ; | |
| 2705 | - $last_gradid = $attribs['id']; | |
| 2706 | - $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | |
| 2707 | - return; | |
| 2708 | - } | |
| 2709 | - else if (strtolower($name) == 'stop'){ | |
| 2710 | - if (!$last_gradid) break; | |
| 2711 | - $color = '#000000'; | |
| 2712 | - if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',$attribs['style'],$m)) { | |
| 2713 | - $color = trim($m[1]); | |
| 2714 | - } else if (isset($attribs['stop-color']) && $attribs['stop-color']) { | |
| 2715 | - $color = $attribs['stop-color']; | |
| 2716 | - } | |
| 2717 | - $col = $svg_class->mpdf_ref->ConvertColor($color); | |
| 2718 | - if (!$col) { $col = $svg_class->mpdf_ref->ConvertColor('#000000'); } // In case "transparent" or "inherit" returned | |
| 2719 | - if ($col{0}==3 || $col{0}==5) { // RGB | |
| 2720 | - $color_final = sprintf('%.3F %.3F %.3F',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255); | |
| 2721 | - $svg_class->svg_gradient[$last_gradid]['colorspace']='RGB'; | |
| 2722 | - } | |
| 2723 | - else if ($col{0}==4 || $col{0}==6) { // CMYK | |
| 2724 | - $color_final = sprintf('%.3F %.3F %.3F %.3F',ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100); | |
| 2725 | - $svg_class->svg_gradient[$last_gradid]['colorspace']='CMYK'; | |
| 2726 | - } | |
| 2727 | - else if ($col{0}==1) { // Grayscale | |
| 2728 | - $color_final = sprintf('%.3F',ord($col{1})/255); | |
| 2729 | - $svg_class->svg_gradient[$last_gradid]['colorspace']='Gray'; | |
| 2730 | - } | |
| 2731 | - | |
| 2732 | - $stop_opacity = 1; | |
| 2733 | - if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',$attribs['style'],$m)) { | |
| 2734 | - $stop_opacity = $m[1]; | |
| 2735 | - } else if (isset($attribs['stop-opacity'])) { | |
| 2736 | - $stop_opacity = $attribs['stop-opacity']; | |
| 2737 | - } | |
| 2738 | - else if ($col{0}==5) { // RGBa | |
| 2739 | - $stop_opacity = ord($col{4}/100); | |
| 2740 | - } | |
| 2741 | - else if ($col{0}==6) { // CMYKa | |
| 2742 | - $stop_opacity = ord($col{5}/100); | |
| 2743 | - } | |
| 2744 | - | |
| 2745 | - $tmp_color = array( | |
| 2746 | - 'color' => $color_final, | |
| 2747 | - 'offset' => (isset($attribs['offset']) ? $attribs['offset'] : ''), | |
| 2748 | - 'opacity' => $stop_opacity | |
| 2749 | - ); | |
| 2750 | - array_push($svg_class->svg_gradient[$last_gradid]['color'],$tmp_color); | |
| 2751 | - return; | |
| 2752 | - } | |
| 2753 | - if ($svg_class->inDefs) { return; } | |
| 2754 | - | |
| 2160 | + // mPDF 4.4.003 | |
| 2755 | 2161 | $svg_class->xbase = 0; |
| 2756 | 2162 | $svg_class->ybase = 0; |
| 2757 | 2163 | switch (strtolower($name)){ |
| 2758 | 2164 | |
| 2759 | - // Don't output stuff inside <defs> | |
| 2165 | + // mPDF 5.0.039 - Don't output stuff inside <defs> | |
| 2760 | 2166 | case 'defs': |
| 2761 | 2167 | $svg_class->inDefs = true; |
| 2762 | 2168 | return; |
| 2763 | 2169 | |
| @@ -2766,14 +2172,16 @@ | ||
| 2766 | 2172 | break; |
| 2767 | 2173 | |
| 2768 | 2174 | case 'path': |
| 2769 | 2175 | $path = $attribs['d']; |
| 2770 | - preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $path, $commands, PREG_SET_ORDER); | |
| 2176 | + // mPDF 4.4.003 | |
| 2177 | + preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([e ,\-.\d]+)*/', $path, $commands, PREG_SET_ORDER); | |
| 2771 | 2178 | $path_cmd = ''; |
| 2772 | - $svg_class->subPathInit = true; | |
| 2179 | + $svg_class->subPathInit = true; // mPDF 4.4.003 | |
| 2180 | + // mPDF 5.0.039 | |
| 2773 | 2181 | $svg_class->pathBBox = array(999999,999999,-999999,-999999); |
| 2774 | 2182 | foreach($commands as $c){ |
| 2775 | - if((isset($c) && count($c)==3) || (isset($c[2]) && $c[2]=='')){ | |
| 2183 | + if(count($c)==3 || $c[2]==''){ | |
| 2776 | 2184 | list($tmp, $command, $arguments) = $c; |
| 2777 | 2185 | } |
| 2778 | 2186 | else{ |
| 2779 | 2187 | list($tmp, $command) = $c; |
| @@ -2781,8 +2189,9 @@ | ||
| 2781 | 2189 | } |
| 2782 | 2190 | |
| 2783 | 2191 | $path_cmd .= $svg_class->svgPath($command, $arguments); |
| 2784 | 2192 | } |
| 2193 | + // mPDF 5.0.039 | |
| 2785 | 2194 | if ($svg_class->pathBBox[2]==-1999998) { $svg_class->pathBBox[2] = 100; } |
| 2786 | 2195 | if ($svg_class->pathBBox[3]==-1999998) { $svg_class->pathBBox[3] = 100; } |
| 2787 | 2196 | if ($svg_class->pathBBox[0]==999999) { $svg_class->pathBBox[0] = 0; } |
| 2788 | 2197 | if ($svg_class->pathBBox[1]==999999) { $svg_class->pathBBox[1] = 0; } |
| @@ -2795,15 +2204,16 @@ | ||
| 2795 | 2204 | if (!isset($attribs['x'])) {$attribs['x'] = 0;} |
| 2796 | 2205 | if (!isset($attribs['y'])) {$attribs['y'] = 0;} |
| 2797 | 2206 | if (!isset($attribs['rx'])) {$attribs['rx'] = 0;} |
| 2798 | 2207 | if (!isset($attribs['ry'])) {$attribs['ry'] = 0;} |
| 2799 | - $arguments = array(); | |
| 2800 | - if (isset($attribs['x'])) $arguments['x'] = $attribs['x']; | |
| 2801 | - if (isset($attribs['y'])) $arguments['y'] = $attribs['y']; | |
| 2802 | - if (isset($attribs['width'])) $arguments['w'] = $attribs['width']; | |
| 2803 | - if (isset($attribs['height'])) $arguments['h'] = $attribs['height']; | |
| 2804 | - if (isset($attribs['rx'])) $arguments['rx'] = $attribs['rx']; | |
| 2805 | - if (isset($attribs['ry'])) $arguments['ry'] = $attribs['ry']; | |
| 2208 | + $arguments = array( | |
| 2209 | + 'x' => $attribs['x'], | |
| 2210 | + 'y' => $attribs['y'], | |
| 2211 | + 'w' => $attribs['width'], | |
| 2212 | + 'h' => $attribs['height'], | |
| 2213 | + 'rx' => $attribs['rx'], | |
| 2214 | + 'ry' => $attribs['ry'] | |
| 2215 | + ); | |
| 2806 | 2216 | $path_cmd = $svg_class->svgRect($arguments); |
| 2807 | 2217 | $critere_style = $attribs; |
| 2808 | 2218 | unset($critere_style['x'],$critere_style['y'],$critere_style['rx'],$critere_style['ry'],$critere_style['height'],$critere_style['width']); |
| 2809 | 2219 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| @@ -2811,13 +2221,14 @@ | ||
| 2811 | 2221 | |
| 2812 | 2222 | case 'circle': |
| 2813 | 2223 | if (!isset($attribs['cx'])) {$attribs['cx'] = 0;} |
| 2814 | 2224 | if (!isset($attribs['cy'])) {$attribs['cy'] = 0;} |
| 2815 | - $arguments = array(); | |
| 2816 | - if (isset($attribs['cx'])) $arguments['cx'] = $attribs['cx']; | |
| 2817 | - if (isset($attribs['cy'])) $arguments['cy'] = $attribs['cy']; | |
| 2818 | - if (isset($attribs['r'])) $arguments['rx'] = $attribs['r']; | |
| 2819 | - if (isset($attribs['r'])) $arguments['ry'] = $attribs['r']; | |
| 2225 | + $arguments = array( | |
| 2226 | + 'cx' => $attribs['cx'], | |
| 2227 | + 'cy' => $attribs['cy'], | |
| 2228 | + 'rx' => $attribs['r'], | |
| 2229 | + 'ry' => $attribs['r'] | |
| 2230 | + ); | |
| 2820 | 2231 | $path_cmd = $svg_class->svgEllipse($arguments); |
| 2821 | 2232 | $critere_style = $attribs; |
| 2822 | 2233 | unset($critere_style['cx'],$critere_style['cy'],$critere_style['r']); |
| 2823 | 2234 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| @@ -2825,13 +2236,14 @@ | ||
| 2825 | 2236 | |
| 2826 | 2237 | case 'ellipse': |
| 2827 | 2238 | if (!isset($attribs['cx'])) {$attribs['cx'] = 0;} |
| 2828 | 2239 | if (!isset($attribs['cy'])) {$attribs['cy'] = 0;} |
| 2829 | - $arguments = array(); | |
| 2830 | - if (isset($attribs['cx'])) $arguments['cx'] = $attribs['cx']; | |
| 2831 | - if (isset($attribs['cy'])) $arguments['cy'] = $attribs['cy']; | |
| 2832 | - if (isset($attribs['rx'])) $arguments['rx'] = $attribs['rx']; | |
| 2833 | - if (isset($attribs['ry'])) $arguments['ry'] = $attribs['ry']; | |
| 2240 | + $arguments = array( | |
| 2241 | + 'cx' => $attribs['cx'], | |
| 2242 | + 'cy' => $attribs['cy'], | |
| 2243 | + 'rx' => $attribs['rx'], | |
| 2244 | + 'ry' => $attribs['ry'] | |
| 2245 | + ); | |
| 2834 | 2246 | $path_cmd = $svg_class->svgEllipse($arguments); |
| 2835 | 2247 | $critere_style = $attribs; |
| 2836 | 2248 | unset($critere_style['cx'],$critere_style['cy'],$critere_style['rx'],$critere_style['ry']); |
| 2837 | 2249 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| @@ -2837,14 +2249,10 @@ | ||
| 2837 | 2249 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| 2838 | 2250 | break; |
| 2839 | 2251 | |
| 2840 | 2252 | case 'line': |
| 2841 | - $arguments = array(); | |
| 2842 | - $arguments[0] = (isset($attribs['x1']) ? $attribs['x1'] : ''); | |
| 2843 | - $arguments[1] = (isset($attribs['y1']) ? $attribs['y1'] : ''); | |
| 2844 | - $arguments[2] = (isset($attribs['x2']) ? $attribs['x2'] : ''); | |
| 2845 | - $arguments[3] = (isset($attribs['y2']) ? $attribs['y2'] : ''); | |
| 2846 | - $path_cmd = $svg_class->svgPolyline($arguments,false); | |
| 2253 | + $arguments = array($attribs['x1'],$attribs['y1'],$attribs['x2'],$attribs['y2']); | |
| 2254 | + $path_cmd = $svg_class->svgPolyline($arguments,false); // mPDF 4.4.003 | |
| 2847 | 2255 | $critere_style = $attribs; |
| 2848 | 2256 | unset($critere_style['x1'],$critere_style['y1'],$critere_style['x2'],$critere_style['y2']); |
| 2849 | 2257 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| 2850 | 2258 | break; |
| @@ -2879,213 +2287,145 @@ | ||
| 2879 | 2287 | unset($critere_style['points']); |
| 2880 | 2288 | $path_style = $svg_class->svgDefineStyle($critere_style); |
| 2881 | 2289 | break; |
| 2882 | 2290 | |
| 2883 | - // mPDF 5.7.4 Embedded image | |
| 2884 | - case 'image': | |
| 2885 | - if (isset($attribs['xlink:href']) && $attribs['xlink:href']) { | |
| 2886 | - $svg_class->svgImage($attribs); | |
| 2887 | - } | |
| 2291 | + case 'lineargradient': | |
| 2292 | + $tmp_gradient = array( | |
| 2293 | + 'type' => 'linear', | |
| 2294 | + 'info' => array( | |
| 2295 | + 'x1' => $attribs['x1'], | |
| 2296 | + 'y1' => $attribs['y1'], | |
| 2297 | + 'x2' => $attribs['x2'], | |
| 2298 | + 'y2' => $attribs['y2'] | |
| 2299 | + ), | |
| 2300 | + 'transform' => $attribs['gradientTransform'], | |
| 2301 | + 'units' => $attribs['gradientUnits'], /* mPDF 4.4.003 */ | |
| 2302 | + 'spread' => $attribs['spreadMethod'], /* mPDF 5.0.040 */ | |
| 2303 | + 'color' => array() | |
| 2304 | + ); | |
| 2305 | + | |
| 2306 | + $last_gradid = $attribs['id']; | |
| 2307 | + $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | |
| 2888 | 2308 | break; |
| 2889 | 2309 | |
| 2310 | + case 'radialgradient': | |
| 2311 | + $tmp_gradient = array( | |
| 2312 | + 'type' => 'radial', | |
| 2313 | + 'info' => array( | |
| 2314 | + 'x0' => $attribs['cx'], | |
| 2315 | + 'y0' => $attribs['cy'], | |
| 2316 | + 'x1' => $attribs['fx'], | |
| 2317 | + 'y1' => $attribs['fy'], | |
| 2318 | + 'r' => $attribs['r'] | |
| 2319 | + ), | |
| 2320 | + 'transform' => $attribs['gradientTransform'], | |
| 2321 | + 'units' => $attribs['gradientUnits'], /* mPDF 4.4.003 */ | |
| 2322 | + 'spread' => $attribs['spreadMethod'], /* mPDF 5.0.040 */ | |
| 2323 | + 'color' => array() | |
| 2324 | + ); | |
| 2890 | 2325 | |
| 2891 | - case 'a': | |
| 2892 | - if (isset($attribs['xlink:href'])) { | |
| 2893 | - unset($attribs['xlink:href']); // this should be a hyperlink | |
| 2894 | - // not handled like a xlink:href in other elements | |
| 2895 | - } // then continue like a <g> | |
| 2896 | - case 'g': | |
| 2897 | - $array_style = $svg_class->svgDefineStyle($attribs); | |
| 2898 | - if (isset($array_style['transformations']) && $array_style['transformations']) { | |
| 2899 | - // If in the middle of <text> element, add to textoutput, else WriteString | |
| 2900 | - if ($svg_class->intext) { $svg_class->textoutput .= ' q '.$array_style['transformations']; } // mPDF 5.7.4 | |
| 2901 | - else { $svg_class->svgWriteString(' q '.$array_style['transformations']); } | |
| 2902 | - } | |
| 2903 | - array_push($svg_class->svg_style,$array_style); | |
| 2326 | + $last_gradid = $attribs['id']; | |
| 2904 | 2327 | |
| 2905 | - $svg_class->svgDefineTxtStyle($attribs); | |
| 2328 | + $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | |
| 2906 | 2329 | |
| 2907 | 2330 | break; |
| 2908 | 2331 | |
| 2909 | - case 'text': | |
| 2910 | - $svg_class->textlength = 0; // mPDF 5.7.4 | |
| 2911 | - $svg_class->texttotallength = 0; // mPDF 5.7.4 | |
| 2912 | - $svg_class->textoutput = ''; // mPDF 5.7.4 | |
| 2913 | - $svg_class->textanchor = 'start'; // mPDF 5.7.4 | |
| 2914 | - $svg_class->textXorigin = 0; // mPDF 5.7.4 | |
| 2915 | - $svg_class->textYorigin = 0; // mPDF 5.7.4 | |
| 2916 | - | |
| 2917 | - $svg_class->intext = true; // mPDF 5.7.4 | |
| 2918 | - | |
| 2919 | - $styl = ''; | |
| 2920 | - if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) { | |
| 2921 | - $classes = preg_split('/\s+/',trim($attribs['class'])); | |
| 2922 | - foreach($classes AS $class) { | |
| 2923 | - if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)])) { | |
| 2924 | - $c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)]; | |
| 2925 | - foreach($c AS $prop=>$val) { | |
| 2926 | - $styl .= strtolower($prop).':'.$val.';'; | |
| 2927 | - } | |
| 2928 | - } | |
| 2929 | - } | |
| 2332 | + case 'stop': | |
| 2333 | + if (!$last_gradid) break; | |
| 2334 | + // mPDF 4.4.003 // mPDF 5.0.040 | |
| 2335 | + if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',$attribs['style'],$m)) { | |
| 2336 | + $color = trim($m[1]); | |
| 2337 | + } else if (isset($attribs['stop-color'])) { | |
| 2338 | + $color = $attribs['stop-color']; | |
| 2930 | 2339 | } |
| 2340 | + $col = $svg_class->mpdf_ref->ConvertColor($color); | |
| 2931 | 2341 | |
| 2932 | - if (_SVG_AUTOFONT && isset($attribs['lang']) && $attribs['lang']) { | |
| 2933 | - if (!$svg_class->mpdf_ref->usingCoreFont) { | |
| 2934 | - if ($attribs['lang'] != $svg_class->mpdf_ref->default_lang) { | |
| 2935 | - list ($coreSuitable,$mpdf_unifont) = GetLangOpts($attribs['lang'], $svg_class->mpdf_ref->useAdobeCJK, $svg_class->mpdf_ref->fontdata); | |
| 2936 | - if ($mpdf_unifont) { $styl .= 'font-family:'.$mpdf_unifont.';'; } | |
| 2937 | - } | |
| 2938 | - } | |
| 2342 | + // mPDF 5.0.051 | |
| 2343 | + // mPDF 5.3.74 | |
| 2344 | + if ($col{0}==3 || $col{0}==5) { // RGB | |
| 2345 | + $color_final = sprintf('%.3F %.3F %.3F',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255); | |
| 2346 | + $svg_class->svg_gradient[$last_gradid]['colorspace']='RGB'; | |
| 2939 | 2347 | } |
| 2940 | - | |
| 2941 | - if ($styl) { | |
| 2942 | - if (isset($attribs['style'])) { $attribs['style'] = $styl . $attribs['style']; } | |
| 2943 | - else { $attribs['style'] = $styl; } | |
| 2348 | + else if ($col{0}==4 || $col{0}==6) { // CMYK | |
| 2349 | + $color_final = sprintf('%.3F %.3F %.3F %.3F',ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100); | |
| 2350 | + $svg_class->svg_gradient[$last_gradid]['colorspace']='CMYK'; | |
| 2944 | 2351 | } |
| 2945 | - | |
| 2946 | - $array_style = $svg_class->svgDefineStyle($attribs); | |
| 2947 | - if ($array_style['transformations']) { | |
| 2948 | - $svg_class->textoutput .= ' q '.$array_style['transformations']; // mPDF 5.7.4 | |
| 2352 | + else if ($col{0}==1) { // Grayscale | |
| 2353 | + $color_final = sprintf('%.3F',ord($col{1})/255); | |
| 2354 | + $svg_class->svg_gradient[$last_gradid]['colorspace']='Gray'; | |
| 2949 | 2355 | } |
| 2950 | - array_push($svg_class->svg_style,$array_style); | |
| 2951 | 2356 | |
| 2952 | - $svg_class->txt_data = array(); | |
| 2953 | - $x = isset($attribs['x']) ? $svg_class->ConvertSVGSizePixels($attribs['x'],'x') : 0; // mPDF 5.7.4 | |
| 2954 | - $y = isset($attribs['y']) ? $svg_class->ConvertSVGSizePixels($attribs['y'],'y') : 0; // mPDF 5.7.4 | |
| 2955 | - $x += isset($attribs['dx']) ? $svg_class->ConvertSVGSizePixels($attribs['dx'],'x') : 0; // mPDF 5.7.4 | |
| 2956 | - $y += isset($attribs['dy']) ? $svg_class->ConvertSVGSizePixels($attribs['dy'],'y') : 0; // mPDF 5.7.4 | |
| 2957 | 2357 | |
| 2958 | - $svg_class->txt_data[0] = $x; // mPDF 5.7.4 | |
| 2959 | - $svg_class->txt_data[1] = $y; // mPDF 5.7.4 | |
| 2960 | - $critere_style = $attribs; | |
| 2961 | - unset($critere_style['x'], $critere_style['y']); | |
| 2962 | - $svg_class->svgDefineTxtStyle($critere_style); | |
| 2358 | + // mPDF 5.0.020 | |
| 2359 | + $stop_opacity = 1; | |
| 2360 | + // mPDF 4.4.003 | |
| 2361 | + if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',$attribs['style'],$m)) { | |
| 2362 | + $stop_opacity = $m[1]; | |
| 2363 | + } else if (isset($attribs['stop-opacity'])) { | |
| 2364 | + $stop_opacity = $attribs['stop-opacity']; | |
| 2365 | + } | |
| 2366 | + // mPDF 5.0.051 | |
| 2367 | + // mPDF 5.3.74 | |
| 2368 | + else if ($col{0}==5) { // RGBa | |
| 2369 | + $stop_opacity = ord($col{4}/100); | |
| 2370 | + } | |
| 2371 | + else if ($col{0}==6) { // CMYKa | |
| 2372 | + $stop_opacity = ord($col{5}/100); | |
| 2373 | + } | |
| 2963 | 2374 | |
| 2964 | - $svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style)-1]['text-anchor']; // mPDF 5.7.4 | |
| 2965 | - $svg_class->textXorigin = $svg_class->txt_data[0]; // mPDF 5.7.4 | |
| 2966 | - $svg_class->textYorigin = $svg_class->txt_data[1]; // mPDF 5.7.4 | |
| 2967 | - $svg_class->textjuststarted = true; // mPDF 5.7.4 | |
| 2968 | - | |
| 2375 | + $tmp_color = array( | |
| 2376 | + 'color' => $color_final, | |
| 2377 | + 'offset' => $attribs['offset'], | |
| 2378 | + 'opacity' => $stop_opacity | |
| 2379 | + ); | |
| 2380 | + array_push($svg_class->svg_gradient[$last_gradid]['color'],$tmp_color); | |
| 2969 | 2381 | break; |
| 2970 | 2382 | |
| 2971 | - // mPDF 5.7.4 | |
| 2972 | - case 'tspan': | |
| 2973 | 2383 | |
| 2974 | - // OUTPUT CHUNK(s) UP To NOW (svgText updates $svg_class->textlength) | |
| 2975 | - $p_cmd = $svg_class->svgText(); | |
| 2976 | - $svg_class->textoutput .= $p_cmd; | |
| 2977 | - $tmp = count($svg_class->svg_style)-1; | |
| 2978 | - $current_style = $svg_class->svg_style[$tmp]; | |
| 2979 | - | |
| 2980 | - $styl = ''; | |
| 2981 | - if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) { | |
| 2982 | - $classes = preg_split('/\s+/',trim($attribs['class'])); | |
| 2983 | - foreach($classes AS $class) { | |
| 2984 | - if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)])) { | |
| 2985 | - $c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)]; | |
| 2986 | - foreach($c AS $prop=>$val) { | |
| 2987 | - $styl .= strtolower($prop).':'.$val.';'; | |
| 2988 | - } | |
| 2989 | - } | |
| 2384 | + case 'a': | |
| 2385 | + if (isset($attribs['xlink:href'])) { | |
| 2386 | + unset($attribs['xlink:href']); // this should be a hyperlink | |
| 2387 | + // not handled like a xlink:href in other elements | |
| 2388 | + } // then continue like a <g> | |
| 2389 | + case 'g': | |
| 2390 | + $array_style = $svg_class->svgDefineStyle($attribs); | |
| 2391 | + if ($array_style['transformations']) { | |
| 2392 | + $svg_class->svgWriteString(' q '.$array_style['transformations']); | |
| 2990 | 2393 | } |
| 2991 | - } | |
| 2394 | + array_push($svg_class->svg_style,$array_style); | |
| 2992 | 2395 | |
| 2993 | - if (_SVG_AUTOFONT && isset($attribs['lang']) && $attribs['lang']) { | |
| 2994 | - if (!$svg_class->mpdf_ref->usingCoreFont) { | |
| 2995 | - if ($attribs['lang'] != $svg_class->mpdf_ref->default_lang) { | |
| 2996 | - list ($coreSuitable,$mpdf_unifont) = GetLangOpts($attribs['lang'], $svg_class->mpdf_ref->useAdobeCJK, $svg_class->mpdf_ref->fontdata); | |
| 2997 | - if ($mpdf_unifont) { $styl .= 'font-family:'.$mpdf_unifont.';'; } | |
| 2998 | - } | |
| 2999 | - } | |
| 3000 | - } | |
| 2396 | + $svg_class->svgDefineTxtStyle($attribs); // mPDF 4.4.003 | |
| 3001 | 2397 | |
| 3002 | - if ($styl) { | |
| 3003 | - if (isset($attribs['style'])) { $attribs['style'] = $styl . $attribs['style']; } | |
| 3004 | - else { $attribs['style'] = $styl; } | |
| 3005 | - } | |
| 2398 | + break; | |
| 3006 | 2399 | |
| 3007 | - $array_style = $svg_class->svgDefineStyle($attribs); | |
| 3008 | - | |
| 3009 | - $svg_class->txt_data = array(); | |
| 3010 | - | |
| 3011 | - | |
| 3012 | - // If absolute position adjustment (x or y), creates new block of text for text-alignment | |
| 3013 | - if (isset($attribs['x']) || isset($attribs['y'])) { | |
| 3014 | - // If text-anchor middle|end, adjust | |
| 3015 | - if ($svg_class->textanchor == 'end') { $tx = -$svg_class->texttotallength; } | |
| 3016 | - else if ($svg_class->textanchor == 'middle') { $tx = -$svg_class->texttotallength/2; } | |
| 3017 | - else { $tx = 0; } | |
| 3018 | - while(preg_match('/mPDF-AXS\((.*?)\)/',$svg_class->textoutput,$m)) { | |
| 3019 | - if ($tx) { | |
| 3020 | - $txk = $m[1] + ($tx*$svg_class->kp); | |
| 3021 | - $svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk) ,$svg_class->textoutput,1); | |
| 3022 | - } | |
| 3023 | - else { | |
| 3024 | - $svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',$svg_class->textoutput,1); | |
| 3025 | - } | |
| 2400 | + case 'text': | |
| 2401 | + // mPDF 4.4.003 | |
| 2402 | + $array_style = $svg_class->svgDefineStyle($attribs); | |
| 2403 | + if ($array_style['transformations']) { | |
| 2404 | + $svg_class->svgWriteString(' q '.$array_style['transformations']); | |
| 3026 | 2405 | } |
| 2406 | + array_push($svg_class->svg_style,$array_style); | |
| 3027 | 2407 | |
| 3028 | - $svg_class->svgWriteString($svg_class->textoutput); | |
| 3029 | - | |
| 3030 | - $svg_class->textXorigin += $svg_class->textlength; | |
| 3031 | - $currentX = $svg_class->textXorigin; | |
| 3032 | - $currentY = $svg_class->textYorigin; | |
| 3033 | - $svg_class->textlength = 0; | |
| 3034 | - $svg_class->texttotallength = 0; | |
| 3035 | - $svg_class->textoutput = ''; | |
| 3036 | - | |
| 3037 | - $x = isset($attribs['x']) ? $svg_class->ConvertSVGSizePixels($attribs['x'],'x') : $currentX; | |
| 3038 | - $y = isset($attribs['y']) ? $svg_class->ConvertSVGSizePixels($attribs['y'],'y') : $currentY; | |
| 3039 | - | |
| 3040 | - $svg_class->txt_data[0] = $x; | |
| 3041 | - $svg_class->txt_data[1] = $y; | |
| 2408 | + $svg_class->txt_data = array(); | |
| 2409 | + $svg_class->txt_data[0] = $attribs['x']; | |
| 2410 | + $svg_class->txt_data[1] = $attribs['y']; | |
| 3042 | 2411 | $critere_style = $attribs; |
| 3043 | 2412 | unset($critere_style['x'], $critere_style['y']); |
| 3044 | 2413 | $svg_class->svgDefineTxtStyle($critere_style); |
| 3045 | 2414 | |
| 3046 | - $svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style)-1]['text-anchor']; | |
| 3047 | - $svg_class->textXorigin = $x; | |
| 3048 | - $svg_class->textYorigin = $y; | |
| 3049 | - | |
| 3050 | - } | |
| 3051 | - else { | |
| 3052 | - | |
| 3053 | - $svg_class->textXorigin += $svg_class->textlength; | |
| 3054 | - $currentX = $svg_class->textXorigin; | |
| 3055 | - $currentY = $svg_class->textYorigin; | |
| 3056 | - | |
| 3057 | - $currentX += isset($attribs['dx']) ? $svg_class->ConvertSVGSizePixels($attribs['dx'],'x') : 0; | |
| 3058 | - $currentY += isset($attribs['dy']) ? $svg_class->ConvertSVGSizePixels($attribs['dy'],'y') : 0; | |
| 3059 | - | |
| 3060 | - $svg_class->txt_data[0] = $currentX; | |
| 3061 | - $svg_class->txt_data[1] = $currentY; | |
| 3062 | - $critere_style = $attribs; | |
| 3063 | - unset($critere_style['x'], $critere_style['y']); | |
| 3064 | - $svg_class->svgDefineTxtStyle($critere_style); | |
| 3065 | - $svg_class->textXorigin = $currentX; | |
| 3066 | - $svg_class->textYorigin = $currentY; | |
| 3067 | - | |
| 3068 | - } | |
| 3069 | - | |
| 3070 | - if ($array_style['transformations']) { | |
| 3071 | - $svg_class->textoutput .= ' q '.$array_style['transformations']; | |
| 3072 | - } | |
| 3073 | - array_push($svg_class->svg_style,$array_style); | |
| 3074 | - | |
| 3075 | 2415 | break; |
| 3076 | 2416 | } |
| 3077 | 2417 | |
| 3078 | 2418 | // |
| 3079 | 2419 | //insertion des path et du style dans le flux de donn� general. |
| 3080 | - if (isset($path_cmd) && $path_cmd) { | |
| 2420 | + if (isset($path_cmd) && $path_cmd) { // mPDF 4.4.003 | |
| 3081 | 2421 | // mPDF 5.0 |
| 3082 | 2422 | list($prestyle,$poststyle) = $svg_class->svgStyle($path_style, $attribs, strtolower($name)); |
| 3083 | - if (isset($path_style['transformations']) && $path_style['transformations']) { // transformation on an element | |
| 3084 | - $svg_class->svgWriteString(" q ".$path_style['transformations']. $prestyle . $path_cmd . $poststyle . " Q\n"); | |
| 2423 | + if ($path_style['transformations']) { // transformation on an element | |
| 2424 | + $svg_class->svgWriteString(" q ".$path_style['transformations']. " $prestyle $path_cmd $poststyle" . " Q\n"); | |
| 3085 | 2425 | } |
| 3086 | 2426 | else { |
| 3087 | - $svg_class->svgWriteString(" q ".$prestyle . $path_cmd . $poststyle ." Q\n"); // mPDF 5.7.4 | |
| 2427 | + $svg_class->svgWriteString("$prestyle $path_cmd $poststyle\n"); | |
| 3088 | 2428 | } |
| 3089 | 2429 | } |
| 3090 | 2430 | } |
| 3091 | 2431 | |
| @@ -3091,114 +2431,56 @@ | ||
| 3091 | 2431 | |
| 3092 | 2432 | function characterData($parser, $data) |
| 3093 | 2433 | { |
| 3094 | 2434 | global $svg_class; |
| 3095 | - if ($svg_class->inDefs) { return; } // mPDF 5.7.2 | |
| 3096 | 2435 | if(isset($svg_class->txt_data[2])) { |
| 3097 | 2436 | $svg_class->txt_data[2] .= $data; |
| 3098 | 2437 | } |
| 3099 | 2438 | else { |
| 3100 | 2439 | $svg_class->txt_data[2] = $data; |
| 3101 | - $svg_class->txt_data[0] = $svg_class->textXorigin ; | |
| 3102 | - $svg_class->txt_data[1] = $svg_class->textYorigin ; } | |
| 2440 | + } | |
| 3103 | 2441 | } |
| 3104 | 2442 | |
| 3105 | 2443 | |
| 3106 | 2444 | function xml_svg2pdf_end($parser, $name){ |
| 3107 | 2445 | global $svg_class; |
| 3108 | - // mPDF 5.7.2 | |
| 3109 | - // Don't output stuff inside <defs> | |
| 3110 | - if ($name == 'defs') { | |
| 3111 | - $svg_class->inDefs = false; | |
| 3112 | - return; | |
| 3113 | - } | |
| 3114 | - if ($svg_class->inDefs) { return; } | |
| 3115 | 2446 | switch($name){ |
| 3116 | 2447 | |
| 3117 | 2448 | case "g": |
| 3118 | 2449 | case "a": |
| 3119 | - if ($svg_class->intext) { | |
| 3120 | - $p_cmd = $svg_class->svgText(); | |
| 3121 | - $svg_class->textoutput .= $p_cmd; | |
| 3122 | - } | |
| 3123 | - | |
| 3124 | 2450 | $tmp = count($svg_class->svg_style)-1; |
| 3125 | 2451 | $current_style = $svg_class->svg_style[$tmp]; |
| 3126 | 2452 | if ($current_style['transformations']) { |
| 3127 | - // If in the middle of <text> element, add to textoutput, else WriteString | |
| 3128 | - if ($svg_class->intext) { $svg_class->textoutput .= " Q\n"; } // mPDF 5.7.4 | |
| 3129 | - else { $svg_class->svgWriteString(" Q\n"); } | |
| 2453 | + $svg_class->svgWriteString(" Q\n"); | |
| 3130 | 2454 | } |
| 3131 | 2455 | array_pop($svg_class->svg_style); |
| 3132 | - array_pop($svg_class->txt_style); | |
| 3133 | - if ($svg_class->intext) { | |
| 3134 | - $svg_class->textXorigin += $svg_class->textlength; | |
| 3135 | - $svg_class->textlength = 0; | |
| 3136 | - } | |
| 3137 | 2456 | |
| 2457 | + array_pop($svg_class->txt_style); // mPDF 4.4.003 | |
| 2458 | + | |
| 3138 | 2459 | break; |
| 3139 | - case 'font': | |
| 3140 | - $last_svg_fontdefw = ''; | |
| 3141 | - break; | |
| 3142 | - case 'font-face': | |
| 3143 | - $last_svg_fontid = ''; | |
| 3144 | - $last_svg_fontstyle = ''; | |
| 3145 | - break; | |
| 3146 | 2460 | case 'radialgradient': |
| 3147 | 2461 | case 'lineargradient': |
| 3148 | 2462 | $last_gradid = ''; |
| 3149 | 2463 | break; |
| 3150 | 2464 | case "text": |
| 3151 | - $svg_class->txt_data[2] = rtrim($svg_class->txt_data[2]); // mPDF 5.7.4 | |
| 3152 | 2465 | $path_cmd = $svg_class->svgText(); |
| 3153 | - $svg_class->textoutput .= $path_cmd; // mPDF 5.7.4 | |
| 2466 | + // echo 'path >> '.$path_cmd."<br><br>"; | |
| 2467 | + // echo "style >> ".$get_style[1]."<br><br>"; | |
| 2468 | + $svg_class->svgWriteString($path_cmd); | |
| 2469 | + // mPDF 4.4.003 | |
| 3154 | 2470 | $tmp = count($svg_class->svg_style)-1; |
| 3155 | 2471 | $current_style = $svg_class->svg_style[$tmp]; |
| 3156 | 2472 | if ($current_style['transformations']) { |
| 3157 | - $svg_class->textoutput .= " Q\n"; // mPDF 5.7.4 | |
| 2473 | + $svg_class->svgWriteString(" Q\n"); | |
| 3158 | 2474 | } |
| 3159 | 2475 | array_pop($svg_class->svg_style); |
| 3160 | - array_pop($svg_class->txt_style); // mPDF 5.7.4 | |
| 3161 | 2476 | |
| 3162 | - // mPDF 5.7.4 | |
| 3163 | - // If text-anchor middle|end, adjust | |
| 3164 | - if ($svg_class->textanchor == 'end') { $tx = -$svg_class->texttotallength; } | |
| 3165 | - else if ($svg_class->textanchor == 'middle') { $tx = -$svg_class->texttotallength/2; } | |
| 3166 | - else { $tx = 0; } | |
| 3167 | - while(preg_match('/mPDF-AXS\((.*?)\)/',$svg_class->textoutput,$m)) { | |
| 3168 | - if ($tx) { | |
| 3169 | - $txk = $m[1] + ($tx*$svg_class->kp); | |
| 3170 | - $svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk) ,$svg_class->textoutput,1); | |
| 3171 | - } | |
| 3172 | - else { | |
| 3173 | - $svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',$svg_class->textoutput,1); | |
| 3174 | - } | |
| 3175 | - } | |
| 3176 | - | |
| 3177 | - $svg_class->svgWriteString($svg_class->textoutput); | |
| 3178 | - $svg_class->textlength = 0; | |
| 3179 | - $svg_class->texttotallength = 0; | |
| 3180 | - $svg_class->textoutput = ''; | |
| 3181 | - $svg_class->intext = false; // mPDF 5.7.4 | |
| 3182 | - | |
| 3183 | 2477 | break; |
| 3184 | - // mPDF 5.7.4 | |
| 3185 | - case "tspan": | |
| 3186 | - $p_cmd = $svg_class->svgText(); | |
| 3187 | - $svg_class->textoutput .= $p_cmd; | |
| 3188 | - $tmp = count($svg_class->svg_style)-1; | |
| 3189 | - $current_style = $svg_class->svg_style[$tmp]; | |
| 3190 | - if ($current_style['transformations']) { | |
| 3191 | - $svg_class->textoutput .= " Q\n"; | |
| 3192 | - } | |
| 3193 | - array_pop($svg_class->svg_style); | |
| 3194 | - array_pop($svg_class->txt_style); | |
| 3195 | - | |
| 3196 | - $svg_class->textXorigin += $svg_class->textlength; | |
| 3197 | - $svg_class->textlength = 0; | |
| 3198 | - | |
| 3199 | - break; | |
| 3200 | 2478 | } |
| 2479 | + // mPDF 5.0.039 - Don't output stuff inside <defs> | |
| 2480 | + if ($name == 'defs') { | |
| 2481 | + $svg_class->inDefs = false; | |
| 2482 | + } | |
| 3201 | 2483 | |
| 3202 | 2484 | } |
| 3203 | 2485 | |
| 3204 | 2486 | } |
| @@ -3205,9 +2487,9 @@ | ||
| 3205 | 2487 | |
| 3206 | 2488 | $svg2pdf_xml=''; |
| 3207 | 2489 | global $svg_class; |
| 3208 | 2490 | $svg_class = $this; |
| 3209 | - // Don't output stuff inside <defs> | |
| 2491 | + // mPDF 5.0.039 - Don't output stuff inside <defs> | |
| 3210 | 2492 | $svg_class->inDefs = false; |
| 3211 | 2493 | $svg2pdf_xml_parser = xml_parser_create("utf-8"); |
| 3212 | 2494 | xml_parser_set_option($svg2pdf_xml_parser, XML_OPTION_CASE_FOLDING, false); |
| 3213 | 2495 | xml_set_element_handler($svg2pdf_xml_parser, "xml_svg2pdf_start", "xml_svg2pdf_end"); |
| @@ -3212,8 +2494,9 @@ | ||
| 3212 | 2494 | xml_parser_set_option($svg2pdf_xml_parser, XML_OPTION_CASE_FOLDING, false); |
| 3213 | 2495 | xml_set_element_handler($svg2pdf_xml_parser, "xml_svg2pdf_start", "xml_svg2pdf_end"); |
| 3214 | 2496 | xml_set_character_data_handler($svg2pdf_xml_parser, "characterData"); |
| 3215 | 2497 | xml_parse($svg2pdf_xml_parser, $data); |
| 2498 | + // mPDF 4.4.003 | |
| 3216 | 2499 | if ($this->svg_error) { return false; } |
| 3217 | 2500 | else { |
| 3218 | 2501 | return array('x'=>$this->svg_info['x']*$this->kp,'y'=>-$this->svg_info['y']*$this->kp,'w'=>$this->svg_info['w']*$this->kp,'h'=>-$this->svg_info['h']*$this->kp,'data'=>$svg_class->svg_string); |
| 3219 | 2502 | } |
| @@ -3219,144 +2502,14 @@ | ||
| 3219 | 2502 | } |
| 3220 | 2503 | |
| 3221 | 2504 | } |
| 3222 | 2505 | |
| 3223 | - | |
| 3224 | - | |
| 3225 | -// AUTOFONT ========================= | |
| 3226 | -function markScriptToLang($html) { | |
| 3227 | - if ($this->mpdf_ref->onlyCoreFonts) { return $html; } | |
| 3228 | - if (empty($this->script2lang)) { | |
| 3229 | - if (!empty($this->mpdf_ref->script2lang)) { | |
| 3230 | - $this->script2lang = $this->mpdf_ref->script2lang; | |
| 3231 | - $this->viet = $this->mpdf_ref->viet; | |
| 3232 | - $this->pashto = $this->mpdf_ref->pashto; | |
| 3233 | - $this->urdu = $this->mpdf_ref->urdu; | |
| 3234 | - $this->persian = $this->mpdf_ref->persian; | |
| 3235 | - $this->sindhi = $this->mpdf_ref->sindhi; | |
| 3236 | - } | |
| 3237 | - else { | |
| 3238 | - include(_MPDF_PATH.'config_script2lang.php'); | |
| 3239 | - } | |
| 3240 | - } | |
| 3241 | - | |
| 3242 | - $n = ''; | |
| 3243 | - $a=preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE); | |
| 3244 | - foreach($a as $i => $e) { | |
| 3245 | - if($i%2==0) { | |
| 3246 | - $e = strcode2utf($e); | |
| 3247 | - $e = $this->mpdf_ref->lesser_entity_decode($e); | |
| 3248 | - | |
| 3249 | - $earr = $this->mpdf_ref->UTF8StringToArray($e, false); | |
| 3250 | - | |
| 3251 | - $scriptblock = 0; | |
| 3252 | - $scriptblocks = array(); | |
| 3253 | - $scriptblocks[0] = 0; | |
| 3254 | - $chardata = array(); | |
| 3255 | - $subchunk = 0; | |
| 3256 | - $charctr = 0; | |
| 3257 | - foreach($earr as $char) { | |
| 3258 | - $ucd_record = UCDN::get_ucd_record($char); | |
| 3259 | - $sbl = $ucd_record[6]; | |
| 3260 | - | |
| 3261 | - if ($sbl && $sbl != 40 && $sbl != 102) { | |
| 3262 | - if ($scriptblock == 0) { $scriptblock = $sbl; $scriptblocks[$subchunk] = $scriptblock; } | |
| 3263 | - else if ($scriptblock > 0 && $scriptblock != $sbl) { | |
| 3264 | - // NEW (non-common) Script encountered in this chunk. | |
| 3265 | - // Start a new subchunk | |
| 3266 | - $subchunk++; | |
| 3267 | - $scriptblock = $sbl; | |
| 3268 | - $charctr = 0; | |
| 3269 | - $scriptblocks[$subchunk] = $scriptblock; | |
| 3270 | - } | |
| 3271 | - } | |
| 3272 | - | |
| 3273 | - $chardata[$subchunk][$charctr]['script'] = $sbl; | |
| 3274 | - $chardata[$subchunk][$charctr]['uni'] = $char; | |
| 3275 | - $charctr++; | |
| 3276 | - } | |
| 3277 | - | |
| 3278 | - // If scriptblock[x] = common & non-baseScript | |
| 3279 | - // and scriptblock[x+1] = baseScript | |
| 3280 | - // Move common script from end of x to start of x+1 | |
| 3281 | - for($sch=0;$sch<$subchunk;$sch++) { | |
| 3282 | - if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf_ref->baseScript && $scriptblocks[$sch+1] == $this->mpdf_ref->baseScript) { | |
| 3283 | - $end = count($chardata[$sch])-1; | |
| 3284 | - while($chardata[$sch][$end]['script'] == 0 && $end > 1) { // common script | |
| 3285 | - $tmp = array_pop($chardata[$sch]); | |
| 3286 | - array_unshift($chardata[$sch+1],$tmp); | |
| 3287 | - $end--; | |
| 3288 | - } | |
| 3289 | - } | |
| 3290 | - } | |
| 3291 | - | |
| 3292 | - $o = ''; | |
| 3293 | - for($sch=0;$sch<=$subchunk;$sch++) { | |
| 3294 | - if (isset($chardata[$sch])) { | |
| 3295 | - $s = ''; | |
| 3296 | - for ($j=0;$j<count($chardata[$sch]);$j++) { | |
| 3297 | - $s.=code2utf($chardata[$sch][$j]['uni']); | |
| 3298 | - } | |
| 3299 | - // ZZZ99 Undo lesser_entity_decode as above - but only for <>& | |
| 3300 | - $s = str_replace("&","&",$s); | |
| 3301 | - $s = str_replace("<","<",$s); | |
| 3302 | - $s = str_replace(">",">",$s); | |
| 3303 | - | |
| 3304 | - if (substr($a[$i-1],0,5)!='<text' && substr($a[$i-1],0,5)!='<tspa') { continue; } // <tspan> or <text> only | |
| 3305 | - | |
| 3306 | - $lang = ''; | |
| 3307 | - // Check Vietnamese if Latin script - even if Basescript | |
| 3308 | - if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->mpdf_ref->autoVietnamese && preg_match("/([".$this->viet."])/u", $s)) { | |
| 3309 | - $lang="vi"; | |
| 3310 | - } | |
| 3311 | - // Check Arabic for different languages if Arabic script - even if Basescript | |
| 3312 | - else if ($scriptblocks[$sch] == UCDN::SCRIPT_ARABIC && $this->mpdf_ref->autoArabic) { | |
| 3313 | - if (preg_match("/[".$this->sindhi ."]/u", $s) ) { | |
| 3314 | - $lang="sd"; | |
| 3315 | - } | |
| 3316 | - else if (preg_match("/[".$this->urdu ."]/u", $s) ) { | |
| 3317 | - $lang="ur"; | |
| 3318 | - } | |
| 3319 | - else if (preg_match("/[".$this->pashto ."]/u", $s) ) { | |
| 3320 | - $lang="ps"; | |
| 3321 | - } | |
| 3322 | - else if (preg_match("/[".$this->persian ."]/u", $s) ) { | |
| 3323 | - $lang="fa"; | |
| 3324 | - } | |
| 3325 | - else if ($this->mpdf_ref->baseScript != UCDN::SCRIPT_ARABIC && isset($this->script2lang[$scriptblocks[$sch]])) { | |
| 3326 | - $lang="'.$this->script2lang[$scriptblocks[$sch]].'"; | |
| 3327 | - } | |
| 3328 | - } | |
| 3329 | - // Identify Script block if not Basescript, and mark up as language | |
| 3330 | - else if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf_ref->baseScript && isset($this->script2lang[$scriptblocks[$sch]])) { | |
| 3331 | - $lang=$this->script2lang[$scriptblocks[$sch]]; | |
| 3332 | - } | |
| 3333 | - if ($lang) { | |
| 3334 | - $o .= '<tspan lang="'.$lang.'">'.$s.'</tspan>'; | |
| 3335 | - } | |
| 3336 | - else { $o .= $s; } | |
| 3337 | - | |
| 3338 | - } | |
| 3339 | - } | |
| 3340 | - | |
| 3341 | - $a[$i] = $o; | |
| 3342 | - } | |
| 3343 | - else { | |
| 3344 | - $a[$i] = '<'.$e.'>'; | |
| 3345 | - } | |
| 3346 | - } | |
| 3347 | - $n = implode('',$a); | |
| 3348 | - return $n; | |
| 3349 | 2506 | } |
| 3350 | 2507 | |
| 3351 | - | |
| 3352 | -} | |
| 3353 | - | |
| 3354 | 2508 | // END OF CLASS |
| 3355 | -// END OF CLASS | |
| 3356 | -// END OF CLASS | |
| 3357 | 2509 | |
| 3358 | 2510 | |
| 2511 | +// mPDF 5.0.040 | |
| 3359 | 2512 | function calc_bezier_bbox($start, $c) { |
| 3360 | 2513 | $P0 = array($start[0],$start[1]); |
| 3361 | 2514 | $P1 = array($c[0],$c[1]); |
| 3362 | 2515 | $P2 = array($c[2],$c[3]); |
| @@ -3395,8 +2548,9 @@ | ||
| 3395 | 2548 | $y2 = max($bounds[1]); |
| 3396 | 2549 | return array($x, $y, $x2, $y2); |
| 3397 | 2550 | } |
| 3398 | 2551 | |
| 2552 | +// mPDF 5.0.040 | |
| 3399 | 2553 | function _testIntersectCircle($cx, $cy, $cr) { |
| 3400 | 2554 | // Tests whether a circle fully encloses a rectangle 0,0,1,1 |
| 3401 | 2555 | // to see if any further radial gradients need adding (SVG) |
| 3402 | 2556 | // If centre of circle is inside 0,0,1,1 square |
| @@ -3414,8 +2568,9 @@ | ||
| 3414 | 2568 | if ($cr < $maxd) { return true; } |
| 3415 | 2569 | else { return false; } |
| 3416 | 2570 | } |
| 3417 | 2571 | |
| 2572 | +// mPDF 5.0.040 | |
| 3418 | 2573 | function _testIntersect($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4) { |
| 3419 | 2574 | // Tests whether line (x1, y1) and (x2, y2) [a gradient axis (perpendicular)] |
| 3420 | 2575 | // intersects with a specific line segment (x3, y3) and (x4, y4) |
| 3421 | 2576 | $a1 = $y2-$y1; |