【发布时间】:2021-10-26 00:23:36
【问题描述】:
我有一个刀片,可以将 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 文件吗?
【问题讨论】:
标签: javascript php laravel laravel-5