barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.74k stars 971 forks source link

Problem using ::loadView facade. #847

Open Iainthealer opened 2 years ago

Iainthealer commented 2 years ago

Hello.

I am using latest blank laravel installation on 7.4php as well as package v1.0.0 (beta). When I try to generate .pdf file I always get error: Error Using $this when not in object context

Barryvdh\DomPDF\PDF::loadView vendor/barryvdh/laravel-dompdf/src/PDF.php:142

public function loadView($view, $data = array(), $mergeData = array(), $encoding = null) { $html = $this->view->make($view, $data, $mergeData)->render(); // This is line 142 return $this->loadHTML($html, $encoding); }

Thank you!

Iainthealer commented 2 years ago

Fixed it my self. I was using wrong namespace.

Correct one was use Barryvdh\DomPDF\Facade as PDF;

barryvdh commented 2 years ago

Yes or Barryvdh\DomPDF\Facade\Pdf

Anum-Aamir commented 2 years ago

After using this i am getting this error. need help. (Call to a member function get_cellmap() on null)

AYB-CHA commented 2 years ago

Yes or Barryvdh\DomPDF\Facade\Pdf

No that dosen't work. the facade class is called Facade not Pdf like this. Barryvdh\DomPDF\Facade it's also wrong in the readme.

olaitan6201 commented 2 years ago

None of it is working, please work on it.

acgtwentyone commented 2 years ago

It's working fine with the latest version of laravel-dompdf (v1.0.2). Maybe you need to update the package.

// import
use Barryvdh\DomPDF\Facade\Pdf;
// usage
PDF::setPaper('a4', 'portrait')->loadView('your_view', $your_view_data)->save(storage_path('/dir') . '/' .  $filename);
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.