Lightpack PDF Service

A robust, extensible PDF generation API for Lightpack applications, featuring driver-based architecture, seamless storage integration, and full HTTP response support.

Features

Quick Start

1. Install Dompdf

composer require dompdf/dompdf

2. Basic Usage

$pdf = app('pdf');
$pdf->setTitle('Invoice')
    ->setAuthor('Lightpack')
    ->html('<h1>Invoice #123</h1>');

// Download
$pdf->download('invoice.pdf');

// Stream inline
$pdf->stream('invoice.pdf');

// Save to configured storage
$pdf->save('invoices/invoice-123.pdf');

API Reference

Set Metadata

$pdf->setMeta([
    'title' => 'Report',
    'author' => 'Admin',
    'subject' => 'Monthly',
    'keywords' => 'report, monthly, pdf',
]);

Render from HTML string or view template

$pdf->html('<h1>Hello</h1>');
$pdf->template('invoice', ['order' => $order]);

Add Pages

$pdf->addPage();

Download as Attachment

return $pdf->download('myfile.pdf');

Stream Inline

return $pdf->stream('myfile.pdf');

Save to Storage

$pdf->save('reports/2025-05-15/report.pdf');

Advanced: Access Driver Instance

$driver = $pdf->getDriver();
$dompdf = $driver->getInstance();
$dompdf->setPaper('A4', 'landscape');

Storage Integration

$pdf->save('public/invoices/invoice-123.pdf');
$url = app('storage')->url('public/invoices/invoice-123.pdf');