首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel在队列中保存生成的Pdf

Laravel在队列中保存生成的Pdf
EN

Stack Overflow用户
提问于 2021-08-25 21:29:16
回答 1查看 159关注 0票数 1

我有一个刀片,在那里我将Html转换为pdf并将其保存在本地,然后我使用活动URL获取pdf并将其保存在我的本地,然后我使用laravel库合并这两个pdf,它将通过嵌入生成单个pdf,它之前工作得很好,现在我有一个高质量的pdf,它需要很多时间来合并,由于它需要一些时间,它会返回一个最大限制内存问题,

所以我试着排队

这是我的代码

代码语言:javascript
复制
 $ecg_link = 'https://storage.googleapis.com/staging.uk-production.appspot.com/test1111.pdf';
    
 $ecg_pdf = isset($ecg_link) ?  $ecg_link : '';

 if($ecg_pdf){
        $ecg_contents = file_get_contents($ecg_link);
    
        if (!File::exists(storage_path('app/public/screening/pdf'))){
            File::makeDirectory(storage_path('app/public/screening/pdf'), 0777, true, true);
        }

        \Storage::disk('public')->put('screening/pdf/'.$screening_id.'.pdf', $ecg_contents);
      
        $pdf = PDF::loadView('participants.test', 
         compact('participantdata','Allopurinol','stn_assetreview'));

        if (!File::exists(storage_path('app/public/screening/pdf/temporary-pdf'))){
            File::makeDirectory(storage_path('app/public/screening/pdf/temporary-pdf'), 0777, 
        true, true);
        }
        $pdf->save(storage_path('app/public/screening/pdf/temporary-pdf/'.$screening_id.'.pdf'));

        $pdfMerger = PDFMerger::init(); //Initialize the merger
        $pdfMerger->addPDF(storage_path('app/public/screening/pdf/temporary-pdf/'.$screening_id.'.pdf'), 'all');
        $pdfMerger->addPDF(storage_path('app/public/screening/pdf/'.$screening_id.'.pdf'), 'all' );
       

        $pdfMerger->merge();

        if (!File::exists(storage_path('app/public/screening/pdf/final-pdf'))){
            File::makeDirectory(storage_path('app/public/screening/pdf/final-pdf'), 0777, true, true);
        }
        $pdfMerger->save($screening_id.'.pdf', "download");

当我使用队列时,我无法下载excel,因为它在队列中,我有任何方法可以下载excel,否则我可以通过邮件发送这个pdf吗?

EN

回答 1

Stack Overflow用户

发布于 2021-08-25 22:08:16

您可以使用作业,无论何时保存数据,都可以调用YourJob::dispatch()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68930080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档