Laravel

Laravel package of RenderPDF.io

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

GitHub: https://github.com/renderpdf-io/renderpdf-laravel

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: RenderPdfOptions.php

Last updated