RenderPDF.io
RenderPDF.ioGet Free API Key
  • RenderPDF.io
  • 🔋API Authentication
  • ⚡Rate Limiting
  • 📬Webhooks
  • ➕Usage Calculation
  • 📃Render PDFs
    • 🚀RenderPDF APIs
      • Sync mode
      • Async mode
    • 🖼️Template & Styling
    • 📔Best practices
  • 🛠️Libraries
    • PHP
    • Laravel
    • Node.JS / JavaScript
    • Python
Powered by GitBook
On this page
  • Requirement
  • Installation
  • Usage
  1. Libraries

Laravel

Laravel package of RenderPDF.io

PreviousPHPNextNode.JS / JavaScript

Last updated 9 months ago

We ship a Laravel package that provides easy integration with RenderPDF.io

GitHub:

Requirement

  • PHP 8.1 and above

  • Laravel 10 and above

Installation

composer install renderpdf-io/renderpdf-laravel

Note: for Laravel 10 users, you need to install GuzzleHTTP too.

Add the services.renderpdf-io.key config into your config/services.php (required):

// config/services.php

return [
    'renderpdf-io' => [
        'key' => env('RENDER_PDF_IO_API_KEY'),
    ],
];

Usage

Facade style

Simply use the RenderPdfIo facade

use RenderPdfIo\RenderPdfIo;
use RenderPdfIo\Services\RenderPdfOptions;

public function renderPdf()
{
    $fileUrl = RenderPdfIo::render(new RenderPdfOptions(
        htmlContent: '<p>This is a new PDF</p>',
    ));
}

Dependency Injection style

In case you want to use DI style, we got you:

use RenderPdfIo\Services\RenderPdfIoService;
use RenderPdfIo\Services\RenderPdfOptions;

class InvoiceController
{
    public function download(RenderPdfIoService $renderPdfService)
    {
        $fileUrl = $renderPdfService->render(new RenderPdfOptions(
            htmlContent: '<p>This is a new PDF using DI</p>',
        ));
    }
}

See all the available options here:

🛠️
https://github.com/renderpdf-io/renderpdf-laravel
RenderPdfOptions.php