mercredi 25 août 2021

Laravel Save A Generated Pdf Inside A Queue

I have a blade where i converts Html to a pdf and save it on my local , then i am using a live url to get a pdf and save it on my local Then I am using a laravel library to merge both pdf's and it will generate a single pdf by embeding, It was working fine earlier, now I have a high-quality pdf where it takes much time to merge, due to it, it is takeing mome time and it returns a max limit memory issue,

so i tried to do it on Queue

this is my code

 $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");

when i use queue , i am unable to download the excel since its in queue , I sthere any way i can download the excel , else can i send this pdf over a mail ???

thank you



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3Bdk0VT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire