简体   繁体   中英

Laravel 5.3 pdf rendering issue with barryvdh/laravel-dompdf

Call to undefined method Barryvdh\\DomPDF\\PDF::setOrientation()

I am getting the above error on saving pdf.

 PDF::loadHTML($flight_plan_pdf_content)
   ->setPaper('a4')
   ->setOrientation('portrait')
   ->save($filePath . $fileName);

About mentioned is my code.

the same code is working with laravel 5.2 and "barryvdh/laravel-dompdf": "0.6.*",

Looking at barryvdh/laravel-dompdf I can see that this is correct call

setPaper($paper, $orientation = 'portrait')

so for your example it should be

 PDF::loadHTML($flight_plan_pdf_content)
   ->setPaper('a4')
   ->save($filePath . $fileName);

no need for setting portrait since it's default value.

EDIT: This is related to the latest 0.7 version. If you are using any other just add 'portrait' as the second parameter to the setPaper function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM