Laravel Blade to PDF in Seconds

Swap out local wkhtmltopdf binaries for a hosted Worker. Laravel queues push HTML to the API, Stripe keeps billing aligned with usage, and operations teams receive polished PDFs instantly.

Framework · Laravel Language · PHP Use case · HTML to PDF Platform · Laravel Vapor

Launch Laravel PDFs in three steps

  1. Render your Blade template with data. Use `view()->render()` or Livewire’s HTML output to produce the markup you want to convert.
  2. Call the Worker from a queued job or controller. Use Laravel HTTP client with your API key stored in config. The Worker validates the key, enforces rate limits, and launches the browser renderer.
  3. Store and send the generated PDF. Save the binary to S3, attach it to a mail notification, or upload to your customer portal.

Laravel integration code

Drop this snippet into your project, replace `PDF_API_KEY`, and generate your first PDF. Pair it with the curl request for quick smoke tests.

$pdf = Http::withHeaders([
    'Authorization' => 'Bearer '.config('services.pdf.key'),
    'Content-Type' => 'application/json',
])->post('https://api.yourdomain.com/v1/render', [
    'html' => view('invoices.show', compact('invoice'))->render(),
    'options' => [
        'format' => 'Letter',
        'margin' => [
            'top' => '20mm',
            'bottom' => '20mm'
        ]
    ]
])->throw()->body();

Storage::disk('s3')->put("invoices/{$invoice->id}.pdf", $pdf);

Test with curl

curl -X POST https://api.yourdomain.com/v1/render \
  -H "authorization: Bearer ${PDF_API_KEY}" \
  -H "content-type: application/json" \
  -d '{"html":"

Invoice #512

Thanks!

"}' \ --output laravel-invoice.pdf

Common pitfalls & fixes

FAQ

How do I show usage inside my admin panel?

Call `/v1/usage` with the customer’s API key and display renders versus included quota.

Can I rotate API keys when a customer churns?

Yes. Hit the Stripe webhook `customer.subscription.deleted`, mark the key as canceled in KV, and prevent future renders.

Related guides