小编moh*_*h96的帖子

Snappy PDF 中未显示 Google 图表

我正在尝试加载图表,然后使用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)

wkhtmltopdf laravel laravel-snappy

8
推荐指数
1
解决办法
1414
查看次数

标签 统计

laravel ×1

laravel-snappy ×1

wkhtmltopdf ×1