diff options
author | tcit <tcit@tcit.fr> | 2014-07-24 22:01:35 +0200 |
---|---|---|
committer | tcit <tcit@tcit.fr> | 2014-07-24 22:01:35 +0200 |
commit | d07abb5c42a816c94d05c5a1d7a78122e1b8b65c (patch) | |
tree | 38c9be0fba7c530cc1b4b6b43d127c38bfb45e37 /inc/3rdparty/libraries/mpdf/classes | |
parent | fb9df0c269f36703909b8b259abbdbed29881ecd (diff) | |
download | wallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.tar.gz wallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.tar.zst wallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.zip |
updated mpdf to 5.7.2
Diffstat (limited to 'inc/3rdparty/libraries/mpdf/classes')
-rw-r--r-- | inc/3rdparty/libraries/mpdf/classes/barcode.php | 1 | ||||
-rw-r--r-- | inc/3rdparty/libraries/mpdf/classes/cssmgr.php | 10 | ||||
-rw-r--r-- | inc/3rdparty/libraries/mpdf/classes/svg.php | 333 | ||||
-rw-r--r-- | inc/3rdparty/libraries/mpdf/classes/tocontents.php | 3 |
4 files changed, 228 insertions, 119 deletions
diff --git a/inc/3rdparty/libraries/mpdf/classes/barcode.php b/inc/3rdparty/libraries/mpdf/classes/barcode.php index 2a002693..9a230f0e 100644 --- a/inc/3rdparty/libraries/mpdf/classes/barcode.php +++ b/inc/3rdparty/libraries/mpdf/classes/barcode.php | |||
@@ -871,6 +871,7 @@ class PDFBarcode { | |||
871 | * Very capable code, excellent density, high reliability; in very wide use world-wide | 871 | * Very capable code, excellent density, high reliability; in very wide use world-wide |
872 | */ | 872 | */ |
873 | protected function barcode_c128($code, $type='B', $ean=false) { | 873 | protected function barcode_c128($code, $type='B', $ean=false) { |
874 | $code = strcode2utf($code); // mPDF 5.7.1 Allows e.g. <barcode code="5432
1068" type="C128A" /> | ||
874 | $chr = array( | 875 | $chr = array( |
875 | '212222', /* 00 */ | 876 | '212222', /* 00 */ |
876 | '222122', /* 01 */ | 877 | '222122', /* 01 */ |
diff --git a/inc/3rdparty/libraries/mpdf/classes/cssmgr.php b/inc/3rdparty/libraries/mpdf/classes/cssmgr.php index 9bbbed9c..db325034 100644 --- a/inc/3rdparty/libraries/mpdf/classes/cssmgr.php +++ b/inc/3rdparty/libraries/mpdf/classes/cssmgr.php | |||
@@ -221,9 +221,8 @@ function ReadCSS($html) { | |||
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | // mPDF 5.5.13 | ||
225 | // Replace any background: url(data:image... with temporary image file reference | 224 | // Replace any background: url(data:image... with temporary image file reference |
226 | preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*)\))/si", $CSSstr, $idata); | 225 | preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2 |
227 | if (count($idata[0])) { | 226 | if (count($idata[0])) { |
228 | for($i=0;$i<count($idata[0]);$i++) { | 227 | for($i=0;$i<count($idata[0]);$i++) { |
229 | $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i]; | 228 | $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i]; |
@@ -699,6 +698,13 @@ function fixCSS($prop) { | |||
699 | } | 698 | } |
700 | else { $newprop[$k] = $v; } | 699 | else { $newprop[$k] = $v; } |
701 | } | 700 | } |
701 | else if ($k == 'LIST-STYLE') { // mPDF 5.7.2 | ||
702 | if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|none|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$v,$m) | ||
703 | || preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) { | ||
704 | $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1])); | ||
705 | } | ||
706 | } | ||
707 | |||
702 | 708 | ||
703 | else { | 709 | else { |
704 | $newprop[$k] = $v; | 710 | $newprop[$k] = $v; |
diff --git a/inc/3rdparty/libraries/mpdf/classes/svg.php b/inc/3rdparty/libraries/mpdf/classes/svg.php index 3efe50f9..571f4edd 100644 --- a/inc/3rdparty/libraries/mpdf/classes/svg.php +++ b/inc/3rdparty/libraries/mpdf/classes/svg.php | |||
@@ -808,13 +808,20 @@ $md = $sy * cos($t); | |||
808 | } | 808 | } |
809 | 809 | ||
810 | if (isset($critere_style['style'])){ | 810 | if (isset($critere_style['style'])){ |
811 | if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) { | 811 | if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/i',$critere_style['style'], $m)) { // mPDF 5.7.2 |
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); | 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); |
813 | } | 813 | } |
814 | else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']); // mPDF 4.4.003 | 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; } | 815 | if ($tmp != $critere_style['style']){ $current_style['fill'] = $tmp; } |
816 | } | 816 | } |
817 | 817 | ||
818 | // mPDF 5.7.2 | ||
819 | if (preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m) || | ||
820 | preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m)) { | ||
821 | $current_style['fill-opacity'] = $m[1]; | ||
822 | $current_style['stroke-opacity'] = $m[1]; | ||
823 | } | ||
824 | |||
818 | $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | 825 | $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
819 | if ($tmp != $critere_style['style']){ $current_style['fill-opacity'] = $tmp;} | 826 | if ($tmp != $critere_style['style']){ $current_style['fill-opacity'] = $tmp;} |
820 | 827 | ||
@@ -852,6 +859,12 @@ $md = $sy * cos($t); | |||
852 | if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | 859 | if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} |
853 | 860 | ||
854 | } | 861 | } |
862 | // mPDF 5.7.2 | ||
863 | if(isset($critere_style['opacity'])){ | ||
864 | $current_style['fill-opacity'] = $critere_style['opacity']; | ||
865 | $current_style['stroke-opacity'] = $critere_style['opacity']; | ||
866 | } | ||
867 | |||
855 | if(isset($critere_style['fill'])){ | 868 | if(isset($critere_style['fill'])){ |
856 | $current_style['fill'] = $critere_style['fill']; | 869 | $current_style['fill'] = $critere_style['fill']; |
857 | } | 870 | } |
@@ -909,7 +922,7 @@ $md = $sy * cos($t); | |||
909 | // Cette fonction ecrit le style dans le stream svg. | 922 | // Cette fonction ecrit le style dans le stream svg. |
910 | function svgStyle($critere_style, $attribs, $element){ | 923 | function svgStyle($critere_style, $attribs, $element){ |
911 | $path_style = ''; | 924 | $path_style = ''; |
912 | if (substr_count($critere_style['fill'],'url')>0){ | 925 | if (substr_count($critere_style['fill'],'url')>0 && $element != 'line'){ |
913 | // | 926 | // |
914 | // couleur degradé | 927 | // couleur degradé |
915 | $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['fill']); | 928 | $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['fill']); |
@@ -926,7 +939,7 @@ $md = $sy * cos($t); | |||
926 | 939 | ||
927 | } | 940 | } |
928 | // mPDF 4.4.005 Used as indirect setting for currentColor | 941 | // mPDF 4.4.005 Used as indirect setting for currentColor |
929 | else if (strtolower($critere_style['fill']) == 'currentcolor'){ | 942 | else if (strtolower($critere_style['fill']) == 'currentcolor' && $element != 'line'){ |
930 | $col = $this->mpdf_ref->ConvertColor($critere_style['color']); | 943 | $col = $this->mpdf_ref->ConvertColor($critere_style['color']); |
931 | if ($col) { | 944 | if ($col) { |
932 | // mPDF 5.0.051 | 945 | // mPDF 5.0.051 |
@@ -937,7 +950,7 @@ $md = $sy * cos($t); | |||
937 | $style .= 'F'; | 950 | $style .= 'F'; |
938 | } | 951 | } |
939 | } | 952 | } |
940 | else if ($critere_style['fill'] != 'none'){ | 953 | else if ($critere_style['fill'] != 'none' && $element != 'line'){ |
941 | $col = $this->mpdf_ref->ConvertColor($critere_style['fill']); | 954 | $col = $this->mpdf_ref->ConvertColor($critere_style['fill']); |
942 | if ($col) { | 955 | if ($col) { |
943 | // mPDF 5.0.051 | 956 | // mPDF 5.0.051 |
@@ -1898,12 +1911,10 @@ function Arcto($x1, $y1, $x2, $y2, $rx, $ry, $angle, $largeArcFlag, $sweepFlag) | |||
1898 | $xbase = $x; | 1911 | $xbase = $x; |
1899 | $ybase = -$y; | 1912 | $ybase = -$y; |
1900 | 1913 | ||
1901 | // mPDF 5.0.041 | 1914 | // mPDF 5.7.2 |
1902 | // mPDF 5.0.051 | 1915 | $path_cmd = sprintf('q BT /F%d %.3F Tf %s %.3F %.3F Td %s Tr %s %s %s Tj ET Q ',$this->mpdf_ref->CurrentFont['i'], $this->mpdf_ref->FontSizePt, $opacitystr, $pdfx*$this->kp,$pdfy*$this->kp,$render,$fillstr,$strokestr,$txt)."\n"; |
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]); | 1916 | unset($this->txt_data[0], $this->txt_data[1],$this->txt_data[2]); |
1905 | 1917 | ||
1906 | // mPDF 5.4.12 | ||
1907 | if (isset($current_style['font-size-parent'])) { | 1918 | if (isset($current_style['font-size-parent'])) { |
1908 | $this->mpdf_ref->SetFontSize($current_style['font-size-parent']); | 1919 | $this->mpdf_ref->SetFontSize($current_style['font-size-parent']); |
1909 | } | 1920 | } |
@@ -1912,7 +1923,6 @@ function Arcto($x1, $y1, $x2, $y2, $rx, $ry, $angle, $largeArcFlag, $sweepFlag) | |||
1912 | { | 1923 | { |
1913 | return ' '; | 1924 | return ' '; |
1914 | } | 1925 | } |
1915 | // $path_cmd .= 'h '; // mPDF 5.0 | ||
1916 | return $path_cmd; | 1926 | return $path_cmd; |
1917 | } | 1927 | } |
1918 | 1928 | ||
@@ -1964,8 +1974,8 @@ function svgDefineTxtStyle($critere_style) | |||
1964 | $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | 1974 | $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
1965 | if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} | 1975 | if ($tmp != $critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;} |
1966 | 1976 | ||
1967 | // mPDF 5.0.039 | 1977 | // mPDF 5.7.2 |
1968 | $tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | 1978 | $tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.\"' ,\-]*|none)(.*)/i","$2",$critere_style['style']); |
1969 | if ($tmp != $critere_style['style']){ $critere_style['font-family'] = $tmp;} | 1979 | if ($tmp != $critere_style['style']){ $critere_style['font-family'] = $tmp;} |
1970 | 1980 | ||
1971 | $tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); | 1981 | $tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']); |
@@ -2120,15 +2130,15 @@ function svgDefineTxtStyle($critere_style) | |||
2120 | } | 2130 | } |
2121 | 2131 | ||
2122 | 2132 | ||
2123 | // mPDF 4.4.003 | ||
2124 | if (preg_match('/xlink:href=/si',$data)) { | 2133 | if (preg_match('/xlink:href=/si',$data)) { |
2134 | // GRADIENTS | ||
2125 | // Get links | 2135 | // Get links |
2126 | preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href=["\']#(.*?)["\'](.*?)\/>/si',$data, $links); | 2136 | preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href=["\']#(.*?)["\'](.*?)\/>/si',$data, $links); |
2127 | if (count($links[0])) { $links[5] = array(); } // mPDF 4.5.010 | 2137 | if (count($links[0])) { $links[5] = array(); } |
2128 | // Delete links from data - keeping in $links | 2138 | // Delete links from data - keeping in $links |
2129 | for ($i=0; $i<count($links[0]); $i++) { | 2139 | for ($i=0; $i<count($links[0]); $i++) { |
2130 | $links[5][$i] = 'tmpLink'.RAND(100000,9999999); // mPDF 4.5.010 | 2140 | $links[5][$i] = 'tmpLink'.RAND(100000,9999999); |
2131 | $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', '<MYLINKS'.$links[5][$i].'>' , $data); // mPDF 4.5.010 | 2141 | $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', '<MYLINKS'.$links[5][$i].'>' , $data); |
2132 | } | 2142 | } |
2133 | // Get targets | 2143 | // Get targets |
2134 | preg_match_all('/<(linearGradient|radialgradient)([^>]*)id=["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',$data, $m); | 2144 | preg_match_all('/<(linearGradient|radialgradient)([^>]*)id=["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',$data, $m); |
@@ -2140,13 +2150,110 @@ function svgDefineTxtStyle($critere_style) | |||
2140 | } | 2150 | } |
2141 | // Add back links this time as targets (gradients) | 2151 | // Add back links this time as targets (gradients) |
2142 | for ($i=0; $i<count($links[0]); $i++) { | 2152 | for ($i=0; $i<count($links[0]); $i++) { |
2143 | $def = $links[1][$i] .' '.$links[4][$i].'>'. $stops[$links[3][$i]].'</'.$links[2][$i] .'>' ; // mPDF 4.5.010 | 2153 | $def = $links[1][$i] .' '.$links[4][$i].'>'. $stops[$links[3][$i]].'</'.$links[2][$i] .'>' ; |
2144 | $data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', $def , $data); // mPDF 4.5.010 | 2154 | $data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', $def , $data); |
2155 | } | ||
2156 | |||
2157 | // mPDF 5.7.2 | ||
2158 | // <USE> | ||
2159 | preg_match_all('/<use ([^>]*)xlink:href=["\']#([^>]*?)["\']([^>]*)\/>/si',$data, $links); | ||
2160 | for ($i=0; $i<count($links[0]); $i++) { | ||
2161 | |||
2162 | // Get the item to use from defs | ||
2163 | $insert = ''; | ||
2164 | if (preg_match('/<([a-zA-Z]*) [^>]*id=["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) { | ||
2165 | $insert = $m[0]; | ||
2166 | } | ||
2167 | if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id=["\']'.$links[2][$i].'["\']/si',$data, $m)) { | ||
2168 | |||
2169 | if (preg_match('/<'.$m[1].'[^>]*id=["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) { | ||
2170 | $insert = $m[0]; | ||
2171 | } | ||
2172 | } | ||
2173 | |||
2174 | if ($insert) { | ||
2175 | |||
2176 | $inners = $links[1][$i] . ' ' . $links[3][$i]; | ||
2177 | // Change x,y coords to translate() | ||
2178 | if (preg_match('/y=["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; } | ||
2179 | else { $y = 0; } | ||
2180 | if (preg_match('/x=["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; } | ||
2181 | else { $x = 0; } | ||
2182 | if ($x || $y) { | ||
2183 | $inners = preg_replace('/(y|x)=["\']([^>]*?)["\']/', '', $inners); | ||
2184 | if (preg_match('/transform=["\']([^>]*?)["\']/', $inners, $m)) { | ||
2185 | if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) { | ||
2186 | $transform = $m[1]; // transform="...." | ||
2187 | $x += $mm[1]; | ||
2188 | $y += $mm[2]; | ||
2189 | $transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform); | ||
2190 | $transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"'; | ||
2191 | $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners); | ||
2192 | } | ||
2193 | else { | ||
2194 | $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners); | ||
2195 | } | ||
2196 | } | ||
2197 | else { | ||
2198 | $inners .= ' transform="translate('.$x.', '.$y.')"'; | ||
2199 | } | ||
2200 | } | ||
2201 | } | ||
2202 | $replacement = '<g '.$inners.'>'.$insert.'</g>'; | ||
2203 | $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data); | ||
2204 | } | ||
2205 | preg_match_all('/<use ([^>]*)xlink:href=["\']#([^>]*?)["\']([^>]*)>\s*<\/use>/si',$data, $links); | ||
2206 | for ($i=0; $i<count($links[0]); $i++) { | ||
2207 | |||
2208 | // Get the item to use from defs | ||
2209 | $insert = ''; | ||
2210 | if (preg_match('/<([a-zA-Z]*) [^>]*id=["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) { | ||
2211 | $insert = $m[0]; | ||
2212 | } | ||
2213 | if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id=["\']'.$links[2][$i].'["\']/si',$data, $m)) { | ||
2214 | |||
2215 | if (preg_match('/<'.$m[1].'[^>]*id=["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) { | ||
2216 | $insert = $m[0]; | ||
2217 | } | ||
2218 | } | ||
2219 | |||
2220 | if ($insert) { | ||
2221 | |||
2222 | $inners = $links[1][$i] . ' ' . $links[3][$i]; | ||
2223 | // Change x,y coords to translate() | ||
2224 | if (preg_match('/y=["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; } | ||
2225 | else { $y = 0; } | ||
2226 | if (preg_match('/x=["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; } | ||
2227 | else { $x = 0; } | ||
2228 | if ($x || $y) { | ||
2229 | $inners = preg_replace('/(y|x)=["\']([^>]*?)["\']/', '', $inners); | ||
2230 | if (preg_match('/transform=["\']([^>]*?)["\']/', $inners, $m)) { | ||
2231 | if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) { | ||
2232 | $transform = $m[1]; // transform="...." | ||
2233 | $x += $mm[1]; | ||
2234 | $y += $mm[2]; | ||
2235 | $transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform); | ||
2236 | $transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"'; | ||
2237 | $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners); | ||
2238 | } | ||
2239 | else { | ||
2240 | $inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners); | ||
2241 | } | ||
2242 | } | ||
2243 | else { | ||
2244 | $inners .= ' transform="translate('.$x.', '.$y.')"'; | ||
2245 | } | ||
2246 | } | ||
2247 | $replacement = '<g '.$inners.'>'.$insert.'</g>'; | ||
2248 | $data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data); | ||
2249 | |||
2250 | |||
2251 | } | ||
2145 | } | 2252 | } |
2146 | } | 2253 | } |
2147 | // mPDF 4.4.003 - Removes <pattern> | 2254 | // Removes <pattern> |
2148 | $data = preg_replace('/<pattern.*?<\/pattern>/is', '', $data); | 2255 | $data = preg_replace('/<pattern.*?<\/pattern>/is', '', $data); |
2149 | // mPDF 4.4.003 - Removes <marker> | 2256 | // Removes <marker> |
2150 | $data = preg_replace('/<marker.*?<\/marker>/is', '', $data); | 2257 | $data = preg_replace('/<marker.*?<\/marker>/is', '', $data); |
2151 | 2258 | ||
2152 | $this->svg_info['data'] = $data; | 2259 | $this->svg_info['data'] = $data; |
@@ -2155,14 +2262,96 @@ function svgDefineTxtStyle($critere_style) | |||
2155 | 2262 | ||
2156 | // | 2263 | // |
2157 | // chargement unique des fonctions | 2264 | // chargement unique des fonctions |
2158 | if(!function_exists("xml_svg2pdf_start")){ // mPDF 5.3.76 | 2265 | if(!function_exists("xml_svg2pdf_start")){ |
2159 | 2266 | ||
2160 | function xml_svg2pdf_start($parser, $name, $attribs){ | 2267 | function xml_svg2pdf_start($parser, $name, $attribs){ |
2161 | // | 2268 | // |
2162 | // definition | 2269 | // definition |
2163 | global $svg_class, $last_gradid; | 2270 | global $svg_class, $last_gradid; |
2164 | 2271 | ||
2165 | // mPDF 4.4.003 | 2272 | // mPDF 5.7.2 |
2273 | if (strtolower($name) == 'lineargradient'){ | ||
2274 | $tmp_gradient = array( | ||
2275 | 'type' => 'linear', | ||
2276 | 'info' => array( | ||
2277 | 'x1' => $attribs['x1'], | ||
2278 | 'y1' => $attribs['y1'], | ||
2279 | 'x2' => $attribs['x2'], | ||
2280 | 'y2' => $attribs['y2'] | ||
2281 | ), | ||
2282 | 'transform' => $attribs['gradientTransform'], | ||
2283 | 'units' => $attribs['gradientUnits'], | ||
2284 | 'spread' => $attribs['spreadMethod'], | ||
2285 | 'color' => array() | ||
2286 | ); | ||
2287 | $last_gradid = $attribs['id']; | ||
2288 | $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | ||
2289 | return; | ||
2290 | } | ||
2291 | else if (strtolower($name) == 'radialgradient'){ | ||
2292 | $tmp_gradient = array( | ||
2293 | 'type' => 'radial', | ||
2294 | 'info' => array( | ||
2295 | 'x0' => $attribs['cx'], | ||
2296 | 'y0' => $attribs['cy'], | ||
2297 | 'x1' => $attribs['fx'], | ||
2298 | 'y1' => $attribs['fy'], | ||
2299 | 'r' => $attribs['r'] | ||
2300 | ), | ||
2301 | 'transform' => $attribs['gradientTransform'], | ||
2302 | 'units' => $attribs['gradientUnits'], | ||
2303 | 'spread' => $attribs['spreadMethod'], | ||
2304 | 'color' => array() | ||
2305 | ); | ||
2306 | $last_gradid = $attribs['id']; | ||
2307 | $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | ||
2308 | return; | ||
2309 | } | ||
2310 | else if (strtolower($name) == 'stop'){ | ||
2311 | if (!$last_gradid) break; | ||
2312 | if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',$attribs['style'],$m)) { | ||
2313 | $color = trim($m[1]); | ||
2314 | } else if (isset($attribs['stop-color'])) { | ||
2315 | $color = $attribs['stop-color']; | ||
2316 | } | ||
2317 | $col = $svg_class->mpdf_ref->ConvertColor($color); | ||
2318 | |||
2319 | if ($col{0}==3 || $col{0}==5) { // RGB | ||
2320 | $color_final = sprintf('%.3F %.3F %.3F',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255); | ||
2321 | $svg_class->svg_gradient[$last_gradid]['colorspace']='RGB'; | ||
2322 | } | ||
2323 | else if ($col{0}==4 || $col{0}==6) { // CMYK | ||
2324 | $color_final = sprintf('%.3F %.3F %.3F %.3F',ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100); | ||
2325 | $svg_class->svg_gradient[$last_gradid]['colorspace']='CMYK'; | ||
2326 | } | ||
2327 | else if ($col{0}==1) { // Grayscale | ||
2328 | $color_final = sprintf('%.3F',ord($col{1})/255); | ||
2329 | $svg_class->svg_gradient[$last_gradid]['colorspace']='Gray'; | ||
2330 | } | ||
2331 | |||
2332 | $stop_opacity = 1; | ||
2333 | if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',$attribs['style'],$m)) { | ||
2334 | $stop_opacity = $m[1]; | ||
2335 | } else if (isset($attribs['stop-opacity'])) { | ||
2336 | $stop_opacity = $attribs['stop-opacity']; | ||
2337 | } | ||
2338 | else if ($col{0}==5) { // RGBa | ||
2339 | $stop_opacity = ord($col{4}/100); | ||
2340 | } | ||
2341 | else if ($col{0}==6) { // CMYKa | ||
2342 | $stop_opacity = ord($col{5}/100); | ||
2343 | } | ||
2344 | |||
2345 | $tmp_color = array( | ||
2346 | 'color' => $color_final, | ||
2347 | 'offset' => $attribs['offset'], | ||
2348 | 'opacity' => $stop_opacity | ||
2349 | ); | ||
2350 | array_push($svg_class->svg_gradient[$last_gradid]['color'],$tmp_color); | ||
2351 | return; | ||
2352 | } | ||
2353 | if ($svg_class->inDefs) { return; } | ||
2354 | |||
2166 | $svg_class->xbase = 0; | 2355 | $svg_class->xbase = 0; |
2167 | $svg_class->ybase = 0; | 2356 | $svg_class->ybase = 0; |
2168 | switch (strtolower($name)){ | 2357 | switch (strtolower($name)){ |
@@ -2293,99 +2482,6 @@ function svgDefineTxtStyle($critere_style) | |||
2293 | $path_style = $svg_class->svgDefineStyle($critere_style); | 2482 | $path_style = $svg_class->svgDefineStyle($critere_style); |
2294 | break; | 2483 | break; |
2295 | 2484 | ||
2296 | case 'lineargradient': | ||
2297 | $tmp_gradient = array( | ||
2298 | 'type' => 'linear', | ||
2299 | 'info' => array( | ||
2300 | 'x1' => $attribs['x1'], | ||
2301 | 'y1' => $attribs['y1'], | ||
2302 | 'x2' => $attribs['x2'], | ||
2303 | 'y2' => $attribs['y2'] | ||
2304 | ), | ||
2305 | 'transform' => $attribs['gradientTransform'], | ||
2306 | 'units' => $attribs['gradientUnits'], /* mPDF 4.4.003 */ | ||
2307 | 'spread' => $attribs['spreadMethod'], /* mPDF 5.0.040 */ | ||
2308 | 'color' => array() | ||
2309 | ); | ||
2310 | |||
2311 | $last_gradid = $attribs['id']; | ||
2312 | $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | ||
2313 | break; | ||
2314 | |||
2315 | case 'radialgradient': | ||
2316 | $tmp_gradient = array( | ||
2317 | 'type' => 'radial', | ||
2318 | 'info' => array( | ||
2319 | 'x0' => $attribs['cx'], | ||
2320 | 'y0' => $attribs['cy'], | ||
2321 | 'x1' => $attribs['fx'], | ||
2322 | 'y1' => $attribs['fy'], | ||
2323 | 'r' => $attribs['r'] | ||
2324 | ), | ||
2325 | 'transform' => $attribs['gradientTransform'], | ||
2326 | 'units' => $attribs['gradientUnits'], /* mPDF 4.4.003 */ | ||
2327 | 'spread' => $attribs['spreadMethod'], /* mPDF 5.0.040 */ | ||
2328 | 'color' => array() | ||
2329 | ); | ||
2330 | |||
2331 | $last_gradid = $attribs['id']; | ||
2332 | |||
2333 | $svg_class->svgAddGradient($attribs['id'],$tmp_gradient); | ||
2334 | |||
2335 | break; | ||
2336 | |||
2337 | case 'stop': | ||
2338 | if (!$last_gradid) break; | ||
2339 | // mPDF 4.4.003 // mPDF 5.0.040 | ||
2340 | if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',$attribs['style'],$m)) { | ||
2341 | $color = trim($m[1]); | ||
2342 | } else if (isset($attribs['stop-color'])) { | ||
2343 | $color = $attribs['stop-color']; | ||
2344 | } | ||
2345 | $col = $svg_class->mpdf_ref->ConvertColor($color); | ||
2346 | |||
2347 | // mPDF 5.0.051 | ||
2348 | // mPDF 5.3.74 | ||
2349 | if ($col{0}==3 || $col{0}==5) { // RGB | ||
2350 | $color_final = sprintf('%.3F %.3F %.3F',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255); | ||
2351 | $svg_class->svg_gradient[$last_gradid]['colorspace']='RGB'; | ||
2352 | } | ||
2353 | else if ($col{0}==4 || $col{0}==6) { // CMYK | ||
2354 | $color_final = sprintf('%.3F %.3F %.3F %.3F',ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100); | ||
2355 | $svg_class->svg_gradient[$last_gradid]['colorspace']='CMYK'; | ||
2356 | } | ||
2357 | else if ($col{0}==1) { // Grayscale | ||
2358 | $color_final = sprintf('%.3F',ord($col{1})/255); | ||
2359 | $svg_class->svg_gradient[$last_gradid]['colorspace']='Gray'; | ||
2360 | } | ||
2361 | |||
2362 | |||
2363 | // mPDF 5.0.020 | ||
2364 | $stop_opacity = 1; | ||
2365 | // mPDF 4.4.003 | ||
2366 | if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',$attribs['style'],$m)) { | ||
2367 | $stop_opacity = $m[1]; | ||
2368 | } else if (isset($attribs['stop-opacity'])) { | ||
2369 | $stop_opacity = $attribs['stop-opacity']; | ||
2370 | } | ||
2371 | // mPDF 5.0.051 | ||
2372 | // mPDF 5.3.74 | ||
2373 | else if ($col{0}==5) { // RGBa | ||
2374 | $stop_opacity = ord($col{4}/100); | ||
2375 | } | ||
2376 | else if ($col{0}==6) { // CMYKa | ||
2377 | $stop_opacity = ord($col{5}/100); | ||
2378 | } | ||
2379 | |||
2380 | $tmp_color = array( | ||
2381 | 'color' => $color_final, | ||
2382 | 'offset' => $attribs['offset'], | ||
2383 | 'opacity' => $stop_opacity | ||
2384 | ); | ||
2385 | array_push($svg_class->svg_gradient[$last_gradid]['color'],$tmp_color); | ||
2386 | break; | ||
2387 | |||
2388 | |||
2389 | case 'a': | 2485 | case 'a': |
2390 | if (isset($attribs['xlink:href'])) { | 2486 | if (isset($attribs['xlink:href'])) { |
2391 | unset($attribs['xlink:href']); // this should be a hyperlink | 2487 | unset($attribs['xlink:href']); // this should be a hyperlink |
@@ -2403,7 +2499,6 @@ function svgDefineTxtStyle($critere_style) | |||
2403 | break; | 2499 | break; |
2404 | 2500 | ||
2405 | case 'text': | 2501 | case 'text': |
2406 | // mPDF 4.4.003 | ||
2407 | $array_style = $svg_class->svgDefineStyle($attribs); | 2502 | $array_style = $svg_class->svgDefineStyle($attribs); |
2408 | if ($array_style['transformations']) { | 2503 | if ($array_style['transformations']) { |
2409 | $svg_class->svgWriteString(' q '.$array_style['transformations']); | 2504 | $svg_class->svgWriteString(' q '.$array_style['transformations']); |
@@ -2436,6 +2531,7 @@ function svgDefineTxtStyle($critere_style) | |||
2436 | function characterData($parser, $data) | 2531 | function characterData($parser, $data) |
2437 | { | 2532 | { |
2438 | global $svg_class; | 2533 | global $svg_class; |
2534 | if ($svg_class->inDefs) { return; } // mPDF 5.7.2 | ||
2439 | if(isset($svg_class->txt_data[2])) { | 2535 | if(isset($svg_class->txt_data[2])) { |
2440 | $svg_class->txt_data[2] .= $data; | 2536 | $svg_class->txt_data[2] .= $data; |
2441 | } | 2537 | } |
@@ -2447,6 +2543,13 @@ function svgDefineTxtStyle($critere_style) | |||
2447 | 2543 | ||
2448 | function xml_svg2pdf_end($parser, $name){ | 2544 | function xml_svg2pdf_end($parser, $name){ |
2449 | global $svg_class; | 2545 | global $svg_class; |
2546 | // Don't output stuff inside <defs> | ||
2547 | // mPDF 5.7.2 | ||
2548 | if ($name == 'defs') { | ||
2549 | $svg_class->inDefs = false; | ||
2550 | return; | ||
2551 | } | ||
2552 | if ($svg_class->inDefs) { return; } | ||
2450 | switch($name){ | 2553 | switch($name){ |
2451 | 2554 | ||
2452 | case "g": | 2555 | case "g": |
diff --git a/inc/3rdparty/libraries/mpdf/classes/tocontents.php b/inc/3rdparty/libraries/mpdf/classes/tocontents.php index 4e0065d2..b1b61446 100644 --- a/inc/3rdparty/libraries/mpdf/classes/tocontents.php +++ b/inc/3rdparty/libraries/mpdf/classes/tocontents.php | |||
@@ -224,7 +224,6 @@ function insertTOC() { | |||
224 | $tocstart=count($this->mpdf->pages); | 224 | $tocstart=count($this->mpdf->pages); |
225 | if ($toc_preHTML) { $this->mpdf->WriteHTML($toc_preHTML); } | 225 | if ($toc_preHTML) { $this->mpdf->WriteHTML($toc_preHTML); } |
226 | 226 | ||
227 | |||
228 | // mPDF 5.6.19 | 227 | // mPDF 5.6.19 |
229 | $html ='<div class="mpdf_toc" id="mpdf_toc_'.$toc_id.'">'; | 228 | $html ='<div class="mpdf_toc" id="mpdf_toc_'.$toc_id.'">'; |
230 | foreach($this->_toc as $t) { | 229 | foreach($this->_toc as $t) { |
@@ -268,7 +267,7 @@ function insertTOC() { | |||
268 | $s .= $this->mpdf->PrintBodyBackgrounds(); | 267 | $s .= $this->mpdf->PrintBodyBackgrounds(); |
269 | 268 | ||
270 | $s .= $this->mpdf->PrintPageBackgrounds(); | 269 | $s .= $this->mpdf->PrintPageBackgrounds(); |
271 | $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->mpdf->pages[$this->mpdf->page]); | 270 | $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->mpdf->uniqstr.')/', "\n".$s."\n".'\\1', $this->mpdf->pages[$this->mpdf->page]); |
272 | $this->mpdf->pageBackgrounds = array(); | 271 | $this->mpdf->pageBackgrounds = array(); |
273 | 272 | ||
274 | //Page footer | 273 | //Page footer |