在HHVM中生成pdf不起作用

时间:2017-05-15 06:48:21

标签: laravel pdf laravel-5.2 hhvm phpwkhtmltopdf

我在我的ubuntu服务器上使用了nginx和hhvm,并且laravel中的mikehaertl/phpwkhtmltopdf包用于生成pdf,但是在HHVM中生成的pdf显示下面和我本地机器中的内容效果很好:

enter image description here

我的代码是:

  $logo = storage_path('logo/logo.jpg');
  $font = storage_path('fonts/IRRoya.ttf');
  $barcode = DNS2D::getBarcodePNG($order["registration_number"], "QRCODE",5,5);
  $date = jDateTime::strftime('Y-m-d H:i:s', strtotime($order['order_date']));
  $f_date = jDateTime::convertNumbers($date);
  $view =   view('bill.bill',compact('order','logo','font','barcode','f_date'));
  $pdf = new Pdf(array(
      'no-outline',
      'margin-top'    => 0,
      'margin-right'  => 0,
      'margin-bottom' => 0,
      'margin-left'   => 0,
      'disable-smart-shrinking',
      'commandOptions' => array(
          'useExec' => true,
          'procEnv' => array(
              'LANG' => 'fa_IR.utf-8',
          ),
      ),
    ));
    $pdf->addPage($view);
    $pdf->send();

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

  $logo = storage_path('logo/logo.jpg');
  $font = storage_path('fonts/IRRoya.ttf');
  $barcode = DNS2D::getBarcodePNG($order["registration_number"], "QRCODE",5,5);
  $date = jDateTime::strftime('Y-m-d H:i:s', strtotime($order['order_date']));
  $f_date = jDateTime::convertNumbers($date);
  $view =   view('bill.bill',compact('order','logo','font','barcode','f_date'));
  $pdf = new Pdf(array(
      'no-outline',
      'encoding' => 'UTF-8',
      'margin-top'    => 0,
      'margin-right'  => 0,
      'margin-bottom' => 0,
      'margin-left'   => 0,
      'disable-smart-shrinking',
      'commandOptions' => array(
          'useExec' => true,
          'procEnv' => array(
              'LANG' => 'fa_IR.utf-8',
          ),
      ),
    ));
    $pdf->addPage($view);
    $content = $pdf->toString();
    return response($content)->withHeaders([
            'Content-Type' => 'application/pdf',
            'Pragma' => 'public',
            'Content-disposition' => 'attachment; filename='.$order["registration_number"].'.pdf',
            'Content-Transfer-Encoding' => 'binary',
            'Content-Length' => strlen($content)
        ]);