I got error in my Laravel controller that says syntax error, unexpected token "}", i have checked every line but couldn't identified the error reason.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Dompdf\Dompdf;
class WordController extends Controller
{
    public function importForm()
    {
        return view('import');
    }
    public function importWord(Request $request)
    {
        $file_path = $request->file('word_file')->getRealPath();
        try {
            $word = new COM("Word.Application") or die("Unable to instantiate Word");
            $word->Visible = 0;
            $word->Documents->Open($file_path);
            $content = $word->ActiveDocument->Content->Text;
            $word->Quit();
            $word = null;
            unset($word);
        } catch (Exception $e) {
            return redirect()->back()->with('error', 'An error occurred while importing the Word document');
        }
        $dompdf = new Dompdf();
        $dompdf->loadHtml($content);
        $dompdf->setPaper('A4', 'portrait');
        $dompdf->render();
        return $dompdf->stream();
        }
}
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire