Support the ongoing development of Laravel.io →
Laravel Laravel.io
Last updated 1 year ago.

akibo liked this thread

1
moderator

Hello Zahidzee,

A view can be cast to a string, on that way you get the html. The HTML can used in a html to pdf class.

For the dompdf way, did you get a result for a small text? With that you can test if it is a problem with the content of your view or with dompdf in general.

What do you use for pdf snappy? The error you mention sounds like a missing configuration.

If you can share some code there is a bigger change that someone can help you.

0

Run the under-mentioned command to install DomPDF in Laravel 8.

composer require barryvdh/laravel-dompdf

<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Employee; use PDF; class EmployeeController extends Controller { // Display user data in view public function showEmployees(){ $employee = Employee::all(); return view('index', compact('employee')); } // Generate PDF public function createPDF() { // retreive all records from db $data = Employee::all(); // share data to view view()->share('employee',$data); $pdf = PDF::loadView('pdf_view', $data); // download PDF file with download method return $pdf->download('pdf_file.pdf'); } } Hope you helpful ..
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Zahid zahidzee Joined 24 Aug 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.