我正在尝试加载图表,然后使用Laravel-snappy将其转换为 PDF
这是我用来生成pdf的代码:
$pdf = SnappyPDF::loadView('report', []);
$pdf->setOption('enable-javascript', true);
$pdf->setOption('no-stop-slow-scripts', true);
$pdf->setOption('page-size', 'A4');
$pdf->setOption('lowquality', false);
$pdf->setOption('disable-smart-shrinking', true);
$pdf->setOption('images', true);
$pdf->setOption('window-status', 'ready');
$pdf->setOption('run-script', 'window.setTimeout(function(){window.status="ready";},5000);');
return $pdf->inline();
Run Code Online (Sandbox Code Playgroud)
这是 HTML/CSS report.blade.php:
<head>
<script src="http://www.gstatic.com/charts/loader.js"></script>
<script>
function init() {
google.charts.load('current', {packages: ['corechart']});
var interval = setInterval(function () {
if (google.visualization !== undefined && google.visualization.DataTable !== undefined
&& google.visualization.PieChart !== undefined) {
clearInterval(interval);
window.status = 'ready';
drawChart();
}
}, 100);
}
function drawChart() {
// Define the chart to be drawn.
var …Run Code Online (Sandbox Code Playgroud)