1. Go to this page and download the library: Download trianity/laravel-mpdf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
trianity / laravel-mpdf example snippets
use Trianity\LaravelMpdf\LaravelMpdfWrapper;
public function show(LaravelMpdfWrapper $pdf)
{
return $pdf->loadHTML('<h1>Hello</h1>')->output();
}
use Trianity\LaravelMpdf\Facades\PDF;
class ReportController
{
public function show()
{
$pdf = PDF::loadView('pdf.document', ['name' => 'World']);
$pdf->stream('document.pdf');
}
}
$pdf->output(); // Return the PDF as a string
$pdf->save($path); // Save the PDF and return $path
$pdf->download('document.pdf'); // Send it as a download
$pdf->stream('document.pdf'); // Send it inline
$pdf->getMpdf()->AddPage(); // Access the underlying mPDF instance
$pdf->WriteHTML('<p>More HTML</p>');