PHP code example of sensiolabs / gotenberg-bundle

1. Go to this page and download the library: Download sensiolabs/gotenberg-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sensiolabs / gotenberg-bundle example snippets


// config/bundles.php

return [
    // ...
    SensioLabs\GotenbergBundle\SensioLabsGotenbergBundle::class => ['all' => true],
];

namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->url()
            ->url('https://sensiolabs.com/fr/')
            ->generate()
            ->stream() // will return directly a stream response
        ;
    }
}

namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->html()
            ->content('twig_simple_pdf.html.twig', [
                'my_var' => 'value'
            ])
            ->generate()
            ->stream() // will return directly a stream response
        ;
    }
}

namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergScreenshotInterface;

class YourController
{
    public function yourControllerMethod(GotenbergScreenshotInterface $gotenberg): Response
    {
        return $gotenberg->url()
             ->url('https://sensiolabs.com/fr/')
             ->generate()
             ->stream()
        ;
    }
}

namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergScreenshotInterface;

class YourController
{
    public function yourControllerMethod(GotenbergScreenshotInterface $gotenberg): Response
    {
        return $gotenberg->html()
            ->content('twig_simple_pdf.html.twig', [
                 'my_var' => 'value'
            ])
            ->generate()
            ->stream()
        ;
    }
}