# DocFast for Laravel Official Laravel integration for the [DocFast](https://docfast.dev) HTML/Markdown to PDF API. ## Installation ```bash composer require docfast/laravel ``` Add your API key to `.env`: ```env DOCFAST_API_KEY=df_pro_your_api_key ``` Publish the config (optional): ```bash php artisan vendor:publish --tag=docfast-config ``` ## Usage ### Via Facade ```php use DocFast\Laravel\Facades\DocFast; // HTML to PDF $pdf = DocFast::html('

Invoice

Total: €99.00

'); return response($pdf) ->header('Content-Type', 'application/pdf') ->header('Content-Disposition', 'inline; filename="invoice.pdf"'); ``` ### Via Dependency Injection ```php use DocFast\Client; class InvoiceController extends Controller { public function download(Client $docfast) { $pdf = $docfast->html(view('invoice')->render()); return response($pdf) ->header('Content-Type', 'application/pdf'); } } ``` ### Markdown to PDF ```php $pdf = DocFast::markdown('# Report\n\nGenerated at ' . now()); ``` ### URL to PDF ```php $pdf = DocFast::url('https://example.com'); ``` ### With PDF Options ```php use DocFast\PdfOptions; $options = new PdfOptions(); $options->format = 'Letter'; $options->landscape = true; $options->margin = ['top' => '20mm', 'bottom' => '20mm']; $pdf = DocFast::html($html, null, $options); ``` ### Headers and Footers ```php $options = new PdfOptions(); $options->displayHeaderFooter = true; $options->footerTemplate = '
Page
'; $options->margin = ['top' => '10mm', 'bottom' => '20mm']; $pdf = DocFast::html(view('report')->render(), null, $options); ``` ### Templates ```php $pdf = DocFast::renderTemplate('invoice', [ 'company' => 'Acme Corp', 'items' => [['name' => 'Widget', 'price' => 9.99]], ]); ``` ## Configuration ```php // config/docfast.php return [ 'api_key' => env('DOCFAST_API_KEY'), 'base_url' => env('DOCFAST_BASE_URL', 'https://docfast.dev'), 'timeout' => env('DOCFAST_TIMEOUT', 60), ]; ``` ## Links - [PHP SDK](../php/) — standalone PHP client - [Documentation](https://docfast.dev/docs) - [API Reference](https://docfast.dev/openapi.json) - [Get an API Key](https://docfast.dev)