laravel-dompdf icon indicating copy to clipboard operation
laravel-dompdf copied to clipboard

Problem using ::loadView facade.

Open Iainthealer opened this issue 3 years ago • 7 comments

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 avatar Jan 06 '22 07:01 Iainthealer

Fixed it my self. I was using wrong namespace.

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

Iainthealer avatar Jan 06 '22 07:01 Iainthealer

Yes or Barryvdh\DomPDF\Facade\Pdf

barryvdh avatar Jan 30 '22 09:01 barryvdh

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

Anum-Aamir avatar Mar 10 '22 08:03 Anum-Aamir

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.

ayb-cha avatar Mar 25 '22 16:03 ayb-cha

None of it is working, please work on it.

olaitan6201 avatar Jun 09 '22 23:06 olaitan6201

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

acgtwentyone avatar Jun 21 '22 17:06 acgtwentyone

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.

stale[bot] avatar Sep 21 '22 03:09 stale[bot]