Permission denied error encountered when using laravel-dompdf

213 Views Asked by At

hello guys im trying to save a docx file as a pdf and when i save it its give me an error

public function attr(Request $request)
    {
        // Validate the form data here as needed
    
        // Get the form data
        $title = $request->input('title');

 
        // Load the Word template
        $template = new TemplateProcessor(storage_path('app/public/docs/AR.docx'));
    
        // Replace placeholders with form data
        $template->setValue('title', $title);
    
        // Save the modified Word document
        $outputPathDocx = storage_path('app/public/docs/AR_' . uniqid() . '.docx');
        $template->saveAs($outputPathDocx);
    
        // Convert Word to PDF using Dompdf
        $outputPathPdf = storage_path('app/public/pdfs/attr/AR_' . uniqid() . '.pdf');
        $pdf = PDF::loadFile($outputPathDocx);
        $pdf->save($outputPathPdf);
    
        // to download the generated PDF:
        return response()->download($outputPathPdf, 'AR.pdf');
    }

but i got this problem

Permission denied on C:\Users\nourd\OneDrive\Desktop\dashboard\storage\app\public\docs\AR_6558f287364af.docx. The communication protocol is not supported.

in this LINE

$pdf = PDF::loadFile($outputPathDocx);

i try a lot to resolve this problem

0

There are 0 best solutions below