Unable to convert word doc to pdf using LibreOffice with Laravel

Viewed 380

I'm quite new to laravel, having an issue trying to convert a word doc to pdf via localhost on a MAC with LibreOffice. In the UI when I click download I get an error message saying pdf file does not exist.

I can manually generate a pdf via terminal with:

soffice --headless --convert-to pdf:writer_pdf_Export Invoice_6.doc

But when I use the code below for the application, the application returns Invoice_6.pdf file does not exist and sometimes I get a time-out response:

   $fullStoragePath = storage_path('app/' . $filename . '.doc');
     $response = exec("soffice --headless --convert-to pdf:writer_pdf_Export --outdir $this->outdir $fullStoragePath");
        Log::info($response);
            return storage_path('app/' . $filename . '.pdf');
0 Answers
Related