aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty
diff options
context:
space:
mode:
authortcit <tcit@tcit.fr>2014-07-24 22:01:35 +0200
committertcit <tcit@tcit.fr>2014-07-24 22:01:35 +0200
commitd07abb5c42a816c94d05c5a1d7a78122e1b8b65c (patch)
tree38c9be0fba7c530cc1b4b6b43d127c38bfb45e37 /inc/3rdparty
parentfb9df0c269f36703909b8b259abbdbed29881ecd (diff)
downloadwallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.tar.gz
wallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.tar.zst
wallabag-d07abb5c42a816c94d05c5a1d7a78122e1b8b65c.zip
updated mpdf to 5.7.2
Diffstat (limited to 'inc/3rdparty')
-rw-r--r--inc/3rdparty/libraries/mpdf/classes/barcode.php1
-rw-r--r--inc/3rdparty/libraries/mpdf/classes/cssmgr.php10
-rw-r--r--inc/3rdparty/libraries/mpdf/classes/svg.php333
-rw-r--r--inc/3rdparty/libraries/mpdf/classes/tocontents.php3
-rw-r--r--inc/3rdparty/libraries/mpdf/includes/functions.php32
-rw-r--r--inc/3rdparty/libraries/mpdf/mpdf.php328
6 files changed, 462 insertions, 245 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&#013;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
diff --git a/inc/3rdparty/libraries/mpdf/includes/functions.php b/inc/3rdparty/libraries/mpdf/includes/functions.php
index 03f47090..78683af8 100644
--- a/inc/3rdparty/libraries/mpdf/includes/functions.php
+++ b/inc/3rdparty/libraries/mpdf/includes/functions.php
@@ -1,5 +1,13 @@
1<?php 1<?php
2 2
3// mPDF 5.7
4// Replace a section of an array with the elements in reverse
5function array_splice_reverse(&$arr, $offset, $length) {
6 $tmp = (array_reverse(array_slice($arr, $offset, $length)));
7 array_splice($arr, $offset, $length, $tmp);
8}
9
10
3// mPDF 5.6.23 11// mPDF 5.6.23
4function array_insert(&$array, $value, $offset) { 12function array_insert(&$array, $value, $offset) {
5 if (is_array($array)) { 13 if (is_array($array)) {
@@ -92,12 +100,30 @@ function PreparePreText($text,$ff='//FF//') {
92if(!function_exists('strcode2utf')){ 100if(!function_exists('strcode2utf')){
93 function strcode2utf($str,$lo=true) { 101 function strcode2utf($str,$lo=true) {
94 //converts all the &#nnn; and &#xhhh; in a string to Unicode 102 //converts all the &#nnn; and &#xhhh; in a string to Unicode
95 if ($lo) { $lo = 1; } else { $lo = 0; } 103 // mPDF 5.7
96 $str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str); 104 if ($lo) {
97 $str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str); 105 $str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_lo_callback', $str);
106 $str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_lo_callback', $str);
107 }
108 else {
109 $str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_callback', $str);
110 $str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_callback', $str);
111 }
98 return $str; 112 return $str;
99 } 113 }
100} 114}
115function code2utf_callback($matches) {
116 return code2utf($matches[1], 0);
117}
118function code2utf_lo_callback($matches) {
119 return code2utf($matches[1], 1);
120}
121function codeHex2utf_callback($matches) {
122 return codeHex2utf($matches[1], 0);
123}
124function codeHex2utf_lo_callback($matches) {
125 return codeHex2utf($matches[1], 1);
126}
101 127
102if(!function_exists('code2utf')){ 128if(!function_exists('code2utf')){
103 function code2utf($num,$lo=true){ 129 function code2utf($num,$lo=true){
diff --git a/inc/3rdparty/libraries/mpdf/mpdf.php b/inc/3rdparty/libraries/mpdf/mpdf.php
index f12dfec0..fd4f57b3 100644
--- a/inc/3rdparty/libraries/mpdf/mpdf.php
+++ b/inc/3rdparty/libraries/mpdf/mpdf.php
@@ -2,10 +2,10 @@
2 2
3// ****************************************************************************** 3// ******************************************************************************
4// Software: mPDF, Unicode-HTML Free PDF generator * 4// Software: mPDF, Unicode-HTML Free PDF generator *
5// Version: 5.7 based on * 5// Version: 5.7.2 based on *
6// FPDF by Olivier PLATHEY * 6// FPDF by Olivier PLATHEY *
7// HTML2FPDF by Renato Coelho * 7// HTML2FPDF by Renato Coelho *
8// Date: 2013-07-14 * 8// Date: 2013-09-01 *
9// Author: Ian Back <ianb@bpm1.com> * 9// Author: Ian Back <ianb@bpm1.com> *
10// License: GPL * 10// License: GPL *
11// * 11// *
@@ -13,7 +13,7 @@
13// ****************************************************************************** 13// ******************************************************************************
14 14
15 15
16define('mPDF_VERSION','5.7'); 16define('mPDF_VERSION','5.7.2');
17 17
18//Scale factor 18//Scale factor
19define('_MPDFK', (72/25.4)); 19define('_MPDFK', (72/25.4));
@@ -269,6 +269,7 @@ var $directw;
269////////////////////// 269//////////////////////
270// INTERNAL VARIABLES 270// INTERNAL VARIABLES
271////////////////////// 271//////////////////////
272var $uniqstr; // mPDF 5.7.2
272var $writingToC; // mPDF 5.6.38 273var $writingToC; // mPDF 5.6.38
273// mPDF 5.6.01 274// mPDF 5.6.01
274var $layers; 275var $layers;
@@ -850,6 +851,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
850 $this->useSubstitutionsMB =& $this->useSubstitutions; 851 $this->useSubstitutionsMB =& $this->useSubstitutions;
851 852
852 $this->writingToC = false; // mPDF 5.6.38 853 $this->writingToC = false; // mPDF 5.6.38
854 $this->uniqstr = '20110230'; // mPDF 5.7.2
853 // mPDF 5.6.01 855 // mPDF 5.6.01
854 $this->layers = array(); 856 $this->layers = array();
855 $this->current_layer = 0; 857 $this->current_layer = 0;
@@ -1146,7 +1148,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1146 $optcore = false; 1148 $optcore = false;
1147 $onlyCoreFonts = false; 1149 $onlyCoreFonts = false;
1148 if (preg_match('/([\-+])aCJK/i',$mode, $m)) { 1150 if (preg_match('/([\-+])aCJK/i',$mode, $m)) {
1149 preg_replace('/([\-+])aCJK/i','',$mode); 1151 $mode = preg_replace('/([\-+])aCJK/i','',$mode);
1150 if ($m[1]=='+') { $this->useAdobeCJK = true; } 1152 if ($m[1]=='+') { $this->useAdobeCJK = true; }
1151 else { $this->useAdobeCJK = false; } 1153 else { $this->useAdobeCJK = false; }
1152 } 1154 }
@@ -1682,8 +1684,8 @@ function SetAlpha($alpha, $bm='Normal', $return=false, $mode='B') {
1682 $alpha = 1; 1684 $alpha = 1;
1683 } 1685 }
1684 $a = array('BM'=>'/'.$bm); 1686 $a = array('BM'=>'/'.$bm);
1685 if ($mode=='F' || $mode='B') $a['ca'] = $alpha; 1687 if ($mode=='F' || $mode=='B') $a['ca'] = $alpha; // mPDF 5.7.2
1686 if ($mode=='S' || $mode='B') $a['CA'] = $alpha; 1688 if ($mode=='S' || $mode=='B') $a['CA'] = $alpha; // mPDF 5.7.2
1687 $gs = $this->AddExtGState($a); 1689 $gs = $this->AddExtGState($a);
1688 if ($return) { return sprintf('/GS%d gs', $gs); } 1690 if ($return) { return sprintf('/GS%d gs', $gs); }
1689 else { $this->_out(sprintf('/GS%d gs', $gs)); } 1691 else { $this->_out(sprintf('/GS%d gs', $gs)); }
@@ -1765,7 +1767,7 @@ function Close() {
1765 $s .= $this->PrintBodyBackgrounds(); 1767 $s .= $this->PrintBodyBackgrounds();
1766 1768
1767 $s .= $this->PrintPageBackgrounds(); 1769 $s .= $this->PrintPageBackgrounds();
1768 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); 1770 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]);
1769 $this->pageBackgrounds = array(); 1771 $this->pageBackgrounds = array();
1770 1772
1771 if($this->visibility!='visible') 1773 if($this->visibility!='visible')
@@ -2344,7 +2346,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
2344 $s = $this->PrintPageBackgrounds(); 2346 $s = $this->PrintPageBackgrounds();
2345 2347
2346 // Writes after the marker so not overwritten later by page background etc. 2348 // Writes after the marker so not overwritten later by page background etc.
2347 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 2349 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
2348 $this->pageBackgrounds = array(); 2350 $this->pageBackgrounds = array();
2349 $family=$this->FontFamily; 2351 $family=$this->FontFamily;
2350 $style=$this->FontStyle.($this->U ? 'U' : '').($this->S ? 'S' : ''); 2352 $style=$this->FontStyle.($this->U ? 'U' : '').($this->S ? 'S' : '');
@@ -2485,7 +2487,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
2485 $s .= $this->PrintBodyBackgrounds(); 2487 $s .= $this->PrintBodyBackgrounds();
2486 2488
2487 $s .= $this->PrintPageBackgrounds(); 2489 $s .= $this->PrintPageBackgrounds();
2488 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); 2490 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]);
2489 $this->pageBackgrounds = array(); 2491 $this->pageBackgrounds = array();
2490 } 2492 }
2491 2493
@@ -2545,9 +2547,9 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
2545 } 2547 }
2546 2548
2547 // Tiling Patterns 2549 // Tiling Patterns
2548 $this->_out('___PAGE___START'.date('jY')); 2550 $this->_out('___PAGE___START'.$this->uniqstr);
2549 $this->_out('___BACKGROUND___PATTERNS'.date('jY')); 2551 $this->_out('___BACKGROUND___PATTERNS'.$this->uniqstr);
2550 $this->_out('___HEADER___MARKER'.date('jY')); 2552 $this->_out('___HEADER___MARKER'.$this->uniqstr);
2551 $this->pageBackgrounds = array(); 2553 $this->pageBackgrounds = array();
2552 2554
2553 //Set line cap style to square 2555 //Set line cap style to square
@@ -3628,9 +3630,8 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3628 $oldcolumn = $this->CurrCol; 3630 $oldcolumn = $this->CurrCol;
3629 // Automatic page break 3631 // Automatic page break
3630 // Allows PAGE-BREAK-AFTER = avoid to work 3632 // Allows PAGE-BREAK-AFTER = avoid to work
3631
3632 if (!$this->tableLevel && (($this->y+$this->divheight>$this->PageBreakTrigger) || ($this->y+$h>$this->PageBreakTrigger) || 3633 if (!$this->tableLevel && (($this->y+$this->divheight>$this->PageBreakTrigger) || ($this->y+$h>$this->PageBreakTrigger) ||
3633 ($this->y+($h*2)>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) { 3634 ($this->y+($h*2)+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['margin_bottom']>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) { // mPDF 5.7.2
3634 $x=$this->x;//Current X position 3635 $x=$this->x;//Current X position
3635 3636
3636 3637
@@ -6086,6 +6087,17 @@ function WriteFlowingBlock( $s)
6086 $savedContent = array_pop( $content ); 6087 $savedContent = array_pop( $content );
6087 $savedContentB = array_pop($contentB); // mPDF 5.6.20 6088 $savedContentB = array_pop($contentB); // mPDF 5.6.20
6088 $savedFont = array_pop( $font ); 6089 $savedFont = array_pop( $font );
6090
6091 // mPDF 5.7.2
6092 // e.g: |first chunk |second chunk |[IndexEntry]|doesntfit
6093 if (isset($this->objectbuffer[(count($content)-1)]) && $this->objectbuffer[(count($content)-1)]['OUTER-WIDTH'] < 0.001) {
6094 $savedObj = $this->objectbuffer[(count($content)-1)];
6095 array_pop( $content );
6096 array_pop( $contentB );
6097 array_pop( $font );
6098 array_pop( $this->objectbuffer );
6099 }
6100
6089 // trim any trailing spaces off the last bit of content 6101 // trim any trailing spaces off the last bit of content
6090 $currContent =& $content[ count( $content ) - 1 ]; 6102 $currContent =& $content[ count( $content ) - 1 ];
6091 $currContent = rtrim( $currContent ); 6103 $currContent = rtrim( $currContent );
@@ -6347,6 +6359,10 @@ function WriteFlowingBlock( $s)
6347 $this->keep_block_together = 0; 6359 $this->keep_block_together = 0;
6348 } 6360 }
6349 6361
6362 if ($this->kwt && !$is_table) { // mPDF 5.7+
6363 $this->printkwtbuffer();
6364 $this->kwt = false;
6365 }
6350 6366
6351/*-- COLUMNS --*/ 6367/*-- COLUMNS --*/
6352 // COLS 6368 // COLS
@@ -6913,7 +6929,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t
6913 6929
6914 if ($this->watermarkImgBehind) { 6930 if ($this->watermarkImgBehind) {
6915 $outstring = $this->watermarkImgAlpha . "\n" . $outstring . "\n" . $this->SetAlpha(1, 'Normal', true) . "\n"; 6931 $outstring = $this->watermarkImgAlpha . "\n" . $outstring . "\n" . $this->SetAlpha(1, 'Normal', true) . "\n";
6916 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$outstring."\n".'\\1', $this->pages[$this->page]); 6932 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$outstring."\n".'\\1', $this->pages[$this->page]);
6917 } 6933 }
6918 else { $this->_out($outstring); } 6934 else { $this->_out($outstring); }
6919 6935
@@ -7387,7 +7403,7 @@ function Output($name='',$dest='')
7387/*-- PROGRESS-BAR --*/ 7403/*-- PROGRESS-BAR --*/
7388 if ($this->progressBar && ($dest=='D' || $dest=='I')) { 7404 if ($this->progressBar && ($dest=='D' || $dest=='I')) {
7389 if($name=='') { $name='mpdf.pdf'; } 7405 if($name=='') { $name='mpdf.pdf'; }
7390 $tempfile = '_tempPDF'.RAND(1,10000); 7406 $tempfile = '_tempPDF'.uniqid(rand(1,100000),true);
7391 //Save to local file 7407 //Save to local file
7392 $f=fopen(_MPDF_TEMP_PATH.$tempfile.'.pdf','wb'); 7408 $f=fopen(_MPDF_TEMP_PATH.$tempfile.'.pdf','wb');
7393 if(!$f) $this->Error('Unable to create temporary output file: '.$tempfile.'.pdf'); 7409 if(!$f) $this->Error('Unable to create temporary output file: '.$tempfile.'.pdf');
@@ -7451,7 +7467,7 @@ function Output($name='',$dest='')
7451 // don't use length if server using compression 7467 // don't use length if server using compression
7452 header('Content-Length: '.strlen($this->buffer)); 7468 header('Content-Length: '.strlen($this->buffer));
7453 } 7469 }
7454 header('Content-disposition: attachment; filename="'.$name.'"'); 7470 header('Content-disposition: inline; filename="'.$name.'"');
7455 header('Cache-Control: public, must-revalidate, max-age=0'); 7471 header('Cache-Control: public, must-revalidate, max-age=0');
7456 header('Pragma: public'); 7472 header('Pragma: public');
7457 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); 7473 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
@@ -7501,7 +7517,7 @@ function Output($name='',$dest='')
7501 $interval = 3600; 7517 $interval = 3600;
7502 if ($handle = opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) { 7518 if ($handle = opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) {
7503 while (false !== ($file = readdir($handle))) { 7519 while (false !== ($file = readdir($handle))) {
7504 if (!is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { // mPDF 5.4.19 7520 if (!is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".") && (substr($file, 0, 1) !== '.') && ($file !='dummy.txt')) { // mPDF 5.7
7505 unlink(_MPDF_TEMP_PATH.$file); 7521 unlink(_MPDF_TEMP_PATH.$file);
7506 } 7522 }
7507 } 7523 }
@@ -7576,7 +7592,7 @@ function _puthtmlheaders() {
7576 else { $pntstr = ''; } 7592 else { $pntstr = ''; }
7577 $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg} 7593 $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg}
7578 $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb} 7594 $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb}
7579 $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); 7595 $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7
7580 7596
7581 $this->HTMLheaderPageLinks = array(); 7597 $this->HTMLheaderPageLinks = array();
7582 $this->HTMLheaderPageAnnots = array(); 7598 $this->HTMLheaderPageAnnots = array();
@@ -7602,7 +7618,7 @@ function _puthtmlheaders() {
7602 7618
7603 // Writes over the page background but behind any other output on page 7619 // Writes over the page background but behind any other output on page
7604 $os = preg_replace('/\\\\/','\\\\\\\\',$os); 7620 $os = preg_replace('/\\\\/','\\\\\\\\',$os);
7605 $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.date('jY').')/', "\n".$os."\n".'\\1', $this->pages[$n]); 7621 $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]);
7606 7622
7607 $lks = $this->HTMLheaderPageLinks; 7623 $lks = $this->HTMLheaderPageLinks;
7608 foreach($lks AS $lk) { 7624 foreach($lks AS $lk) {
@@ -7659,7 +7675,7 @@ function _puthtmlheaders() {
7659 else { $pntstr = ''; } 7675 else { $pntstr = ''; }
7660 $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg} 7676 $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg}
7661 $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb} 7677 $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb}
7662 $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); 7678 $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7
7663 7679
7664 7680
7665 $this->HTMLheaderPageLinks = array(); 7681 $this->HTMLheaderPageLinks = array();
@@ -7694,7 +7710,7 @@ function _puthtmlheaders() {
7694 $os .= $this->StopTransform(true)."\n"; 7710 $os .= $this->StopTransform(true)."\n";
7695 // Writes over the page background but behind any other output on page 7711 // Writes over the page background but behind any other output on page
7696 $os = preg_replace('/\\\\/','\\\\\\\\',$os); 7712 $os = preg_replace('/\\\\/','\\\\\\\\',$os);
7697 $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.date('jY').')/', "\n".$os."\n".'\\1', $this->pages[$n]); 7713 $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]);
7698 7714
7699 $lks = $this->HTMLheaderPageLinks; 7715 $lks = $this->HTMLheaderPageLinks;
7700 foreach($lks AS $lk) { 7716 foreach($lks AS $lk) {
@@ -7876,10 +7892,10 @@ function _putpages()
7876 $thispage=str_replace($this->aliasNbPgGpHex,$r,$thispage); 7892 $thispage=str_replace($this->aliasNbPgGpHex,$r,$thispage);
7877 7893
7878 } 7894 }
7879 $thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.date('jY').'\s*)/', " ", $thispage); 7895 $thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.$this->uniqstr.'\s*)/', " ", $thispage);
7880 $thispage = preg_replace('/(\s*___HEADER___MARKER'.date('jY').'\s*)/', " ", $thispage); 7896 $thispage = preg_replace('/(\s*___HEADER___MARKER'.$this->uniqstr.'\s*)/', " ", $thispage);
7881 $thispage = preg_replace('/(\s*___PAGE___START'.date('jY').'\s*)/', " ", $thispage); 7897 $thispage = preg_replace('/(\s*___PAGE___START'.$this->uniqstr.'\s*)/', " ", $thispage);
7882 $thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.date('jY').'\s*)/', " ", $thispage); 7898 $thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.$this->uniqstr.'\s*)/', " ", $thispage);
7883 7899
7884 //Page 7900 //Page
7885 $this->_newobj(); 7901 $this->_newobj();
@@ -7928,10 +7944,13 @@ function _putpages()
7928 } 7944 }
7929 7945
7930 $annotsnum = 0; 7946 $annotsnum = 0;
7947 $embeddedfiles = array(); // mPDF 5.7.2 /EmbeddedFiles
7948
7931 if (isset($this->PageLinks[$n])) { $annotsnum += count($this->PageLinks[$n]); } 7949 if (isset($this->PageLinks[$n])) { $annotsnum += count($this->PageLinks[$n]); }
7932/*-- ANNOTATIONS --*/ 7950/*-- ANNOTATIONS --*/
7933 if (isset($this->PageAnnots[$n])) { 7951 if (isset($this->PageAnnots[$n])) {
7934 foreach ($this->PageAnnots[$n] as $k => $pl) { 7952 foreach ($this->PageAnnots[$n] as $k => $pl) {
7953 if (!empty($pl['opt']['file'])) { $embeddedfiles[$annotsnum+1] = true ; } // mPDF 5.7.2 /EmbeddedFiles
7935 if (!empty($pl['opt']['popup']) || !empty($pl['opt']['file'])) { $annotsnum += 2 ; } 7954 if (!empty($pl['opt']['popup']) || !empty($pl['opt']['file'])) { $annotsnum += 2 ; }
7936 else { $annotsnum++; } 7955 else { $annotsnum++; }
7937 $this->PageAnnots[$n][$k]['pageobj'] = $this->n; 7956 $this->PageAnnots[$n][$k]['pageobj'] = $this->n;
@@ -7952,7 +7971,7 @@ function _putpages()
7952 if ($annotsnum || $formsnum) { 7971 if ($annotsnum || $formsnum) {
7953 $s = '/Annots [ '; 7972 $s = '/Annots [ ';
7954 for($i=0;$i<$annotsnum;$i++) { 7973 for($i=0;$i<$annotsnum;$i++) {
7955 $s .= ($annotid + $i) . ' 0 R '; 7974 if (!isset($embeddedfiles[$i])) { $s .= ($annotid + $i) . ' 0 R '; } // mPDF 5.7.2 /EmbeddedFiles
7956 } 7975 }
7957 $annotid += $annotsnum; 7976 $annotid += $annotsnum;
7958/*-- FORMS --*/ 7977/*-- FORMS --*/
@@ -7974,7 +7993,7 @@ function _putpages()
7974 $this->_putstream($p); 7993 $this->_putstream($p);
7975 $this->_out('endobj'); 7994 $this->_out('endobj');
7976 } 7995 }
7977 $this->_putannots($n); 7996 $this->_putannots(); // mPDF 5.7.2
7978 7997
7979 //Pages root 7998 //Pages root
7980 $this->offsets[1]=strlen($this->buffer); 7999 $this->offsets[1]=strlen($this->buffer);
@@ -7991,7 +8010,7 @@ function _putpages()
7991} 8010}
7992 8011
7993 8012
7994function _putannots($n) { 8013function _putannots() { // mPDF 5.7.2
7995 $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; 8014 $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
7996 $nb=$this->page; 8015 $nb=$this->page;
7997 for($n=1;$n<=$nb;$n++) 8016 for($n=1;$n<=$nb;$n++)
@@ -9752,7 +9771,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
9752 if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "JPG image may not use CMYK color space - ".$file." - (Image converted to RGB. NB This will alter the colour profile of the image.)"; } 9771 if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "JPG image may not use CMYK color space - ".$file." - (Image converted to RGB. NB This will alter the colour profile of the image.)"; }
9753 $im = @imagecreatefromstring($data); 9772 $im = @imagecreatefromstring($data);
9754 if ($im) { 9773 if ($im) {
9755 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; 9774 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
9756 imageinterlace($im, false); 9775 imageinterlace($im, false);
9757 $check = @imagepng($im, $tempfile); 9776 $check = @imagepng($im, $tempfile);
9758 if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse JPG(CMYK) image'); } 9777 if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse JPG(CMYK) image'); }
@@ -9857,7 +9876,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
9857 $w = imagesx($im); 9876 $w = imagesx($im);
9858 $h = imagesy($im); 9877 $h = imagesy($im);
9859 if ($im) { 9878 if ($im) {
9860 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; 9879 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
9861 // Alpha channel set 9880 // Alpha channel set
9862 if ($pngalpha) { 9881 if ($pngalpha) {
9863 if ($this->PDFA) { $this->Error("PDFA1-b does not permit images with alpha channel transparency (".$file.")."); } 9882 if ($this->PDFA) { $this->Error("PDFA1-b does not permit images with alpha channel transparency (".$file.")."); }
@@ -9865,24 +9884,18 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
9865 // generate gray scale pallete 9884 // generate gray scale pallete
9866 for ($c = 0; $c < 256; ++$c) { ImageColorAllocate($imgalpha, $c, $c, $c); } 9885 for ($c = 0; $c < 256; ++$c) { ImageColorAllocate($imgalpha, $c, $c, $c); }
9867 // extract alpha channel 9886 // extract alpha channel
9868 $gammacorr = 2.2; // gamma correction
9869 for ($xpx = 0; $xpx < $w; ++$xpx) { 9887 for ($xpx = 0; $xpx < $w; ++$xpx) {
9870 for ($ypx = 0; $ypx < $h; ++$ypx) { 9888 for ($ypx = 0; $ypx < $h; ++$ypx) {
9871 //$colorindex = imagecolorat($im, $xpx, $ypx);
9872 //$col = imagecolorsforindex($im, $colorindex);
9873 //$gamma2 = (pow((((127 - $col['alpha']) * 255 / 127) / 255), $gammacorr) * 255);
9874 $alpha = (imagecolorat($im, $xpx, $ypx) & 0x7F000000) >> 24; 9889 $alpha = (imagecolorat($im, $xpx, $ypx) & 0x7F000000) >> 24;
9890 // mPDF 5.7.2
9875 if ($alpha < 127) { 9891 if ($alpha < 127) {
9876 if ($alpha==0) { $gamma = 255; } 9892 imagesetpixel($imgalpha, $xpx, $ypx, (255-($alpha * 2)));
9877 else
9878 $gamma = (pow((((127 - $alpha) * 255 / 127) / 255), $gammacorr) * 255);
9879 imagesetpixel($imgalpha, $xpx, $ypx, $gamma);
9880 } 9893 }
9881 } 9894 }
9882 } 9895 }
9883 // create temp alpha file 9896 // create temp alpha file
9884 $tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.RAND(1,10000).'.png'; 9897 $tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.md5($file).RAND(1,10000).'.png';
9885 if (!is_writable($tempfile_alpha)) { 9898 if (!is_writable(_MPDF_TEMP_PATH)) { // mPDF 5.7.2
9886 ob_start(); 9899 ob_start();
9887 $check = @imagepng($imgalpha); 9900 $check = @imagepng($imgalpha);
9888 if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); } 9901 if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
@@ -9892,6 +9905,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
9892 ob_end_clean(); 9905 ob_end_clean();
9893 // extract image without alpha channel 9906 // extract image without alpha channel
9894 $imgplain = imagecreatetruecolor($w, $h); 9907 $imgplain = imagecreatetruecolor($w, $h);
9908 imagealphablending( $imgplain, false ); // mPDF 5.7.2
9895 imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h); 9909 imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
9896 // create temp image file 9910 // create temp image file
9897 $minfo = $this->_getImage($this->_tempimglnk, false); 9911 $minfo = $this->_getImage($this->_tempimglnk, false);
@@ -9918,6 +9932,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
9918 9932
9919 // extract image without alpha channel 9933 // extract image without alpha channel
9920 $imgplain = imagecreatetruecolor($w, $h); 9934 $imgplain = imagecreatetruecolor($w, $h);
9935 imagealphablending( $imgplain, false ); // mPDF 5.7.2
9921 imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h); 9936 imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
9922 9937
9923 // create temp image file 9938 // create temp image file
@@ -10040,7 +10055,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
10040 if (isset($gd['GIF Read Support']) && $gd['GIF Read Support']) { 10055 if (isset($gd['GIF Read Support']) && $gd['GIF Read Support']) {
10041 $im = @imagecreatefromstring($data); 10056 $im = @imagecreatefromstring($data);
10042 if ($im) { 10057 if ($im) {
10043 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; 10058 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
10044 imagealphablending($im, false); 10059 imagealphablending($im, false);
10045 imagesavealpha($im, false); 10060 imagesavealpha($im, false);
10046 imageinterlace($im, false); 10061 imageinterlace($im, false);
@@ -10171,7 +10186,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
10171 if (isset($gd['PNG Support']) && $gd['PNG Support']) { 10186 if (isset($gd['PNG Support']) && $gd['PNG Support']) {
10172 $im = @imagecreatefromstring($data); 10187 $im = @imagecreatefromstring($data);
10173 if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); } 10188 if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); }
10174 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; 10189 $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
10175 imagealphablending($im, false); 10190 imagealphablending($im, false);
10176 imagesavealpha($im, false); 10191 imagesavealpha($im, false);
10177 imageinterlace($im, false); 10192 imageinterlace($im, false);
@@ -10295,10 +10310,10 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
10295 $imgdata .= chr($r).chr($g).chr($b); 10310 $imgdata .= chr($r).chr($g).chr($b);
10296 } 10311 }
10297 if ($mask) { 10312 if ($mask) {
10298 $col = imagecolorsforindex($im, $rgb); 10313 // mPDF 5.7.2 Gamma correction
10299 $gammacorr = 2.2; // gamma correction 10314 $alpha = ($rgb & 0x7F000000) >> 24;
10300 $gamma = intval((pow((((127 - $col['alpha']) * 255 / 127) / 255), $gammacorr) * 255)); 10315 if ($alpha < 127) { $mimgdata .= chr(255-($alpha * 2)); }
10301 $mimgdata .= chr($gamma); 10316 else { $mimgdata .= chr(0); }
10302 } 10317 }
10303 } 10318 }
10304 } 10319 }
@@ -10316,7 +10331,7 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
10316 $minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png', 10331 $minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png',
10317 'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>'); 10332 'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
10318 if ($dpi) { $minfo['set-dpi'] = $dpi; } 10333 if ($dpi) { $minfo['set-dpi'] = $dpi; }
10319 $tempfile = '_tempImgPNG'.RAND(1,10000).'.png'; 10334 $tempfile = '_tempImgPNG'.md5($file).RAND(1,10000).'.png';
10320 $imgmask = count($this->images)+1; 10335 $imgmask = count($this->images)+1;
10321 $minfo['i']=$imgmask ; 10336 $minfo['i']=$imgmask ;
10322 $this->images[$tempfile] = $minfo; 10337 $this->images[$tempfile] = $minfo;
@@ -10408,7 +10423,7 @@ function file_get_contents_by_socket($url, &$data) {
10408 10423
10409function _imageTypeFromString(&$data) { 10424function _imageTypeFromString(&$data) {
10410 $type = ''; 10425 $type = '';
10411 if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif') { 10426 if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif' || substr($data, 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8 // mpDF 5.7.2
10412 $type = 'jpeg'; 10427 $type = 'jpeg';
10413 } 10428 }
10414 else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") { 10429 else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") {
@@ -11117,7 +11132,11 @@ function GetFullPath(&$path,$basepath='') {
11117 if (!$basepath) { $basepath = $this->basepath; } 11132 if (!$basepath) { $basepath = $this->basepath; }
11118 //Fix path value 11133 //Fix path value
11119 $path = str_replace("\\","/",$path); //If on Windows 11134 $path = str_replace("\\","/",$path); //If on Windows
11120 $path = preg_replace('/^\/\//','http://',$path); // mPDF 5.6.27 11135 // mPDF 5.7.2
11136 if (substr($path,0,2) == "//") {
11137 $tr = parse_url($basepath);
11138 $path = $tr['scheme'].':'.$path;
11139 }
11121 $regexp = '|^./|'; // Inadvertently corrects "./path/etc" and "//www.domain.com/etc" 11140 $regexp = '|^./|'; // Inadvertently corrects "./path/etc" and "//www.domain.com/etc"
11122 $path = preg_replace($regexp,'',$path); 11141 $path = preg_replace($regexp,'',$path);
11123 11142
@@ -11138,7 +11157,10 @@ function GetFullPath(&$path,$basepath='') {
11138 else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link 11157 else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link
11139 if (substr($path,0,1) == "/") { 11158 if (substr($path,0,1) == "/") {
11140 $tr = parse_url($basepath); 11159 $tr = parse_url($basepath);
11141 $root = $tr['scheme'].'://'.$tr['host']; 11160 // mPDF 5.7.2
11161 $root = '';
11162 if (!empty($tr['scheme'])) { $root .= $tr['scheme'].'://'; }
11163 $root .= $tr['host'];
11142 $path = $root . $path; 11164 $path = $root . $path;
11143 } 11165 }
11144 else { $path = $basepath . $path; } 11166 else { $path = $basepath . $path; }
@@ -11350,7 +11372,7 @@ function Header($content='') {
11350 if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) { 11372 if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) {
11351 $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']); 11373 $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']);
11352 $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd); 11374 $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd);
11353 $hd = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$hd); 11375 $hd = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$hd); // mPDF 5.7
11354 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; } 11376 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; }
11355 else { $hff = $this->original_default_font; } 11377 else { $hff = $this->original_default_font; }
11356 if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; } 11378 if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; }
@@ -11421,10 +11443,24 @@ function Header($content='') {
11421 11443
11422/*-- TABLES --*/ 11444/*-- TABLES --*/
11423function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',$horf = 'H',$level, $firstSpread=true, $finalSpread=true) { 11445function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',$horf = 'H',$level, $firstSpread=true, $finalSpread=true) {
11424 if(($horf=='H' || $horf=='F') && !empty($content) && !empty($content[0])) { // mPDF 5.6.61 11446 if(($horf=='H' || $horf=='F') && !empty($content)) { // mPDF 5.7.2
11425 $table = &$this->table[1][1]; 11447 $table = &$this->table[1][1];
11426 // Advance down page by half width of top border
11427 11448
11449 // mPDF 5.7.2
11450 if ($horf=='F') { // Table Footer
11451 $firstrow = count($table['cells']) - $table['footernrows'];
11452 $lastrow = count($table['cells']) - 1;
11453 }
11454 else { // Table Header
11455 $firstrow = 0;
11456 $lastrow = $table['headernrows'] - 1;
11457 }
11458 if(empty($content[$firstrow])) {
11459 if ($this->debug) { $this->Error("&lt;tfoot&gt; must precede &lt;tbody&gt; in a table"); }
11460 else { return; }
11461 }
11462
11463 // Advance down page by half width of top border
11428 if ($horf=='H') { // Only if header 11464 if ($horf=='H') { // Only if header
11429 if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; } 11465 if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; }
11430 else { $adv = $table['max_cell_border_width']['T'] /2 ; } 11466 else { $adv = $table['max_cell_border_width']['T'] /2 ; }
@@ -11438,14 +11474,6 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
11438 } 11474 }
11439 } 11475 }
11440 11476
11441 if ($horf=='F') { // Table Footer
11442 $firstrow = count($table['cells']) - $table['footernrows'];
11443 $lastrow = count($table['cells']) - 1;
11444 }
11445 else { // Table Header
11446 $firstrow = 0;
11447 $lastrow = $table['headernrows'] - 1;
11448 }
11449 11477
11450 $topy = $content[$firstrow][0]['y']-$this->y; 11478 $topy = $content[$firstrow][0]['y']-$this->y;
11451 11479
@@ -12054,7 +12082,7 @@ function _getHtmlHeight($html) {
12054 $html = str_replace('{PAGENO}',$this->pagenumPrefix.$this->docPageNum($this->page).$this->pagenumSuffix,$html); 12082 $html = str_replace('{PAGENO}',$this->pagenumPrefix.$this->docPageNum($this->page).$this->pagenumSuffix,$html);
12055 $html = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->docPageNumTotal($this->page).$this->nbpgSuffix,$html ); 12083 $html = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->docPageNumTotal($this->page).$this->nbpgSuffix,$html );
12056 $html = str_replace($this->aliasNbPg,$this->page,$html ); 12084 $html = str_replace($this->aliasNbPg,$this->page,$html );
12057 $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); 12085 $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7
12058 $this->HTMLheaderPageLinks = array(); 12086 $this->HTMLheaderPageLinks = array();
12059 $this->HTMLheaderPageAnnots = array(); 12087 $this->HTMLheaderPageAnnots = array();
12060 $this->HTMLheaderPageForms = array(); 12088 $this->HTMLheaderPageForms = array();
@@ -12064,6 +12092,10 @@ function _getHtmlHeight($html) {
12064 $this->writingHTMLheader = false; 12092 $this->writingHTMLheader = false;
12065 $h = ($this->y - $this->margin_header); 12093 $h = ($this->y - $this->margin_header);
12066 $this->Reset(); 12094 $this->Reset();
12095 // mPDF 5.7.2 - Clear in case Float used in Header/Footer
12096 $this->blk[0]['blockContext'] = 0;
12097 $this->blk[0]['float_endpos'] = 0;
12098
12067 $this->pageoutput[$this->page] = array(); 12099 $this->pageoutput[$this->page] = array();
12068 $this->headerbuffer = ''; 12100 $this->headerbuffer = '';
12069 $this->pageBackgrounds = $savepb; 12101 $this->pageBackgrounds = $savepb;
@@ -12489,7 +12521,7 @@ function Footer() {
12489 if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) { 12521 if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) {
12490 $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']); 12522 $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']);
12491 $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd); 12523 $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd);
12492 $hd = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$hd); 12524 $hd = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$hd); // mPDF 5.7
12493 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; } 12525 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; }
12494 else { $hff = $this->original_default_font; } 12526 else { $hff = $this->original_default_font; }
12495 if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; } 12527 if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; }
@@ -12579,7 +12611,7 @@ function hardHyphenate($word, $maxWidth) {
12579 else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { 12611 else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
12580 $p = strpos($word, "-", $offset); 12612 $p = strpos($word, "-", $offset);
12581 } 12613 }
12582 if ($p !== false) { $poss[] = $p - count($poss); } 12614 if ($p !== false) { $poss[] = $p; } // mPDF 5.7.2
12583 else { break; } 12615 else { break; }
12584 $offset = $p+1; 12616 $offset = $p+1;
12585 } 12617 }
@@ -12634,7 +12666,9 @@ function softHyphenate($word, $maxWidth) {
12634 else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { 12666 else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
12635 $p = strpos($word, chr(173), $offset); 12667 $p = strpos($word, chr(173), $offset);
12636 } 12668 }
12637 if ($p !== false) { $poss[] = $p - count($poss); } 12669 // mPDF 5.7.2
12670 //if ($p !== false) { $poss[] = $p - count($poss); }
12671 if ($p !== false) { $poss[] = $p; }
12638 else { break; } 12672 else { break; }
12639 $offset = $p+1; 12673 $offset = $p+1;
12640 } 12674 }
@@ -13049,7 +13083,8 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
13049 $cnt += $this->SubstituteCharsMB($a, $i, $e); 13083 $cnt += $this->SubstituteCharsMB($a, $i, $e);
13050 } 13084 }
13051 if ($this->biDirectional) { // *RTL* 13085 if ($this->biDirectional) { // *RTL*
13052 $e = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $e); // *RTL* 13086 // mPDF 5.7+
13087 $e = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $e ); // *RTL*
13053 } // *RTL* 13088 } // *RTL*
13054 // Font-specific ligature substitution for Indic fonts 13089 // Font-specific ligature substitution for Indic fonts
13055 if (isset($this->CurrentFont['indic']) && $this->CurrentFont['indic']) $this->ConvertIndic($e); // *INDIC* 13090 if (isset($this->CurrentFont['indic']) && $this->CurrentFont['indic']) $this->ConvertIndic($e); // *INDIC*
@@ -13343,7 +13378,7 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
13343 if ($old_page != $new_page) { 13378 if ($old_page != $new_page) {
13344 $s = $this->PrintPageBackgrounds(); 13379 $s = $this->PrintPageBackgrounds();
13345 // Writes after the marker so not overwritten later by page background etc. 13380 // Writes after the marker so not overwritten later by page background etc.
13346 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 13381 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
13347 $this->pageBackgrounds = array(); 13382 $this->pageBackgrounds = array();
13348 $this->page = $new_page; 13383 $this->page = $new_page;
13349 $this->ResetMargins(); 13384 $this->ResetMargins();
@@ -14426,7 +14461,7 @@ function ClearFloats($clear, $blklvl=0) {
14426 if ($old_page != $new_page) { 14461 if ($old_page != $new_page) {
14427 $s = $this->PrintPageBackgrounds(); 14462 $s = $this->PrintPageBackgrounds();
14428 // Writes after the marker so not overwritten later by page background etc. 14463 // Writes after the marker so not overwritten later by page background etc.
14429 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 14464 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
14430 $this->pageBackgrounds = array(); 14465 $this->pageBackgrounds = array();
14431 $this->page = $new_page; 14466 $this->page = $new_page;
14432 } 14467 }
@@ -14924,8 +14959,8 @@ function OpenTag($tag,$attr)
14924 if (strpos($size,',')) { $size = explode(',',$size); } 14959 if (strpos($size,',')) { $size = explode(',',$size); }
14925 } 14960 }
14926 else { $size = 'D'; } 14961 else { $size = 'D'; }
14927 if (isset($attr['POS']) && $attr['POS']) { 14962 if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2
14928 $pos = $attr['POS']; 14963 $pos = $attr['POSITION'];
14929 if (strpos($pos,',')) { $pos = explode(',',$pos); } 14964 if (strpos($pos,',')) { $pos = explode(',',$pos); }
14930 } 14965 }
14931 else { $pos = 'P'; } 14966 else { $pos = 'P'; }
@@ -15273,7 +15308,7 @@ function OpenTag($tag,$attr)
15273 $this->meter = new meter(); 15308 $this->meter = new meter();
15274 $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high); 15309 $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
15275 //Save to local file 15310 //Save to local file
15276 $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.strtolower($tag).'.svg'; 15311 $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.strtolower($tag).'.svg';
15277 file_put_contents($srcpath, $svg); 15312 file_put_contents($srcpath, $svg);
15278 $orig_srcpath = $srcpath; 15313 $orig_srcpath = $srcpath;
15279 $this->GetFullPath($srcpath); 15314 $this->GetFullPath($srcpath);
@@ -17111,7 +17146,7 @@ function OpenTag($tag,$attr)
17111 if ($this->cacheTables) { 17146 if ($this->cacheTables) {
17112 $this->packTableData = true; // required for cacheTables 17147 $this->packTableData = true; // required for cacheTables
17113 $this->simpleTables = false; // Cannot co-exist with cacheTables 17148 $this->simpleTables = false; // Cannot co-exist with cacheTables
17114 $table['cache'] = _MPDF_TEMP_PATH.'_tempTblCache'.RAND(1,1000000).'.dat'; 17149 $table['cache'] = _MPDF_TEMP_PATH.'_tempTblCache'.uniqid(rand(1,100000),true).'.dat';
17115 $fh = fopen($table['cache'] , "wb") or $this->Error("When using cacheTables, you must have read/write access to cache files (".$table['cache'] .")"); 17150 $fh = fopen($table['cache'] , "wb") or $this->Error("When using cacheTables, you must have read/write access to cache files (".$table['cache'] .")");
17116 fwrite($fh, "\x00"); 17151 fwrite($fh, "\x00");
17117 fclose($fh); 17152 fclose($fh);
@@ -18237,10 +18272,7 @@ function OpenTag($tag,$attr)
18237 18272
18238function _getListStyle($ls) { 18273function _getListStyle($ls) {
18239 if (stristr($ls,'decimal')) { return '1'; } 18274 if (stristr($ls,'decimal')) { return '1'; }
18240/* CSS3 list-styles numeric (selected) + I added tamil 18275 else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$ls,$m)) {
18241arabic-indic | bengali | devanagari | gujarati | gurmukhi | kannada | malayalam | oriya | persian | telugu | thai | urdu
18242*/
18243 else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu)/i',$ls,$m)) {
18244 return strtolower(trim($m[1])); 18276 return strtolower(trim($m[1]));
18245 } 18277 }
18246 else if (stristr($ls,'lower-roman')) { return 'i'; } 18278 else if (stristr($ls,'lower-roman')) { return 'i'; }
@@ -18470,7 +18502,7 @@ function CloseTag($tag)
18470 if ($old_page != $new_page) { 18502 if ($old_page != $new_page) {
18471 $s = $this->PrintPageBackgrounds(); 18503 $s = $this->PrintPageBackgrounds();
18472 // Writes after the marker so not overwritten later by page background etc. 18504 // Writes after the marker so not overwritten later by page background etc.
18473 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 18505 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
18474 $this->pageBackgrounds = array(); 18506 $this->pageBackgrounds = array();
18475 $this->page = $new_page; 18507 $this->page = $new_page;
18476 $this->ResetMargins(); 18508 $this->ResetMargins();
@@ -18529,7 +18561,7 @@ function CloseTag($tag)
18529 // If width not set, here would need to adjust and output buffer 18561 // If width not set, here would need to adjust and output buffer
18530 $s = $this->PrintPageBackgrounds(); 18562 $s = $this->PrintPageBackgrounds();
18531 // Writes after the marker so not overwritten later by page background etc. 18563 // Writes after the marker so not overwritten later by page background etc.
18532 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 18564 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
18533 $this->pageBackgrounds = array(); 18565 $this->pageBackgrounds = array();
18534 $this->Reset(); 18566 $this->Reset();
18535 $this->pageoutput[$this->page] = array(); 18567 $this->pageoutput[$this->page] = array();
@@ -18561,7 +18593,7 @@ function CloseTag($tag)
18561 // If width not set, here would need to adjust and output buffer 18593 // If width not set, here would need to adjust and output buffer
18562 $s = $this->PrintPageBackgrounds(); 18594 $s = $this->PrintPageBackgrounds();
18563 // Writes after the marker so not overwritten later by page background etc. 18595 // Writes after the marker so not overwritten later by page background etc.
18564 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 18596 $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
18565 $this->pageBackgrounds = array(); 18597 $this->pageBackgrounds = array();
18566 $this->Reset(); 18598 $this->Reset();
18567 $this->pageoutput[$this->page] = array(); 18599 $this->pageoutput[$this->page] = array();
@@ -19834,6 +19866,19 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada
19834 $list_item_marker = $rnum . $this->list_number_suffix; 19866 $list_item_marker = $rnum . $this->list_number_suffix;
19835 $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, $cp),strlen($maxnum)).$this->list_number_suffix); 19867 $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, $cp),strlen($maxnum)).$this->list_number_suffix);
19836 break; 19868 break;
19869 case 'khmer':
19870 case 'cambodian':
19871 $cp = 0x17E0;
19872 $rnum = $this->dec2other($num, $cp);
19873 $list_item_marker = $rnum . $this->list_number_suffix;
19874 $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
19875 break;
19876 case 'lao':
19877 $cp = 0x0ED0;
19878 $rnum = $this->dec2other($num, $cp);
19879 $list_item_marker = $rnum . $this->list_number_suffix;
19880 $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(6, $cp),strlen($maxnum)).$this->list_number_suffix);
19881 break;
19837 default: 19882 default:
19838 if ($this->listDir == 'rtl') { $list_item_marker = $this->list_number_suffix . $num; } 19883 if ($this->listDir == 'rtl') { $list_item_marker = $this->list_number_suffix . $num; }
19839 else { $list_item_marker = $num . $this->list_number_suffix; } 19884 else { $list_item_marker = $num . $this->list_number_suffix; }
@@ -20643,10 +20688,10 @@ function _setBorderLine($b, $k=1) {
20643 $this->SetLineWidth($b['w']/$k); 20688 $this->SetLineWidth($b['w']/$k);
20644 $this->SetDColor($b['c']); 20689 $this->SetDColor($b['c']);
20645 if ($b['c'][0]==5) { // RGBa 20690 if ($b['c'][0]==5) { // RGBa
20646 $this->SetAlpha($b['c'][4], 'Normal', false, 'S')."\n"; 20691 $this->SetAlpha(ord($b['c'][4])/100, 'Normal', false, 'S')."\n"; // mPDF 5.7.2
20647 } 20692 }
20648 else if ($b['c'][0]==6) { // CMYKa 20693 else if ($b['c'][0]==6) { // CMYKa
20649 $this->SetAlpha($b['c'][5], 'Normal', false, 'S')."\n"; 20694 $this->SetAlpha(ord($b['c'][5])/100, 'Normal', false, 'S')."\n"; // mPDF 5.7.2
20650 } 20695 }
20651} 20696}
20652 20697
@@ -23767,7 +23812,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
23767 } 23812 }
23768 else { 23813 else {
23769 $wi = $c['miw'] - $wis; 23814 $wi = $c['miw'] - $wis;
23770 foreach ($list as $k) { $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; } 23815 foreach ($list as $k) { if (!isset($wc[$k]['w']) || !$wc[$k]['w']) $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; } // mPDF 5.7.2
23771 } 23816 }
23772 } 23817 }
23773 if ($c['maw'] > $was) { 23818 if ($c['maw'] > $was) {
@@ -25813,7 +25858,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
25813 } 25858 }
25814 } 25859 }
25815 25860
25816 if ($level==1) { $this->_out('___TABLE___BACKGROUNDS'.date('jY')); } 25861 if ($level==1) { $this->_out('___TABLE___BACKGROUNDS'.$this->uniqstr); }
25817 $tableheaderadj = 0; 25862 $tableheaderadj = 0;
25818 $tablefooteradj = 0; 25863 $tablefooteradj = 0;
25819 25864
@@ -26076,12 +26121,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
26076 if ($this->tableBackgrounds) { 26121 if ($this->tableBackgrounds) {
26077 $s = $this->PrintTableBackgrounds(); 26122 $s = $this->PrintTableBackgrounds();
26078 if ($this->bufferoutput) { 26123 if ($this->bufferoutput) {
26079 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->headerbuffer); 26124 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer);
26080 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->headerbuffer ); 26125 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer );
26081 } 26126 }
26082 else { 26127 else {
26083 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 26128 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
26084 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->pages[$this->page]); 26129 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]);
26085 } 26130 }
26086 $this->tableBackgrounds = array(); 26131 $this->tableBackgrounds = array();
26087 } 26132 }
@@ -26103,7 +26148,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
26103 26148
26104 $this->AddPage($this->CurOrientation); 26149 $this->AddPage($this->CurOrientation);
26105 26150
26106 $this->_out('___TABLE___BACKGROUNDS'.date('jY')); 26151 $this->_out('___TABLE___BACKGROUNDS'.$this->uniqstr);
26107 26152
26108 26153
26109 if ($this->tableClipPath ) { $this->_out($this->tableClipPath); } 26154 if ($this->tableClipPath ) { $this->_out($this->tableClipPath); }
@@ -26972,16 +27017,16 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
26972 if ($this->tableBackgrounds && $level == 1) { 27017 if ($this->tableBackgrounds && $level == 1) {
26973 $s = $this->PrintTableBackgrounds(); 27018 $s = $this->PrintTableBackgrounds();
26974 if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) { 27019 if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) {
26975 $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->tablebuffer); 27020 $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->tablebuffer);
26976 if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->tablebuffer); } 27021 if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->tablebuffer); }
26977 } 27022 }
26978 else if ($this->bufferoutput) { 27023 else if ($this->bufferoutput) {
26979 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->headerbuffer); 27024 $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer);
26980 if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->headerbuffer ); } 27025 if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer ); }
26981 } 27026 }
26982 else { 27027 else {
26983 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); 27028 $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
26984 if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->pages[$this->page]); } 27029 if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]); }
26985 } 27030 }
26986 $this->tableBackgrounds = array(); 27031 $this->tableBackgrounds = array();
26987 } 27032 }
@@ -28108,14 +28153,9 @@ function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging
28108} 28153}
28109 28154
28110function TOC_Entry($txt, $level=0, $toc_id=0) { 28155function TOC_Entry($txt, $level=0, $toc_id=0) {
28111 $txt = $this->purify_utf8_text($txt); 28156 // mPDF 5.7.2
28112 if ($this->text_input_as_HTML) {
28113 $txt = $this->all_entities_to_utf8($txt);
28114 }
28115 if ($this->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mb_enc,'UTF-8'); }
28116 if ($this->ColActive) { $ily = $this->y0; } else { $ily = $this->y; } // use top of columns 28157 if ($this->ColActive) { $ily = $this->y0; } else { $ily = $this->y; } // use top of columns
28117 28158
28118 // mPDF 5.6.19 mPDF 5.6.25 mPDF 5.6.37
28119 if (!class_exists('tocontents', false)) { include(_MPDF_PATH.'classes/tocontents.php'); } 28159 if (!class_exists('tocontents', false)) { include(_MPDF_PATH.'classes/tocontents.php'); }
28120 if (empty($this->tocontents)) { $this->tocontents = new tocontents($this); } 28160 if (empty($this->tocontents)) { $this->tocontents = new tocontents($this); }
28121 $linkn = $this->AddLink(); 28161 $linkn = $this->AddLink();
@@ -28130,7 +28170,7 @@ function TOC_Entry($txt, $level=0, $toc_id=0) {
28130 28170
28131/*-- RTL --*/ 28171/*-- RTL --*/
28132 if ($this->biDirectional) { 28172 if ($this->biDirectional) {
28133 $txt = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $txt ); 28173 $txt = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $txt ); // mPDF 5.7+
28134 } 28174 }
28135/*-- END RTL --*/ 28175/*-- END RTL --*/
28136 if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; } 28176 if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
@@ -28556,7 +28596,7 @@ function IndexEntry($txt, $xref='') {
28556 if ($this->keep_block_together) { 28596 if ($this->keep_block_together) {
28557 if (isset($this->ktReference[$i]['t']) && $this->ktReference[$i]['t']==$txt){ 28597 if (isset($this->ktReference[$i]['t']) && $this->ktReference[$i]['t']==$txt){
28558 $Present=1; 28598 $Present=1;
28559 if (!in_array($this->page,$this->ktReference[$i]['p'])) { 28599 if ($this->page != $this->ktReference[$i]['op']) { // mPDF 5.7.2
28560 $this->ktReference[$i]['op'] = $this->page; 28600 $this->ktReference[$i]['op'] = $this->page;
28561 } 28601 }
28562 } 28602 }
@@ -28565,7 +28605,7 @@ function IndexEntry($txt, $xref='') {
28565 else if ($this->table_rotate) { 28605 else if ($this->table_rotate) {
28566 if (isset($this->tbrot_Reference[$i]['t']) && $this->tbrot_Reference[$i]['t']==$txt){ 28606 if (isset($this->tbrot_Reference[$i]['t']) && $this->tbrot_Reference[$i]['t']==$txt){
28567 $Present=1; 28607 $Present=1;
28568 if (!in_array($this->page,$this->tbrot_Reference[$i]['p'])) { 28608 if ($this->page != $this->tbrot_Reference[$i]['op']) { // mPDF 5.7.2
28569 $this->tbrot_Reference[$i]['op'] = $this->page; 28609 $this->tbrot_Reference[$i]['op'] = $this->page;
28570 } 28610 }
28571 } 28611 }
@@ -28573,7 +28613,7 @@ function IndexEntry($txt, $xref='') {
28573 else if ($this->kwt) { 28613 else if ($this->kwt) {
28574 if (isset($this->kwt_Reference[$i]['t']) && $this->kwt_Reference[$i]['t']==$txt){ 28614 if (isset($this->kwt_Reference[$i]['t']) && $this->kwt_Reference[$i]['t']==$txt){
28575 $Present=1; 28615 $Present=1;
28576 if (!in_array($this->page,$this->kwt_Reference[$i]['p'])) { 28616 if ($this->page != $this->kwt_Reference[$i]['op']) { // mPDF 5.7.2
28577 $this->kwt_Reference[$i]['op'] = $this->page; 28617 $this->kwt_Reference[$i]['op'] = $this->page;
28578 } 28618 }
28579 } 28619 }
@@ -28583,7 +28623,7 @@ function IndexEntry($txt, $xref='') {
28583 else if ($this->ColActive) { 28623 else if ($this->ColActive) {
28584 if (isset($this->col_Reference[$i]['t']) && $this->col_Reference[$i]['t']==$txt){ 28624 if (isset($this->col_Reference[$i]['t']) && $this->col_Reference[$i]['t']==$txt){
28585 $Present=1; 28625 $Present=1;
28586 if (!in_array($this->page,$this->col_Reference[$i]['p'])) { 28626 if ($this->page != $this->col_Reference[$i]['op']) { // mPDF 5.7.2
28587 $this->col_Reference[$i]['op'] = $this->page; 28627 $this->col_Reference[$i]['op'] = $this->page;
28588 } 28628 }
28589 } 28629 }
@@ -28719,7 +28759,7 @@ function CreateIndex($NbCol=1, $reffontsize='', $linespacing='', $offset=3, $use
28719/*-- RTL --*/ 28759/*-- RTL --*/
28720 // Change Arabic + Persian. to Presentation Forms 28760 // Change Arabic + Persian. to Presentation Forms
28721 if ($this->biDirectional) { 28761 if ($this->biDirectional) {
28722 $this->Reference[$i]['t'] = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $this->Reference[$i]['t'] ); 28762 $this->Reference[$i]['t'] = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $this->Reference[$i]['t'] ); // mPDF 5.7+
28723 } 28763 }
28724/*-- END RTL --*/ 28764/*-- END RTL --*/
28725 28765
@@ -29002,7 +29042,7 @@ function NewColumn() {
29002 29042
29003function printcolumnbuffer() { 29043function printcolumnbuffer() {
29004 // Columns ended (but page not ended) -> try to match all columns - unless disabled by using a custom column-break 29044 // Columns ended (but page not ended) -> try to match all columns - unless disabled by using a custom column-break
29005 if (!$this->ColActive && $this->ColumnAdjust && !$this->keepColumns) { 29045 if (!$this->ColActive && $this->ColumnAdjust && !$this->keepColumns) { // mPDF 5.7.2
29006 // Calculate adjustment to add to each column to calculate rel_y value 29046 // Calculate adjustment to add to each column to calculate rel_y value
29007 $this->ColDetails[0]['add_y'] = 0; 29047 $this->ColDetails[0]['add_y'] = 0;
29008 $last_col = 0; 29048 $last_col = 0;
@@ -29106,12 +29146,14 @@ function printcolumnbuffer() {
29106 $yadj = ($s['rel_y'] - $s['y']) - ($last_col_bottom)+$this->y0; 29146 $yadj = ($s['rel_y'] - $s['y']) - ($last_col_bottom)+$this->y0;
29107 // callback function 29147 // callback function
29108 $t = $s['s']; 29148 $t = $s['s'];
29109 $t = preg_replace('/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/e',"\$this->columnAdjustAdd('Td',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); 29149
29110 $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/e',"\$this->columnAdjustAdd('re',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4')",$t); 29150 // mPDF 5.7+
29111 $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) l/e',"\$this->columnAdjustAdd('l',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); 29151 $t = $this->columnAdjustPregReplace('Td', $xadj, $yadj, '/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/', $t);
29112 $t = preg_replace('/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/e',"\$this->columnAdjustAdd('img',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4','\\5')",$t); 29152 $t = $this->columnAdjustPregReplace('re', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/', $t);
29113 $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) m/e',"\$this->columnAdjustAdd('draw',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); 29153 $t = $this->columnAdjustPregReplace('l', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) l/', $t);
29114 $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/e',"\$this->columnAdjustAdd('bezier',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4','\\5','\\6')",$t); 29154 $t = $this->columnAdjustPregReplace('img', $xadj, $yadj, '/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/', $t);
29155 $t = $this->columnAdjustPregReplace('draw', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) m/', $t);
29156 $t = $this->columnAdjustPregReplace('bezier',$xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/', $t);
29115 29157
29116 $this->columnbuffer[$key]['s'] = $t; 29158 $this->columnbuffer[$key]['s'] = $t;
29117 $this->columnbuffer[$key]['newcol'] = $newcolumn; 29159 $this->columnbuffer[$key]['newcol'] = $newcolumn;
@@ -29466,6 +29508,16 @@ function printcolumnbuffer() {
29466 $this->breakpoints = array(); 29508 $this->breakpoints = array();
29467} 29509}
29468 29510
29511// mPDF 5.7+
29512function columnAdjustPregReplace($type, $xadj, $yadj, $pattern, $subject) {
29513 preg_match($pattern, $subject, $matches);
29514 if (!isset($matches[3])) { $matches[3] = 0; }
29515 if (!isset($matches[4])) { $matches[4] = 0; }
29516 if (!isset($matches[5])) { $matches[5] = 0; }
29517 if (!isset($matches[6])) { $matches[6] = 0; }
29518 return str_replace($matches[0], $this->columnAdjustAdd($type, _MPDFK, $xadj, $yadj, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]), $subject);
29519}
29520
29469/*-- END COLUMNS --*/ 29521/*-- END COLUMNS --*/
29470 29522
29471 29523
@@ -30127,6 +30179,11 @@ function reverse_letters($str) {
30127 return $this->mb_strrev($str, $this->mb_enc); 30179 return $this->mb_strrev($str, $this->mb_enc);
30128} 30180}
30129 30181
30182// mPDF 5.7+
30183function reverse_letters_preg_callback($matches) {
30184 return $this->reverse_letters($matches[1]);
30185}
30186
30130function magic_reverse_dir(&$chunk, $join=true, $dir) { 30187function magic_reverse_dir(&$chunk, $join=true, $dir) {
30131 if ($this->usingCoreFont) { return 0; } 30188 if ($this->usingCoreFont) { return 0; }
30132 if ($this->biDirectional) { 30189 if ($this->biDirectional) {
@@ -30136,7 +30193,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) {
30136 30193
30137 // Change Arabic + Persian. to Presentation Forms 30194 // Change Arabic + Persian. to Presentation Forms
30138 if ($join) { 30195 if ($join) {
30139 $chunk = preg_replace("/([".$pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $chunk ); 30196 $chunk = preg_replace_callback("/([".$pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $chunk ); // mPDF 5.7+
30140 } 30197 }
30141 $contains_rtl = false; 30198 $contains_rtl = false;
30142 $all_rtl = true; 30199 $all_rtl = true;
@@ -30196,7 +30253,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) {
30196 } 30253 }
30197 else { 30254 else {
30198 // Reverse numerals only to RTL 30255 // Reverse numerals only to RTL
30199 $sbit = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $sbit ); // mPDF 5.6.32 // mPDF 5.6.46 30256 $sbit = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $sbit ); // mPDF 5.7+
30200 $sbits[$sbitkey] = $sbit; 30257 $sbits[$sbitkey] = $sbit;
30201 } 30258 }
30202 } 30259 }
@@ -30208,7 +30265,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) {
30208 } 30265 }
30209 else { 30266 else {
30210 // Reverse numerals only to RTL 30267 // Reverse numerals only to RTL
30211 $bit = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $bit ); // mPDF 5.6.32 // mPDF 5.6.46 30268 $bit = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $bit ); // mPDF 5.7+
30212 $bits[$bitkey] = $bit; 30269 $bits[$bitkey] = $bit;
30213 } 30270 }
30214 } 30271 }
@@ -30219,7 +30276,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) {
30219 $contains_rtl = true; 30276 $contains_rtl = true;
30220 30277
30221 // Un-Reverse numerals back to ltr 30278 // Un-Reverse numerals back to ltr
30222 $chunk = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $chunk ); // mPDF 5.6.13 // mPDF 5.6.32 // mPDF 5.6.46 30279 $chunk = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $chunk ); // mPDF 5.7+
30223 if ($dir == 'rtl') { 30280 if ($dir == 'rtl') {
30224 if ($endSpace) { $chunk = ' '.$chunk; } 30281 if ($endSpace) { $chunk = ' '.$chunk; }
30225 if ($initSpace) { $chunk .= ' '; } 30282 if ($initSpace) { $chunk .= ' '; }
@@ -31193,7 +31250,7 @@ function AutoFont($html) {
31193 31250
31194/*-- CJK-FONTS --*/ 31251/*-- CJK-FONTS --*/
31195 if ($this->autoFontGroups & AUTOFONT_CJK) { 31252 if ($this->autoFontGroups & AUTOFONT_CJK) {
31196 $e = preg_replace("/([".$this->pregCJKchars.$extra."]*[".$this->pregCJKchars."][".$this->pregCJKchars.$extra."]*)/ue", '$this->replaceCJK(stripslashes(\'\\1\'))', $e); 31253 $e = preg_replace_callback("/([".$this->pregCJKchars .$extra."]*[".$this->pregCJKchars ."][".$this->pregCJKchars .$extra."]*)/u", array($this, 'replaceCJKPregCallback'), $e ); // mPDF 5.7+
31197 } 31254 }
31198/*-- END CJK-FONTS --*/ 31255/*-- END CJK-FONTS --*/
31199 31256
@@ -31202,7 +31259,7 @@ function AutoFont($html) {
31202 // HEBREW 31259 // HEBREW
31203 $e = preg_replace("/([".$this->pregHEBchars .$extra."]*[".$this->pregHEBchars ."][".$this->pregHEBchars .$extra."]*)/u", "\xef\xbf\xb0span lang=\"he\"\xef\xbf\xb1\\1\xef\xbf\xb0/span\xef\xbf\xb1", $e); 31260 $e = preg_replace("/([".$this->pregHEBchars .$extra."]*[".$this->pregHEBchars ."][".$this->pregHEBchars .$extra."]*)/u", "\xef\xbf\xb0span lang=\"he\"\xef\xbf\xb1\\1\xef\xbf\xb0/span\xef\xbf\xb1", $e);
31204 // All Arabic 31261 // All Arabic
31205 $e = preg_replace("/([".$this->pregARABICchars .$extra."]*[".$this->pregARABICchars ."][".$this->pregARABICchars .$extra."]*)/ue", '$this->replaceArabic(stripslashes(\'\\1\'))', $e); 31262 $e = preg_replace_callback("/([".$this->pregARABICchars .$extra."]*[".$this->pregARABICchars ."][".$this->pregARABICchars .$extra."]*)/u", array($this, 'replaceArabicPregCallback'), $e ); // mPDF 5.7+
31206 } 31263 }
31207/*-- END RTL --*/ 31264/*-- END RTL --*/
31208 31265
@@ -31279,6 +31336,11 @@ function replaceCJK($str) {
31279 } 31336 }
31280 return $str; 31337 return $str;
31281} 31338}
31339
31340// mPDF 5.7+
31341function replaceCJKPregCallback($matches) {
31342 return $this->replaceCJK(stripslashes($matches[1]));
31343}
31282/*-- END CJK-FONTS --*/ 31344/*-- END CJK-FONTS --*/
31283 31345
31284/*-- RTL --*/ 31346/*-- RTL --*/
@@ -31318,6 +31380,11 @@ function replaceArabic($str) {
31318 return $str; 31380 return $str;
31319} 31381}
31320 31382
31383// mPDF 5.7+
31384function replaceArabicPregCallback($matches) {
31385 return $this->replaceArabic(stripslashes($matches[1]));
31386}
31387
31321// ARABIC =========================== 31388// ARABIC ===========================
31322// mPDF 5.4.08 31389// mPDF 5.4.08
31323function InitArabic() { 31390function InitArabic() {
@@ -31616,6 +31683,11 @@ function ArabJoin($str) {
31616 return $s; 31683 return $s;
31617} 31684}
31618 31685
31686// mPDF 5.7+
31687function arabJoinPregCallback($matches) {
31688 return $this->ArabJoin(stripslashes($matches[1]));
31689}
31690
31619// mPDF 5.4.08 31691// mPDF 5.4.08
31620function get_arab_glyphs($char, $type) { 31692function get_arab_glyphs($char, $type) {
31621 if ($type>0 && isset($this->arabGlyphs[$char])) { 31693 if ($type>0 && isset($this->arabGlyphs[$char])) {
@@ -32061,7 +32133,7 @@ function AdjustHTML($html, $tabSpaces=8) {
32061 preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi); 32133 preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
32062 if (count($svgi[0])) { 32134 if (count($svgi[0])) {
32063 for($i=0;$i<count($svgi[0]);$i++) { 32135 for($i=0;$i<count($svgi[0]);$i++) {
32064 $file = _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.$i.'.svg'; 32136 $file = _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.$i.'.svg';
32065 //Save to local file 32137 //Save to local file
32066 file_put_contents($file, $svgi[0][$i]); 32138 file_put_contents($file, $svgi[0][$i]);
32067 $html = str_replace($svgi[0][$i], '<img src="'.$file.'" />', $html); // mPDF 5.5.18 32139 $html = str_replace($svgi[0][$i], '<img src="'.$file.'" />', $html); // mPDF 5.5.18
@@ -32137,12 +32209,14 @@ function AdjustHTML($html, $tabSpaces=8) {
32137 $iterator = 0; 32209 $iterator = 0;
32138 while($thereispre) //Recover <pre attributes>content</pre> 32210 while($thereispre) //Recover <pre attributes>content</pre>
32139 { 32211 {
32140 $temp[2][$iterator] = preg_replace("/^([^\n\t]*?)\t/me", "stripslashes('\\1') . str_repeat(' ', ( $tabSpaces - (mb_strlen(stripslashes('\\1')) % $tabSpaces)) )",$temp[2][$iterator]); 32212 $temp[2][$iterator] = preg_replace('/<([^a-zA-Z_:])/','&lt;\\1',$temp[2][$iterator]); // mPDF 5.7.2
32213 $temp[2][$iterator] = preg_replace_callback("/^([^\n\t]*?)\t/m", array($this, 'tabs2spaces_callback'), $temp[2][$iterator]); // mPDF 5.7+
32141 $temp[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp[2][$iterator]); 32214 $temp[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp[2][$iterator]);
32142 32215
32143 $temp[2][$iterator] = preg_replace('/\n/',"<br />",$temp[2][$iterator]); 32216 $temp[2][$iterator] = preg_replace('/\n/',"<br />",$temp[2][$iterator]);
32144 $temp[2][$iterator] = str_replace('\\',"\\\\",$temp[2][$iterator]); 32217 $temp[2][$iterator] = str_replace('\\',"\\\\",$temp[2][$iterator]);
32145 $html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.$temp[2][$iterator].'</erp>',$html,1); 32218 //$html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.$temp[2][$iterator].'</erp>',$html,1);
32219 $html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.str_replace('$','\$',$temp[2][$iterator]).'</erp>',$html,1); // mPDF 5.7+
32146 $thereispre--; 32220 $thereispre--;
32147 $iterator++; 32221 $iterator++;
32148 } 32222 }
@@ -32170,6 +32244,14 @@ function AdjustHTML($html, $tabSpaces=8) {
32170 32244
32171 return $html; 32245 return $html;
32172} 32246}
32247// mPDF 5.7+
32248function tabs2spaces_callback($matches) {
32249 return (stripslashes($matches[1]) . str_repeat(' ', $this->tabSpaces - (mb_strlen(stripslashes($matches[1])) % $this->tabSpaces)));
32250}
32251// mPDF 5.7+
32252function date_callback($matches) {
32253 return date($matches[1]);
32254}
32173 32255
32174/*-- LISTS --*/ 32256/*-- LISTS --*/
32175function dec2other($num, $cp) { 32257function dec2other($num, $cp) {