javascript - Laravel 将生成的 Pdf 保存在队列中
问题描述
我有一个刀片,我将 Html 转换为 pdf 并将其保存在我的本地,然后我使用实时 URL 获取 pdf 并将其保存在我的本地然后我使用 laravel 库来合并两个 pdf,它会生成通过嵌入获得单个 pdf,它之前工作得很好,现在我有一个高质量的 pdf,它需要很长时间才能合并,因此,它需要一些时间并且它返回一个最大限制内存问题,
所以我试着在队列上做
这是我的代码
$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吗?
解决方案
您可以使用作业,并且无论何时保存数据都可以调用YourJob::dispatch()
推荐阅读
- java - 有没有办法更新pitclipse插件中使用的pitest版本?
- php - 我想从调用 Azure API 的“实体”获取域详细信息
- javascript - 无法在静态函数 ReactJs 中调用函数
- c# - 如何使用 for 循环编写 XML 文件以追加元素
- c++ - 在 openssl 中实施 ECIES 1363a-2004
- symfony - Symfony 3 缓存建立与 ezplatform
- c - union integer 成员返回 union 中的数据,而 float 则显示异常
- pandas - 查找熊猫中每个组中的值
- r - 在 R 中使用 voronoi 细分匹配点到节点
- tensorflow - TensorFlow 对象检测 API 微调检查点