aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/libraries/mpdf/mpdf.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/3rdparty/libraries/mpdf/mpdf.php')
-rw-r--r--inc/3rdparty/libraries/mpdf/mpdf.php328
1 files changed, 205 insertions, 123 deletions
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) {