【问题标题】:Laravel Dompdf - Maximum execution time of 30 seconds exceededLaravel Dompdf - 超过 30 秒的最大执行时间
【发布时间】:2021-08-26 15:23:18
【问题描述】:

在我的 Laravel 应用程序中,我使用 DOMPDF 生成 pdf 文件。当我转换肖像发票时,它可以正常工作。当我在错误 Frame.php 中超过 30 秒的最大执行时间(第 0 行)

转换横向发票时其显示

我的控制器代码是:

return \PDF::loadView('pdf/invoice', compact('salesinvoiceData','companyData','salesitemsData'))->setPaper('a4', 'landscape')->setWarnings(false)->download($salesinvoiceData->id.'.pdf');

【问题讨论】:

  • 看起来你有大文件要转换成 pdf

标签: php laravel laravel-5.3 laravel-5.4 dompdf


【解决方案1】:

我认为包含 css & js 是生成 pdf 时加载缓慢的原因。

这是我之前的代码:

@extends('layouts.master')
@section('content')
test
@endsection

删除@extends 后问题修复

test

【讨论】:

    【解决方案2】:

    您可以增加最大执行时间:

    set_time_limit(300); // Extends to 5 minutes.
    
    // Then return the PDF
    return \PDF::loadView(/* ... */)->download($salesinvoiceData->id.'.pdf');;
    

    请参阅:Fatal error: Maximum execution time of 30 seconds exceeded 了解更多信息。

    【讨论】:

    • @Karthik 解决了您的问题吗?
    • 60 秒就够了
    猜你喜欢
    • 2014-01-20
    • 2018-08-31
    • 2018-08-01
    • 1970-01-01
    • 2013-04-01
    • 2013-11-16
    • 2019-04-07
    • 2011-05-02
    • 1970-01-01
    相关资源
    最近更新 更多