dompdf is unable to parse JavaScript. Inline script is for running PHP in the context of the PDF object only. If you need JS to run against the document prior to rendering to PDF you'll need to to it in your web browser then capture the body of the document and send it to dompdf.
Your other option is to use something like wkhtmltopdf, which is a fully functional web browser.
On Wednesday, December 19, 2012 4:57:55 AM UTC-5, Hari Kumar wrote:
Hello,
I have created a html page which has graph using HTML and Javascript. My script demanded to use inline jquery code within the body tag as my graph uses jquery library.I want this to be buffered and saved in pdf.But render skips the <script></script> tags inside the body of the HTML. Please help
<?php
require_once('dompdf_config.inc.php');
$html="<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<script type='text/javascript' src='http://localhost/highcharts/js/jquery.min.js'></script>
<script type='text/javascript' src='http://localhost/highcharts/js/highcharts.js'></script>
<script type='text/javascript' src='http://localhost/highcharts/js/modules/exporting.js'></script>
<script type='text/javascript' src='http://localhost/highcharts/js/themes/gray.js'></script>
<script type='text/php'>
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: '144',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
navigation: {
buttonOptions: {
align: 'right',
verticalAlign: 'top',
x: 10,
y: 50
}
},
title: {
align: 'left',
style:{
width: '600px'
},
text: '1.question1'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
exporting: {
enabled: false
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
{name: 'opt1:0',y: 0, color: '#6B8E23'},
{name: 'opt2:1',y: 1, color: '#1f1f1f'}
,
{name: 'opt3:0',y: 0, color: '#696969'}
]
}]
});
});
});
</script>
</head>
<body><p>Put your html here, or generate it with your favourite
templating system.</p>
<div name='144' id='144' style='min-width: auto; height: 400px; margin: 0 auto'></div><br>
</body>
</html>";
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream('sample.pdf');
?>