Skip to content

rapideinternet/gotenberg-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gotenberg for Laravel

This is a composer package to implement Gotenberg in Laravel.

Installation

Set up your composer.json like this:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rapideinternet/gotenberg-laravel.git"
        }
    ],
    "require": {
        ...
        "rapideinternet/gotenberg-laravel": "dev-development"
    },
}

Then run composer update to install the package.

Usage

If you want to edit any default configuration, publish the config file:

php artisan vendor:publish --provider="RapideInternet\\Gotenberg\\GotenbergServiceProvider" --tag=gotenberg

To connect your local development environment to the Gotenberg service, run:

kubectl -n shared-gotenberg port-forward services/gotenberg 3000:80

To connect your staging or production environment to the Gotenberg service,update your env to:

GOTENBERG_URL: gotenberg.shared-gotenberg.svc.cluster.local

Quick start (v8)

Resolve the client via the container and call any endpoint. Options can be overridden per call using enums.

use RapideInternet\Gotenberg\Gotenberg;
use RapideInternet\Gotenberg\Models\Options;
use RapideInternet\Gotenberg\Enums\PaperFormat;
use RapideInternet\Gotenberg\Enums\EmulatedMediaType;

$client = app(Gotenberg::class);

// Chromium: HTML (Options can be omitted)
$options = new Options([
    'format' => PaperFormat::A4->value,
    'printBackground' => true,
    'emulatedMediaType' => EmulatedMediaType::PRINT->value,
]);
$res = $client->chromiumHtml('<html><body>Hello</body></html>', $options);

// Chromium: URL
$res = $client->chromiumUrl('https://example.com');

// Chromium: Markdown
$res = $client->chromiumMarkdown('# Title');

// LibreOffice: Convert documents
$res = $client->libreofficeConvert([
    ['filename' => 'doc.docx', 'contents' => $binary],
]);

// PDF Engines: Merge PDFs
$res = $client->pdfMerge([
    ['filename' => 'a.pdf', 'contents' => $pdfA],
    ['filename' => 'b.pdf', 'contents' => $pdfB],
]);

// Or via Facade
use RapideInternet\Gotenberg\Facades\Gotenberg;
Gotenberg::chromiumUrl('https://example.com');

About

Gotenberg PDF wrapper for Laravel applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages