Skip to content

Instantly share code, notes, and snippets.

@shahali007
Created October 9, 2023 07:35
Show Gist options
  • Select an option

  • Save shahali007/162b03ff5fb54065a4587f0b4d092344 to your computer and use it in GitHub Desktop.

Select an option

Save shahali007/162b03ff5fb54065a4587f0b4d092344 to your computer and use it in GitHub Desktop.
Generate PDF using Laravel
# Install dependency 'https://github.com/barryvdh/laravel-dompdf'
composer require barryvdh/laravel-dompdf
# Add the file in providers 'config/app.php'
Barryvdh\DomPDF\ServiceProvider::class,
# In laravel controller use the code
use PDF;
public function generatePDF(){
$pdf = PDF::loadView('pdf');
return $pdf->download('sample.pdf');
}
# Use the following package to see exact HTML markup
# No need to import in providers
composer require carlos-meneses/laravel-mpdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment