| Server IP : 20.75.53.88 / Your IP : 216.73.217.72 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/apitce/dev/mpdf/examples/ |
Upload File : |
<?php
define('_MPDF_URI','../');
define('_MPDF_PATH', '../');
include("../mpdf.php");
$mpdf=new mPDF('');
if (strpos($_REQUEST['bodydata'],'id%3D%22MathJax_SVG_Hidden%22')===false) {
die("Hacking attempt");
}
$html = $_POST['bodydata'];
$html = urldecode($html);
preg_match('/<svg[^>]*>\s*(<defs.*?>.*?<\/defs>)\s*<\/svg>/',$html,$m);
$defs = $m[1];
$html = preg_replace('/<svg[^>]*>\s*<defs.*?<\/defs>\s*<\/svg>/','',$html);
$html = preg_replace('/(<svg[^>]*>)/',"\\1".$defs,$html);
preg_match_all('/<svg([^>]*)style="(.*?)"/',$html,$m);
for ($i=0;$i<count($m[0]);$i++) {
$style=$m[2][$i];
preg_match('/width: (.*?);/',$style, $wr);
$w = $mpdf->ConvertSize($wr[1],0,$mpdf->FontSize) * $mpdf->dpi/25.4;
preg_match('/height: (.*?);/',$style, $hr);
$h = $mpdf->ConvertSize($hr[1],0,$mpdf->FontSize) * $mpdf->dpi/25.4;
$replace = '<svg'.$m[1][$i].' width="'.$w.'" height="'.$h.'" style="'.$m[2][$i].'"';
$html = str_replace($m[0][$i],$replace,$html);
}
if ($_POST['PDF']=='PDF') {
//=====================================================
// ADD a stylesheet
$stylesheet = '
img { vertical-align: middle; }
.MathJax_SVG_Display { padding: 1em 0; }
#mpdf-create { display: none; }
h3 {
background-color: #EEEEEE;
padding: 0.5em;
border: 1px solid #8888FF;
font-family: sans-serif;
font-weight: bold;
font-size: 14pt;
}
';
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html);
$mpdf->Output();
//=====================================================
}
else {
//=====================================================
// To output SVG files readable by mPDF as text output
header('Content-type: text/plain');
preg_match_all('/<svg(.*?)<\/svg>/',$html,$m);
for ($i=0;$i<count($m[0]);$i++) {
$svg = $m[0][$i];
$svg = preg_replace('/>/',">\n",$svg); // Just add some new lines
echo $svg."\n\n";
}
//=====================================================
}
exit;
?>