【问题标题】:PDFMerger for Laravel - Cannot Run Script After Merge('browser')Laravel 的 PDFMerger - 合并后无法运行脚本(“浏览器”)
【发布时间】:2017-04-09 13:33:01
【问题描述】:
    $pdf = new \LynX39\LaraPdfMerger\PdfManage;

    $pdf->addPDF(storage_path('public/pdfTemp').'/myFile01.pdf', 'all');
    $pdf->addPDF(storage_path('public/pdfTemp').'/myFile02.pdf', 'all');

    $pdf->merge('browser', 'complete.pdf', 'L');

    // The code below is not running !! why??
    Storage::delete('pdfTemp/myFile01.pdf');
    Storage::delete('pdfTemp/myFile02.pdf');

根据上面的代码, 我将 PdfMerger 用于 PHP Laravel 框架...

问题出在代码后面

$pdf->merge('browser', 'complete.pdf', 'L');

并且该行下面的任何代码都不会运行。

为什么?

【问题讨论】:

    标签: php pdf merge


    【解决方案1】:

    终于解决了我的问题..

    只需按照下面的代码进行操作

    $pdf = new \LynX39\LaraPdfMerger\PdfManage;
    
    $pdf->addPDF(storage_path('public/pdfTemp').'/myFile01.pdf', 'all');
    $pdf->addPDF(storage_path('public/pdfTemp').'/myFile02.pdf', 'all');
    
    // Merge and return to STRING first, and store in $result variable
    $result = $pdf->merge('string', 'complete.pdf', 'L');
    
    // Deleting files
    Storage::delete('pdfTemp/myFile01.pdf');
    Storage::delete('pdfTemp/myFile02.pdf');
    
    //And finnaly get the string and Display to BROWSER as PDF
    header('Content-Type: application/pdf');
    echo $result;
    

    希望它能帮助其他人。

    【讨论】:

      猜你喜欢
      • 2014-08-10
      • 2014-09-15
      • 1970-01-01
      • 2019-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多