1. Go to this page and download the library: Download crushjs/mini-pdf 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/ */
use Crushjs\MiniPdf\Facades\MiniPdf;
MiniPdf::view('invoice', ['invoice' => $invoice]); // Blade view
MiniPdf::html('<h1>Hello</h1>'); // raw HTML
MiniPdf::file(resource_path('templates/letter.html'));
// or the helper
pdf('invoice', ['invoice' => $invoice]);
pdf()->html('<h1>Hello</h1>');
// From a controller: just return it (shown inline in the browser)
return MiniPdf::view('invoice', $data)->name('invoice-001');
$pdf->download('invoice.pdf'); // force download
$pdf->stream('invoice.pdf'); // show in browser
$pdf->save(storage_path('app/a.pdf')); // local path
$pdf->save('invoices/a.pdf', disk: 's3'); // filesystem disk
$pdf->render(); // raw bytes
$pdf->base64(); // e.g. for email/API payloads
use Crushjs\MiniPdf\Enums\Orientation;
use Crushjs\MiniPdf\Enums\Paper;
$pdf->paper(Paper::A4) // A3, A4, A5, Letter, Legal
->paper('Letter', Orientation::Landscape)
->paper([80, 200]) // custom size in mm (e.g. receipts)
->landscape() // or ->portrait()
->margins(10) // CSS shorthand, in mm
->margins(top: 20, right: 10)
->font('dejavusans', 12);