PageRenderTime 28ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/mpdf/mpdf/classes/cssmgr.php

https://gitlab.com/Zinnurain/destination_finder_beta
PHP | 1226 lines | 1046 code | 74 blank | 106 comment | 594 complexity | 25bf4e3537b8f4a23b68054cda5c5a0b MD5 | raw file
  1. <?php
  2. class cssmgr {
  3. var $mpdf = null;
  4. var $tablecascadeCSS;
  5. var $cascadeCSS;
  6. var $CSS;
  7. var $tbCSSlvl;
  8. function cssmgr(&$mpdf) {
  9. $this->mpdf = $mpdf;
  10. $this->tablecascadeCSS = array();
  11. $this->CSS=array();
  12. $this->cascadeCSS = array();
  13. $this->tbCSSlvl = 0;
  14. }
  15. function ReadCSS($html) {
  16. preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
  17. for($i=0; $i<count($m[0]); $i++) {
  18. if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
  19. $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
  20. }
  21. }
  22. preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
  23. for($i=0; $i<count($m[0]); $i++) {
  24. if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
  25. $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
  26. }
  27. }
  28. // mPDF 5.5.02
  29. // Remove Comment tags <!-- ... --> inside CSS as <style> in HTML document
  30. // Remove Comment tags /* ... */ inside CSS as <style> in HTML document
  31. // But first, we replace upper and mixed case closing style tag with lower
  32. // case so we can use str_replace later.
  33. preg_replace('/<\/style>/i', '</style>', $html);
  34. preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
  35. if (count($m[1])) {
  36. for($i=0;$i<count($m[1]);$i++) {
  37. // Remove comment tags
  38. $sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
  39. $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
  40. $html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
  41. }
  42. }
  43. $html = preg_replace('/<!--mpdf/i','',$html);
  44. $html = preg_replace('/mpdf-->/i','',$html);
  45. $html = preg_replace('/<\!\-\-.*?\-\->/s',' ',$html);
  46. $match = 0; // no match for instance
  47. $regexp = ''; // This helps debugging: showing what is the REAL string being processed
  48. $CSSext = array();
  49. //CSS inside external files
  50. $regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
  51. $x = preg_match_all($regexp,$html,$cxt);
  52. if ($x) {
  53. $match += $x;
  54. $CSSext = $cxt[1];
  55. }
  56. $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
  57. $x = preg_match_all($regexp,$html,$cxt);
  58. if ($x) {
  59. $match += $x;
  60. $CSSext = array_merge($CSSext,$cxt[1]);
  61. }
  62. // look for @import stylesheets
  63. //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
  64. $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
  65. $x = preg_match_all($regexp,$html,$cxt);
  66. if ($x) {
  67. $match += $x;
  68. $CSSext = array_merge($CSSext,$cxt[1]);
  69. }
  70. // look for @import without the url()
  71. //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
  72. $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
  73. $x = preg_match_all($regexp,$html,$cxt);
  74. if ($x) {
  75. $match += $x;
  76. $CSSext = array_merge($CSSext,$cxt[1]);
  77. }
  78. $ind = 0;
  79. $CSSstr = '';
  80. if (!is_array($this->cascadeCSS)) $this->cascadeCSS = array();
  81. while($match){
  82. $path = $CSSext[$ind];
  83. $path = htmlspecialchars_decode($path); // mPDF 6
  84. $this->mpdf->GetFullPath($path);
  85. $CSSextblock = $this->mpdf->_get_file($path);
  86. if ($CSSextblock) {
  87. // look for embedded @import stylesheets in other stylesheets
  88. // and fix url paths (including background-images) relative to stylesheet
  89. //$regexpem = '/@import url\([\'\"]{0,1}(.*?\.css)[\'\"]{0,1}\)/si';
  90. $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
  91. $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
  92. $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
  93. if ($xem) {
  94. foreach($cxtem[1] AS $cxtembedded) {
  95. // path is relative to original stlyesheet!!
  96. $this->mpdf->GetFullPath($cxtembedded, $cssBasePath );
  97. $match++;
  98. $CSSext[] = $cxtembedded;
  99. }
  100. }
  101. $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
  102. $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
  103. if ($xem) {
  104. for ($i=0;$i<count($cxtem[0]);$i++) {
  105. // path is relative to original stlyesheet!!
  106. $embedded = $cxtem[2][$i];
  107. if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
  108. $this->mpdf->GetFullPath($embedded, $cssBasePath );
  109. $CSSextblock = preg_replace('/'.preg_quote($cxtem[0][$i],'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), $CSSextblock);
  110. }
  111. }
  112. }
  113. $CSSstr .= ' '.$CSSextblock;
  114. }
  115. $match--;
  116. $ind++;
  117. } //end of match
  118. $match = 0; // reset value, if needed
  119. // CSS as <style> in HTML document
  120. $regexp = '/<style.*?>(.*?)<\/style>/si';
  121. $match = preg_match_all($regexp,$html,$CSSblock);
  122. if ($match) {
  123. $tmpCSSstr = implode(' ',$CSSblock[1]);
  124. $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
  125. $xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
  126. if ($xem) {
  127. for ($i=0;$i<count($cxtem[0]);$i++) {
  128. $embedded = $cxtem[2][$i];
  129. if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
  130. $this->mpdf->GetFullPath($embedded);
  131. $tmpCSSstr = preg_replace('/'.preg_quote($cxtem[0][$i],'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), $tmpCSSstr );
  132. }
  133. }
  134. }
  135. $CSSstr .= ' '.$tmpCSSstr;
  136. }
  137. // Remove comments
  138. $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
  139. $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
  140. if (preg_match('/@media/',$CSSstr)) {
  141. preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
  142. for($i=0; $i<count($m[0]); $i++) {
  143. if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
  144. $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
  145. }
  146. else {
  147. $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/',' '.$m[2][$i].' ',$CSSstr);
  148. }
  149. }
  150. }
  151. // Replace any background: url(data:image... with temporary image file reference
  152. preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2
  153. if (count($idata[0])) {
  154. for($i=0;$i<count($idata[0]);$i++) {
  155. $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
  156. //Save to local file
  157. file_put_contents($file, base64_decode($idata[3][$i]));
  158. // $this->mpdf->GetFullPath($file); // ? is this needed - NO mPDF 5.6.03
  159. $CSSstr = str_replace($idata[0][$i], 'url("'.$file.'")', $CSSstr); // mPDF 5.5.17
  160. }
  161. }
  162. $CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',$CSSstr);
  163. // mPDF 5.7.4 URLs
  164. // Characters "(" ")" and ";" in url() e.g. background-image, cause problems parsing the CSS string
  165. // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ;
  166. // with a segment delimiter in the URI)
  167. $tempmarker = '%ZZ';
  168. if (strpos($CSSstr,'url(')!==false) {
  169. preg_match_all( '/url\(\"(.*?)\"\)/', $CSSstr, $m);
  170. for($i = 0; $i < count($m[1]) ; $i++) {
  171. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  172. $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
  173. }
  174. preg_match_all( '/url\(\'(.*?)\'\)/', $CSSstr, $m);
  175. for($i = 0; $i < count($m[1]) ; $i++) {
  176. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  177. $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
  178. }
  179. preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $CSSstr, $m);
  180. for($i = 0; $i < count($m[1]) ; $i++) {
  181. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  182. $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
  183. }
  184. }
  185. if ($CSSstr ) {
  186. $classproperties = array(); // mPDF 6
  187. preg_match_all('/(.*?)\{(.*?)\}/',$CSSstr,$styles);
  188. for($i=0; $i < count($styles[1]) ; $i++) {
  189. // SET array e.g. $classproperties['COLOR'] = '#ffffff';
  190. $stylestr= trim($styles[2][$i]);
  191. $stylearr = explode(';',$stylestr);
  192. foreach($stylearr AS $sta) {
  193. if (trim($sta)) {
  194. // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
  195. $tmp = explode(':',$sta,2);
  196. $property = $tmp[0];
  197. if (isset($tmp[1])) { $value = $tmp[1]; }
  198. else { $value = ''; }
  199. $value = str_replace($tempmarker,';',$value); // mPDF 5.7.4 URLs
  200. $property = trim($property);
  201. $value = preg_replace('/\s*!important/i','',$value);
  202. $value = trim($value);
  203. if ($property && ($value || $value==='0')) {
  204. // Ignores -webkit-gradient so doesn't override -moz-
  205. if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) {
  206. continue;
  207. }
  208. $classproperties[strtoupper($property)] = $value;
  209. }
  210. }
  211. }
  212. $classproperties = $this->fixCSS($classproperties);
  213. $tagstr = strtoupper(trim($styles[1][$i]));
  214. $tagarr = explode(',',$tagstr);
  215. $pageselectors = false; // used to turn on $this->mpdf->mirrorMargins
  216. foreach($tagarr AS $tg) {
  217. // mPDF 5.7.4
  218. if (preg_match('/NTH-CHILD\((\s*(([\-+]?\d*)N(\s*[\-+]\s*\d+)?|[\-+]?\d+|ODD|EVEN)\s*)\)/',$tg,$m) ) {
  219. $tg = preg_replace('/NTH-CHILD\(.*\)/', 'NTH-CHILD('.str_replace(' ','',$m[1]).')', $tg);
  220. }
  221. $tags = preg_split('/\s+/',trim($tg));
  222. $level = count($tags);
  223. $t = '';
  224. $t2 = '';
  225. $t3 = '';
  226. if (trim($tags[0])=='@PAGE') {
  227. if (isset($tags[0])) { $t = trim($tags[0]); }
  228. if (isset($tags[1])) { $t2 = trim($tags[1]); }
  229. if (isset($tags[2])) { $t3 = trim($tags[2]); }
  230. $tag = '';
  231. if ($level==1) { $tag = $t; }
  232. else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) {
  233. $tag = $t.'>>PSEUDO>>'.$m[1];
  234. if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
  235. }
  236. else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
  237. else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) {
  238. $tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1];
  239. if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
  240. }
  241. if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
  242. else if ($tag) { $this->CSS[$tag] = $classproperties; }
  243. }
  244. else if ($level == 1) { // e.g. p or .class or #id or p.class or p#id
  245. if (isset($tags[0])) { $t = trim($tags[0]); }
  246. if ($t) {
  247. $tag = '';
  248. if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; }
  249. else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; }
  250. else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector
  251. else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector
  252. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
  253. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
  254. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
  255. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector
  256. else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector
  257. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; }
  258. if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
  259. else if ($tag) { $this->CSS[$tag] = $classproperties; }
  260. }
  261. }
  262. else {
  263. $tmp = array();
  264. for($n=0;$n<$level;$n++) {
  265. if (isset($tags[$n])) { $t = trim($tags[$n]); }
  266. else { $t = ''; }
  267. if ($t) {
  268. $tag = '';
  269. if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; }
  270. else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; }
  271. else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector
  272. else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector
  273. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
  274. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
  275. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
  276. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector
  277. else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector
  278. else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; }
  279. if ($tag) $tmp[] = $tag;
  280. else { break; }
  281. }
  282. }
  283. if ($tag) {
  284. $x = &$this->cascadeCSS;
  285. foreach($tmp AS $tp) { $x = &$x[$tp]; }
  286. $x = $this->array_merge_recursive_unique($x, $classproperties);
  287. $x['depth'] = $level;
  288. }
  289. }
  290. }
  291. if ($pageselectors) { $this->mpdf->mirrorMargins = true; }
  292. $properties = array();
  293. $values = array();
  294. $classproperties = array();
  295. }
  296. } // end of if
  297. //Remove CSS (tags and content), if any
  298. $regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
  299. $html = preg_replace($regexp,'',$html);
  300. //print_r($this->CSS); exit;
  301. //print_r($this->cascadeCSS); exit;
  302. return $html;
  303. }
  304. function readInlineCSS($html) {
  305. $html=htmlspecialchars_decode($html); // mPDF 5.7.4 URLs
  306. // mPDF 5.7.4 URLs
  307. // Characters "(" ")" and ";" in url() e.g. background-image, cause probems parsing the CSS string
  308. // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ;
  309. // with a segment delimiter in the URI)
  310. $tempmarker = '%ZZ';
  311. if (strpos($html,'url(')!==false) {
  312. preg_match_all( '/url\(\"(.*?)\"\)/', $html, $m);
  313. for($i = 0; $i < count($m[1]) ; $i++) {
  314. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  315. $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
  316. }
  317. preg_match_all( '/url\(\'(.*?)\'\)/', $html, $m);
  318. for($i = 0; $i < count($m[1]) ; $i++) {
  319. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  320. $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
  321. }
  322. preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $html, $m);
  323. for($i = 0; $i < count($m[1]) ; $i++) {
  324. $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
  325. $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
  326. }
  327. }
  328. //Fix incomplete CSS code
  329. $size = strlen($html)-1;
  330. if (substr($html,$size,1) != ';') $html .= ';';
  331. //Make CSS[Name-of-the-class] = array(key => value)
  332. $regexp = '|\\s*?(\\S+?):(.+?);|i';
  333. preg_match_all( $regexp, $html, $styleinfo);
  334. $properties = $styleinfo[1];
  335. $values = $styleinfo[2];
  336. //Array-properties and Array-values must have the SAME SIZE!
  337. $classproperties = array();
  338. for($i = 0; $i < count($properties) ; $i++) {
  339. // Ignores -webkit-gradient so doesn't override -moz-
  340. if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
  341. continue;
  342. }
  343. $values[$i] = str_replace($tempmarker,';',$values[$i]); // mPDF 5.7.4 URLs
  344. $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
  345. }
  346. return $this->fixCSS($classproperties);
  347. }
  348. function _fix_borderStr($bd) {
  349. preg_match_all("/\((.*?)\)/", $bd, $m);
  350. if (count($m[1])) {
  351. for($i=0;$i<count($m[1]);$i++) {
  352. $sub = preg_replace("/ /", "", $m[1][$i]);
  353. $bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd);
  354. }
  355. }
  356. $prop = preg_split('/\s+/',trim($bd));
  357. $w = 'medium';
  358. $c = '#000000';
  359. $s = 'none';
  360. if ( count($prop) == 1 ) {
  361. // solid
  362. if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
  363. // #000000
  364. else if (is_array($this->mpdf->ConvertColor($prop[0]))) { $c = $prop[0]; }
  365. // 1px
  366. else { $w = $prop[0]; }
  367. }
  368. else if (count($prop) == 2 ) {
  369. // 1px solid
  370. if (in_array($prop[1],$this->mpdf->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
  371. // solid #000000
  372. else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
  373. // 1px #000000
  374. else { $w = $prop[0]; $c = $prop[1]; }
  375. }
  376. else if ( count($prop) == 3 ) {
  377. // Change #000000 1px solid to 1px solid #000000 (proper)
  378. if (substr($prop[0],0,1) == '#') { $c = $prop[0]; $w = $prop[1]; $s = $prop[2]; }
  379. // Change solid #000000 1px to 1px solid #000000 (proper)
  380. else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
  381. // Change solid 1px #000000 to 1px solid #000000 (proper)
  382. else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
  383. $s = $prop[0]; $w = $prop[1]; $c = $prop[2];
  384. }
  385. else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
  386. }
  387. else { return ''; }
  388. $s = strtolower($s);
  389. return $w.' '.$s.' '.$c;
  390. }
  391. function fixCSS($prop) {
  392. if (!is_array($prop) || (count($prop)==0)) return array();
  393. $newprop = array();
  394. foreach($prop AS $k => $v) {
  395. if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
  396. $v = strtolower($v);
  397. }
  398. if ($k == 'FONT') {
  399. $s = trim($v);
  400. preg_match_all('/\"(.*?)\"/',$s,$ff);
  401. if (count($ff[1])) {
  402. foreach($ff[1] AS $ffp) {
  403. $w = preg_split('/\s+/',$ffp);
  404. $s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
  405. }
  406. }
  407. preg_match_all('/\'(.*?)\'/',$s,$ff);
  408. if (count($ff[1])) {
  409. foreach($ff[1] AS $ffp) {
  410. $w = preg_split('/\s+/',$ffp);
  411. $s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
  412. }
  413. }
  414. $s = preg_replace('/\s*,\s*/',',',$s);
  415. $bits = preg_split('/\s+/',$s);
  416. if (count($bits)>1) {
  417. $k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
  418. $fs = $bits[(count($bits)-2)];
  419. if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
  420. $newprop['FONT-SIZE'] = $fsp[1];
  421. $newprop['LINE-HEIGHT'] = $fsp[2];
  422. }
  423. else { $newprop['FONT-SIZE'] = $fs; }
  424. if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
  425. else { $newprop['FONT-STYLE'] = 'normal'; }
  426. if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
  427. else { $newprop['FONT-WEIGHT'] = 'normal'; }
  428. if (preg_match('/small-caps/i',$s)) { $newprop['TEXT-TRANSFORM'] = 'uppercase'; }
  429. }
  430. }
  431. else if ($k == 'FONT-FAMILY') {
  432. $aux_fontlist = explode(",",$v);
  433. $found = 0;
  434. foreach($aux_fontlist AS $f) {
  435. $fonttype = trim($f);
  436. $fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
  437. $fonttype = preg_replace('/ /','',$fonttype);
  438. $v = strtolower(trim($fonttype));
  439. if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
  440. if ((!$this->mpdf->onlyCoreFonts && in_array($v,$this->mpdf->available_unifonts)) ||
  441. in_array($v,array('ccourier','ctimes','chelvetica')) ||
  442. ($this->mpdf->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
  443. in_array($v, array('sjis','uhc','big5','gb'))) {
  444. $newprop[$k] = $v;
  445. $found = 1;
  446. break;
  447. }
  448. }
  449. if (!$found) {
  450. foreach($aux_fontlist AS $f) {
  451. $fonttype = trim($f);
  452. $fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
  453. $fonttype = preg_replace('/ /','',$fonttype);
  454. $v = strtolower(trim($fonttype));
  455. if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
  456. if (in_array($v,$this->mpdf->sans_fonts) || in_array($v,$this->mpdf->serif_fonts) || in_array($v,$this->mpdf->mono_fonts) ) {
  457. $newprop[$k] = $v;
  458. break;
  459. }
  460. }
  461. }
  462. }
  463. // mPDF 5.7.1
  464. else if ($k == 'FONT-VARIANT') {
  465. if (preg_match('/(normal|none)/',$v, $m)) { // mPDF 6
  466. $newprop['FONT-VARIANT-LIGATURES'] = $m[1];
  467. $newprop['FONT-VARIANT-CAPS'] = $m[1];
  468. $newprop['FONT-VARIANT-NUMERIC'] = $m[1];
  469. $newprop['FONT-VARIANT-ALTERNATES'] = $m[1];
  470. }
  471. else {
  472. if (preg_match_all('/(no-common-ligatures|\bcommon-ligatures|no-discretionary-ligatures|\bdiscretionary-ligatures|no-historical-ligatures|\bhistorical-ligatures|no-contextual|\bcontextual)/i',$v, $m)) {
  473. $newprop['FONT-VARIANT-LIGATURES'] = implode(' ',$m[1]);
  474. }
  475. if (preg_match('/(all-small-caps|\bsmall-caps|all-petite-caps|\bpetite-caps|unicase|titling-caps)/i',$v, $m)) {
  476. $newprop['FONT-VARIANT-CAPS'] = $m[1];
  477. }
  478. if (preg_match_all('/(lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)/i',$v, $m)) {
  479. $newprop['FONT-VARIANT-NUMERIC'] = implode(' ',$m[1]);
  480. }
  481. if (preg_match('/(historical-forms)/i',$v, $m)) {
  482. $newprop['FONT-VARIANT-ALTERNATES'] = $m[1];
  483. }
  484. }
  485. }
  486. else if ($k == 'MARGIN') {
  487. $tmp = $this->expand24($v);
  488. $newprop['MARGIN-TOP'] = $tmp['T'];
  489. $newprop['MARGIN-RIGHT'] = $tmp['R'];
  490. $newprop['MARGIN-BOTTOM'] = $tmp['B'];
  491. $newprop['MARGIN-LEFT'] = $tmp['L'];
  492. }
  493. /*-- BORDER-RADIUS --*/
  494. else if ($k == 'BORDER-RADIUS' || $k == 'BORDER-TOP-LEFT-RADIUS' || $k == 'BORDER-TOP-RIGHT-RADIUS' || $k == 'BORDER-BOTTOM-LEFT-RADIUS' || $k == 'BORDER-BOTTOM-RIGHT-RADIUS') {
  495. $tmp = $this->border_radius_expand($v,$k);
  496. if (isset($tmp['TL-H'])) $newprop['BORDER-TOP-LEFT-RADIUS-H'] = $tmp['TL-H'];
  497. if (isset($tmp['TL-V'])) $newprop['BORDER-TOP-LEFT-RADIUS-V'] = $tmp['TL-V'];
  498. if (isset($tmp['TR-H'])) $newprop['BORDER-TOP-RIGHT-RADIUS-H'] = $tmp['TR-H'];
  499. if (isset($tmp['TR-V'])) $newprop['BORDER-TOP-RIGHT-RADIUS-V'] = $tmp['TR-V'];
  500. if (isset($tmp['BL-H'])) $newprop['BORDER-BOTTOM-LEFT-RADIUS-H'] = $tmp['BL-H'];
  501. if (isset($tmp['BL-V'])) $newprop['BORDER-BOTTOM-LEFT-RADIUS-V'] = $tmp['BL-V'];
  502. if (isset($tmp['BR-H'])) $newprop['BORDER-BOTTOM-RIGHT-RADIUS-H'] = $tmp['BR-H'];
  503. if (isset($tmp['BR-V'])) $newprop['BORDER-BOTTOM-RIGHT-RADIUS-V'] = $tmp['BR-V'];
  504. }
  505. /*-- END BORDER-RADIUS --*/
  506. else if ($k == 'PADDING') {
  507. $tmp = $this->expand24($v);
  508. $newprop['PADDING-TOP'] = $tmp['T'];
  509. $newprop['PADDING-RIGHT'] = $tmp['R'];
  510. $newprop['PADDING-BOTTOM'] = $tmp['B'];
  511. $newprop['PADDING-LEFT'] = $tmp['L'];
  512. }
  513. else if ($k == 'BORDER') {
  514. if ($v == '1') { $v = '1px solid #000000'; }
  515. else { $v = $this->_fix_borderStr($v); }
  516. $newprop['BORDER-TOP'] = $v;
  517. $newprop['BORDER-RIGHT'] = $v;
  518. $newprop['BORDER-BOTTOM'] = $v;
  519. $newprop['BORDER-LEFT'] = $v;
  520. }
  521. else if ($k == 'BORDER-TOP') {
  522. $newprop['BORDER-TOP'] = $this->_fix_borderStr($v);
  523. }
  524. else if ($k == 'BORDER-RIGHT') {
  525. $newprop['BORDER-RIGHT'] = $this->_fix_borderStr($v);
  526. }
  527. else if ($k == 'BORDER-BOTTOM') {
  528. $newprop['BORDER-BOTTOM'] = $this->_fix_borderStr($v);
  529. }
  530. else if ($k == 'BORDER-LEFT') {
  531. $newprop['BORDER-LEFT'] = $this->_fix_borderStr($v);
  532. }
  533. else if ($k == 'BORDER-STYLE') {
  534. $e = $this->expand24($v);
  535. if (!empty($e)) {
  536. $newprop['BORDER-TOP-STYLE'] = $e['T'];
  537. $newprop['BORDER-RIGHT-STYLE'] = $e['R'];
  538. $newprop['BORDER-BOTTOM-STYLE'] = $e['B'];
  539. $newprop['BORDER-LEFT-STYLE'] = $e['L'];
  540. }
  541. }
  542. else if ($k == 'BORDER-WIDTH') {
  543. $e = $this->expand24($v);
  544. if (!empty($e)) {
  545. $newprop['BORDER-TOP-WIDTH'] = $e['T'];
  546. $newprop['BORDER-RIGHT-WIDTH'] = $e['R'];
  547. $newprop['BORDER-BOTTOM-WIDTH'] = $e['B'];
  548. $newprop['BORDER-LEFT-WIDTH'] = $e['L'];
  549. }
  550. }
  551. else if ($k == 'BORDER-COLOR') {
  552. $e = $this->expand24($v);
  553. if (!empty($e)) {
  554. $newprop['BORDER-TOP-COLOR'] = $e['T'];
  555. $newprop['BORDER-RIGHT-COLOR'] = $e['R'];
  556. $newprop['BORDER-BOTTOM-COLOR'] = $e['B'];
  557. $newprop['BORDER-LEFT-COLOR'] = $e['L'];
  558. }
  559. }
  560. else if ($k == 'BORDER-SPACING') {
  561. $prop = preg_split('/\s+/',trim($v));
  562. if (count($prop) == 1 ) {
  563. $newprop['BORDER-SPACING-H'] = $prop[0];
  564. $newprop['BORDER-SPACING-V'] = $prop[0];
  565. }
  566. else if (count($prop) == 2 ) {
  567. $newprop['BORDER-SPACING-H'] = $prop[0];
  568. $newprop['BORDER-SPACING-V'] = $prop[1];
  569. }
  570. }
  571. else if ($k == 'TEXT-OUTLINE') { // mPDF 5.6.07
  572. $prop = preg_split('/\s+/',trim($v));
  573. if (trim(strtolower($v)) == 'none' ) {
  574. $newprop['TEXT-OUTLINE'] = 'none';
  575. }
  576. else if (count($prop) == 2 ) {
  577. $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
  578. $newprop['TEXT-OUTLINE-COLOR'] = $prop[1];
  579. }
  580. else if (count($prop) == 3 ) {
  581. $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
  582. $newprop['TEXT-OUTLINE-COLOR'] = $prop[2];
  583. }
  584. }
  585. else if ($k == 'SIZE') {
  586. $prop = preg_split('/\s+/',trim($v));
  587. if (preg_match('/(auto|portrait|landscape)/',$prop[0])) {
  588. $newprop['SIZE'] = strtoupper($prop[0]);
  589. }
  590. else if (count($prop) == 1 ) {
  591. $newprop['SIZE']['W'] = $this->mpdf->ConvertSize($prop[0]);
  592. $newprop['SIZE']['H'] = $this->mpdf->ConvertSize($prop[0]);
  593. }
  594. else if (count($prop) == 2 ) {
  595. $newprop['SIZE']['W'] = $this->mpdf->ConvertSize($prop[0]);
  596. $newprop['SIZE']['H'] = $this->mpdf->ConvertSize($prop[1]);
  597. }
  598. }
  599. else if ($k == 'SHEET-SIZE') {
  600. $prop = preg_split('/\s+/',trim($v));
  601. if (count($prop) == 2 ) {
  602. $newprop['SHEET-SIZE'] = array($this->mpdf->ConvertSize($prop[0]), $this->mpdf->ConvertSize($prop[1]));
  603. }
  604. else {
  605. if(preg_match('/([0-9a-zA-Z]*)-L/i',$v,$m)) { // e.g. A4-L = A$ landscape
  606. $ft = $this->mpdf->_getPageFormat($m[1]);
  607. $format = array($ft[1],$ft[0]);
  608. }
  609. else { $format = $this->mpdf->_getPageFormat($v); }
  610. if ($format) { $newprop['SHEET-SIZE'] = array($format[0]/_MPDFK, $format[1]/_MPDFK); }
  611. }
  612. }
  613. else if ($k == 'BACKGROUND') {
  614. $bg = $this->parseCSSbackground($v);
  615. if ($bg['c']) { $newprop['BACKGROUND-COLOR'] = $bg['c']; }
  616. else { $newprop['BACKGROUND-COLOR'] = 'transparent'; }
  617. /*-- BACKGROUNDS --*/
  618. if ($bg['i']) {
  619. $newprop['BACKGROUND-IMAGE'] = $bg['i'];
  620. if ($bg['r']) { $newprop['BACKGROUND-REPEAT'] = $bg['r']; }
  621. if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
  622. }
  623. else { $newprop['BACKGROUND-IMAGE'] = ''; }
  624. /*-- END BACKGROUNDS --*/
  625. }
  626. /*-- BACKGROUNDS --*/
  627. else if ($k == 'BACKGROUND-IMAGE') {
  628. if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$v,$m)) {
  629. $newprop['BACKGROUND-IMAGE'] = $m[0];
  630. continue;
  631. }
  632. if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) {
  633. $newprop['BACKGROUND-IMAGE'] = $m[1];
  634. }
  635. else if (strtolower($v)=='none') { $newprop['BACKGROUND-IMAGE'] = ''; }
  636. }
  637. else if ($k == 'BACKGROUND-REPEAT') {
  638. if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) {
  639. $newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
  640. }
  641. }
  642. else if ($k == 'BACKGROUND-POSITION') {
  643. $s = $v;
  644. $bits = preg_split('/\s+/',trim($s));
  645. // These should be Position x1 or x2
  646. if (count($bits)==1) {
  647. if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
  648. else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
  649. else { $bg['p'] = $bits[0] . ' 50%'; }
  650. }
  651. else if (count($bits)==2) {
  652. // Can be either right center or center right
  653. if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
  654. $bg['p'] = $bits[1] . ' '.$bits[0];
  655. }
  656. else {
  657. $bg['p'] = $bits[0] . ' '.$bits[1];
  658. }
  659. }
  660. if ($bg['p']) {
  661. $bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
  662. $bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
  663. $bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
  664. if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
  665. $bg['p'] = false;
  666. }
  667. }
  668. if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
  669. }
  670. /*-- END BACKGROUNDS --*/
  671. else if ($k == 'IMAGE-ORIENTATION') {
  672. if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$v,$m)) {
  673. $angle = $m[1] + 0;
  674. if (strtolower($m[2])=='deg') { $angle = $angle; }
  675. else if (strtolower($m[2])=='grad') { $angle *= (360/400); }
  676. else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); }
  677. while($angle < 0) { $angle += 360; }
  678. $angle = ($angle % 360);
  679. $angle /= 90;
  680. $angle = round($angle) * 90;
  681. $newprop['IMAGE-ORIENTATION'] = $angle;
  682. }
  683. }
  684. else if ($k == 'TEXT-ALIGN') {
  685. if (preg_match('/["\'](.){1}["\']/i',$v,$m)) {
  686. $d = array_search($m[1],$this->mpdf->decimal_align);
  687. if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
  688. if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
  689. else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R
  690. }
  691. else if (preg_match('/["\'](\\\[a-fA-F0-9]{1,6})["\']/i',$v,$m)) {
  692. $utf8 = codeHex2utf(substr($m[1],1,6));
  693. $d = array_search($utf8,$this->mpdf->decimal_align);
  694. if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
  695. if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
  696. else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R
  697. }
  698. else { $newprop[$k] = $v; }
  699. }
  700. // mpDF 6 Lists
  701. else if ($k == 'LIST-STYLE') {
  702. if (preg_match('/none/i',$v,$m)) {
  703. $newprop['LIST-STYLE-TYPE'] = 'none';
  704. $newprop['LIST-STYLE-IMAGE'] = 'none';
  705. }
  706. if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao|cjk-decimal|hebrew)/i',$v,$m)) {
  707. $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
  708. }
  709. else if (preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) {
  710. $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
  711. }
  712. if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) {
  713. $newprop['LIST-STYLE-IMAGE'] = strtolower(trim($m[1]));
  714. }
  715. if (preg_match('/(inside|outside)/i',$v,$m)) {
  716. $newprop['LIST-STYLE-POSITION'] = strtolower(trim($m[1]));
  717. }
  718. }
  719. else {
  720. $newprop[$k] = $v;
  721. }
  722. }
  723. return $newprop;
  724. }
  725. function setCSSboxshadow($v) {
  726. $sh = array();
  727. $c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',$v,$x); // mPDF 5.6.05
  728. for($i=0; $i<$c; $i++) {
  729. $col = preg_replace('/,/','*',$x[0][$i]);
  730. $v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
  731. }
  732. $ss = explode(',',$v);
  733. foreach ($ss AS $s) {
  734. $new = array('inset'=>false, 'blur'=>0, 'spread'=>0);
  735. if (preg_match('/inset/i',$s)) { $new['inset'] = true; $s = preg_replace('/\s*inset\s*/','',$s); }
  736. $p = explode(' ',trim($s));
  737. if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
  738. if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
  739. if (isset($p[2])) {
  740. if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
  741. $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
  742. }
  743. else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
  744. if (isset($p[3])) {
  745. if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
  746. $new['spread'] = $this->mpdf->ConvertSize(trim($p[3]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
  747. }
  748. else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); }
  749. if (isset($p[4])) {
  750. $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[4]));
  751. }
  752. }
  753. }
  754. if (!$new['col']) { $new['col'] = $this->mpdf->ConvertColor('#888888'); }
  755. if (isset($new['y'])) { array_unshift($sh, $new); }
  756. }
  757. return $sh;
  758. }
  759. function setCSStextshadow($v) {
  760. $sh = array();
  761. $c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',$v,$x); // mPDF 5.6.05
  762. for($i=0; $i<$c; $i++) {
  763. $col = preg_replace('/,/','*',$x[0][$i]);
  764. $v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
  765. }
  766. $ss = explode(',',$v);
  767. foreach ($ss AS $s) {
  768. $new = array('blur'=>0);
  769. $p = explode(' ',trim($s));
  770. if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
  771. if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
  772. if (isset($p[2])) {
  773. if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
  774. $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl]['inner_width'],$this->mpdf->FontSize,false);
  775. }
  776. else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
  777. if (isset($p[3])) {
  778. $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3]));
  779. }
  780. }
  781. if (!isset($new['col']) || !$new['col']) { $new['col'] = $this->mpdf->ConvertColor('#888888'); }
  782. if (isset($new['y'])) { array_unshift($sh, $new); }
  783. }
  784. return $sh;
  785. }
  786. function parseCSSbackground($s) {
  787. $bg = array('c'=>false, 'i'=>false, 'r'=>false, 'p'=>false, );
  788. /*-- BACKGROUNDS --*/
  789. if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$s,$m)) {
  790. $bg['i'] = $m[0];
  791. }
  792. else
  793. /*-- END BACKGROUNDS --*/
  794. if (preg_match('/url\(/i',$s)) {
  795. // If color, set and strip it off
  796. // mPDF 5.6.05
  797. if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})\s+(url\(.*)/i',$s,$m)) {
  798. $bg['c'] = strtolower($m[1]);
  799. $s = $m[3];
  800. }
  801. /*-- BACKGROUNDS --*/
  802. if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) {
  803. $bg['i'] = $m[1];
  804. $s = strtolower($m[2]);
  805. if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',$s,$m)) {
  806. $bg['r'] = $m[1];
  807. }
  808. // Remove repeat, attachment (discarded) and also any inherit
  809. $s = preg_replace('/(repeat-x|repeat-y|no-repeat|repeat|scroll|fixed|inherit)/','',$s);
  810. $bits = preg_split('/\s+/',trim($s));
  811. // These should be Position x1 or x2
  812. if (count($bits)==1) {
  813. if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
  814. else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
  815. else { $bg['p'] = $bits[0] . ' 50%'; }
  816. }
  817. else if (count($bits)==2) {
  818. // Can be either right center or center right
  819. if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
  820. $bg['p'] = $bits[1] . ' '.$bits[0];
  821. }
  822. else {
  823. $bg['p'] = $bits[0] . ' '.$bits[1];
  824. }
  825. }
  826. if ($bg['p']) {
  827. $bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
  828. $bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
  829. $bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
  830. if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
  831. $bg['p'] = false;
  832. }
  833. }
  834. }
  835. /*-- END BACKGROUNDS --*/
  836. }
  837. else if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})/i',$s,$m)) { $bg['c'] = strtolower($m[1]); } // mPDF 5.6.05
  838. return ($bg);
  839. }
  840. function expand24($mp) {
  841. $prop = preg_split('/\s+/',trim($mp));
  842. if (count($prop) == 1 ) {
  843. return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
  844. }
  845. if (count($prop) == 2 ) {
  846. return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
  847. }
  848. if (count($prop) == 3 ) {
  849. return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
  850. }
  851. if (count($prop) == 4 ) {
  852. return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
  853. }
  854. return array();
  855. }
  856. /*-- BORDER-RADIUS --*/
  857. function border_radius_expand($val,$k) {
  858. $b = array();
  859. if ($k == 'BORDER-RADIUS') {
  860. $hv = explode('/',trim($val));
  861. $prop = preg_split('/\s+/',trim($hv[0]));
  862. if (count($prop)==1) {
  863. $b['TL-H'] = $b['TR-H'] = $b['BR-H'] = $b['BL-H'] = $prop[0];
  864. }
  865. else if (count($prop)==2) {
  866. $b['TL-H'] = $b['BR-H'] = $prop[0];
  867. $b['TR-H'] = $b['BL-H'] = $prop[1];
  868. }
  869. else if (count($prop)==3) {
  870. $b['TL-H'] = $prop[0];
  871. $b['TR-H'] = $b['BL-H'] = $prop[1];
  872. $b['BR-H'] = $prop[2];
  873. }
  874. else if (count($prop)==4) {
  875. $b['TL-H'] = $prop[0];
  876. $b['TR-H'] = $prop[1];
  877. $b['BR-H'] = $prop[2];
  878. $b['BL-H'] = $prop[3];
  879. }
  880. if (count($hv)==2) {
  881. $prop = preg_split('/\s+/',trim($hv[1]));
  882. if (count($prop)==1) {
  883. $b['TL-V'] = $b['TR-V'] = $b['BR-V'] = $b['BL-V'] = $prop[0];
  884. }
  885. else if (count($prop)==2) {
  886. $b['TL-V'] = $b['BR-V'] = $prop[0];
  887. $b['TR-V'] = $b['BL-V'] = $prop[1];
  888. }
  889. else if (count($prop)==3) {
  890. $b['TL-V'] = $prop[0];
  891. $b['TR-V'] = $b['BL-V'] = $prop[1];
  892. $b['BR-V'] = $prop[2];
  893. }
  894. else if (count($prop)==4) {
  895. $b['TL-V'] = $prop[0];
  896. $b['TR-V'] = $prop[1];
  897. $b['BR-V'] = $prop[2];
  898. $b['BL-V'] = $prop[3];
  899. }
  900. }
  901. else {
  902. $b['TL-V'] = $b['TL-H'];
  903. $b['TR-V'] = $b['TR-H'];
  904. $b['BL-V'] = $b['BL-H'];
  905. $b['BR-V'] = $b['BR-H'];
  906. }
  907. return $b;
  908. }
  909. // Parse 2
  910. $h = 0;
  911. $v = 0;
  912. $prop = preg_split('/\s+/',trim($val));
  913. if (count($prop)==1) { $h = $v = $val; }
  914. else { $h = $prop[0]; $v = $prop[1]; }
  915. if ($h==0 || $v==0) { $h = $v = 0; }
  916. if ($k == 'BORDER-TOP-LEFT-RADIUS') {
  917. $b['TL-H'] = $h;
  918. $b['TL-V'] = $v;
  919. }
  920. else if ($k == 'BORDER-TOP-RIGHT-RADIUS') {
  921. $b['TR-H'] = $h;
  922. $b['TR-V'] = $v;
  923. }
  924. else if ($k == 'BORDER-BOTTOM-LEFT-RADIUS') {
  925. $b['BL-H'] = $h;
  926. $b['BL-V'] = $v;
  927. }
  928. else if ($k == 'BORDER-BOTTOM-RIGHT-RADIUS') {
  929. $b['BR-H'] = $h;
  930. $b['BR-V'] = $v;
  931. }
  932. return $b;
  933. }
  934. /*-- END BORDER-RADIUS --*/
  935. function _mergeCSS($p, &$t) {
  936. // Save Cascading CSS e.g. "div.topic p" at this block level
  937. if (isset($p) && $p) {
  938. if ($t) {
  939. $t = $this->array_merge_recursive_unique($t, $p);
  940. }
  941. else { $t = $p; }
  942. }
  943. }
  944. // for CSS handling
  945. function array_merge_recursive_unique($array1, $array2) {
  946. $arrays = func_get_args();
  947. $narrays = count($arrays);
  948. $ret = $arrays[0];
  949. for ($i = 1; $i < $narrays; $i ++) {
  950. foreach ($arrays[$i] as $key => $value) {
  951. if (((string) $key) === ((string) intval($key))) { // integer or string as integer key - append
  952. $ret[] = $value;
  953. }
  954. else { // string key - merge
  955. if (is_array($value) && isset($ret[$key])) {
  956. $ret[$key] = $this->array_merge_recursive_unique($ret[$key], $value);
  957. }
  958. else {
  959. $ret[$key] = $value;
  960. }
  961. }
  962. }
  963. }
  964. return $ret;
  965. }
  966. function _mergeFullCSS($p, &$t, $tag, $classes, $id, $lang) { // mPDF 6
  967. if (isset($p[$tag])) { $this->_mergeCSS($p[$tag], $t); }
  968. // STYLESHEET CLASS e.g. .smallone{} .redletter{}
  969. foreach($classes AS $class) {
  970. if (isset($p['CLASS>>'.$class])) { $this->_mergeCSS($p['CLASS>>'.$class], $t); }
  971. }
  972. // STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd) td:nth-child(2n+1)
  973. if ($tag=='TR' && isset($p) && $p) {
  974. foreach($p AS $k=>$val) {
  975. if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
  976. $select = false;
  977. if ($tag=='TR') {
  978. $row = $this->mpdf->row;
  979. $thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0);
  980. $tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0);
  981. if ($this->mpdf->tabletfoot) { $row -= $thnr; }
  982. else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
  983. if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
  984. $select = $this->_nthchild($a, $row);
  985. }
  986. }
  987. else if ($tag=='TD' || $tag=='TH') {
  988. if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
  989. $select = $this->_nthchild($a, $this->mpdf->col);
  990. }
  991. }
  992. if ($select) {
  993. $this->_mergeCSS($p[$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $t);
  994. }
  995. }
  996. }
  997. }
  998. // STYLESHEET CLASS e.g. [lang=fr]{} or :lang(fr)
  999. if (isset($lang) && isset($p['LANG>>'.$lang])) {
  1000. $this->_mergeCSS($p['LANG>>'.$lang], $t);
  1001. }
  1002. // STYLESHEET CLASS e.g. #smallone{} #redletter{}
  1003. if (isset($id) && isset($p['ID>>'.$id])) {
  1004. $this->_mergeCSS($p['ID>>'.$id], $t);
  1005. }
  1006. // STYLESHEET CLASS e.g. .smallone{} .redletter{}
  1007. foreach($classes AS $class) {
  1008. if (isset($p[$tag.'>>CLASS>>'.$class])) { $this->_mergeCSS($p[$tag.'>>CLASS>>'.$class], $t); }
  1009. }
  1010. // STYLESHEET CLASS e.g. [lang=fr]{} or :lang(fr)
  1011. if (isset($lang) && isset($p[$tag.'>>LANG>>'.$lang])) {
  1012. $this->_mergeCSS($p[$tag.'>>LANG>>'.$lang], $t);
  1013. }
  1014. // STYLESHEET CLASS e.g. #smallone{} #redletter{}
  1015. if (isset($id) && isset($p[$tag.'>>ID>>'.$id])) {
  1016. $this->_mergeCSS($p[$tag.'>>ID>>'.$id], $t);
  1017. }
  1018. }
  1019. function setBorderDominance($prop, $val) {
  1020. if (isset($prop['BORDER-LEFT']) && $prop['BORDER-LEFT']) { $this->cell_border_dominance_L = $val; }
  1021. if (isset($prop['BORDER-RIGHT']) && $prop['BORDER-RIGHT']) { $this->cell_border_dominance_R = $val; }
  1022. if (isset($prop['BORDER-TOP']) && $prop['BORDER-TOP']) { $this->cell_border_dominance_T = $val; }
  1023. if (isset($prop['BORDER-BOTTOM']) && $prop['BORDER-BOTTOM']) { $this->cell_border_dominance_B = $val; }
  1024. }
  1025. function _set_mergedCSS(&$m, &$p, $d=true, $bd=false) {
  1026. if (isset($m)) {
  1027. if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
  1028. if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
  1029. if (is_array($m)) {
  1030. $p = array_merge($p,$m);
  1031. $this->_mergeBorders($p,$m);
  1032. }
  1033. }
  1034. }
  1035. }
  1036. function _mergeBorders(&$b, &$a) { // Merges $a['BORDER-TOP-STYLE'] to $b['BORDER-TOP'] etc.
  1037. foreach(array('TOP','RIGHT','BOTTOM','LEFT') AS $side) {
  1038. foreach(array('STYLE','WIDTH','COLOR') AS $el) {
  1039. if (isset($a['BORDER-'.$side.'-'.$el])) { // e.g. $b['BORDER-TOP-STYLE']
  1040. $s = trim($a['BORDER-'.$side.'-'.$el]);
  1041. if (isset($b['BORDER-'.$side])) { // e.g. $b['BORDER-TOP']
  1042. $p = trim($b['BORDER-'.$side]);
  1043. }
  1044. else { $p = ''; }
  1045. if ($el=='STYLE') {
  1046. if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 '.$s.' \\3', $p); }
  1047. else { $b['BORDER-'.$side] = '0px '.$s.' #000000'; }
  1048. }
  1049. else if ($el=='WIDTH') {
  1050. if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', $s.' \\2 \\3', $p); }
  1051. else { $b['BORDER-'.$side] = $s.' none #000000'; }
  1052. }
  1053. else if ($el=='COLOR') {
  1054. if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 \\2 '.$s, $p); }
  1055. else { $b['BORDER-'.$side] = '0px none '.$s; }
  1056. }
  1057. }
  1058. }
  1059. }
  1060. }
  1061. function MergeCSS($inherit,$tag,$attr) {
  1062. $p = array();
  1063. $zp = array();
  1064. $classes = array();
  1065. if (isset($attr['CLASS'])) {
  1066. $classes = preg_split('/\s+/',$attr['CLASS']);
  1067. }
  1068. if (!isset($attr['ID'])) { $attr['ID']=''; }
  1069. // mPDF 6
  1070. $shortlang = '';
  1071. if (!isset($attr['LANG'])) { $attr['LANG']=''; }
  1072. else {
  1073. $attr['LANG'] = strtolower($attr['LANG']);
  1074. if (strlen($attr['LANG']) == 5) {
  1075. $shortlang = substr($attr['LANG'],0,2);
  1076. }
  1077. }
  1078. //===============================================
  1079. /*-- TABLES --*/
  1080. // Set Inherited properties
  1081. if ($inherit == 'TOPTABLE') { // $tag = TABLE
  1082. //===============================================
  1083. // Save Cascading CSS e.g. "div.topic p" at this block level
  1084. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'])) {
  1085. $this->tablecascadeCSS[0] = $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'];
  1086. }
  1087. else {
  1088. $this->tablecascadeCSS[0] = $this->cascadeCSS;
  1089. }
  1090. }
  1091. //===============================================
  1092. // Set Inherited properties
  1093. if ($inherit == 'TOPTABLE' || $inherit == 'TABLE') {
  1094. //Cascade everything from last level that is not an actual property, or defined by current tag/attributes
  1095. if (isset($this->tablecascadeCSS[$this->tbCSSlvl-1]) && is_array($this->tablecascadeCSS[$this->tbCSSlvl-1])) {
  1096. foreach($this->tablecascadeCSS[$this->tbCSSlvl-1] AS $k=>$v) {
  1097. $this->tablecascadeCSS[$this->tbCSSlvl][$k] = $v;
  1098. }
  1099. }
  1100. $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID'], $attr['LANG']);
  1101. //===============================================
  1102. // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
  1103. //===============================================
  1104. // STYLESHEET TAG e.g. table
  1105. $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID'], $attr['LANG']);
  1106. //===============================================
  1107. }
  1108. /*-- END TABLES --*/
  1109. //===============================================
  1110. // Set Inherited properties
  1111. if ($inherit == 'BLOCK') {
  1112. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS']) && is_array($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'])) {
  1113. foreach($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'] AS $k=>$v) {
  1114. $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'][$k] = $v;
  1115. }
  1116. }
  1117. //===============================================
  1118. // Save Cascading CSS e.g. "div.topic p" at this block level
  1119. $this->_mergeFullCSS($this->cascadeCSS, $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID'], $attr['LANG']);
  1120. //===============================================
  1121. // Cascading forward CSS
  1122. //===============================================
  1123. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1])) {
  1124. $this->_mergeFullCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'], $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID'], $attr['LANG']);
  1125. }
  1126. //===============================================
  1127. // Block properties which are inherited
  1128. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['margin_collapse']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['margin_collapse']) { $p['MARGIN-COLLAPSE'] = 'COLLAPSE'; } // custom tag, but follows CSS principle that border-collapse is inherited
  1129. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']) { $p['LINE-HEIGHT'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']; }
  1130. // mPDF 6
  1131. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']) { $p['LINE-STACKING-STRATEGY'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']; }
  1132. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']) { $p['LINE-STACKING-SHIFT'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']; }
  1133. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) { $p['DIRECTION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']; }
  1134. // mPDF 6 Lists
  1135. if ($tag == 'LI') {
  1136. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']) { $p['LIST-STYLE-TYPE'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']; }
  1137. }
  1138. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']) { $p['LIST-STYLE-IMAGE'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']; }
  1139. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']) { $p['LIST-STYLE-POSITION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']; }
  1140. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['align']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['align']) {
  1141. if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
  1142. else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
  1143. else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
  1144. else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
  1145. }
  1146. if ($this->mpdf->ColActive || $this->mpdf->keep_block_together) {
  1147. if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
  1148. $cor = $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolorarray' ];
  1149. $p['BACKGROUND-COLOR'] = $this->mpdf->_colAtoString($cor);
  1150. }
  1151. }
  1152. if (isset($this