PHP code example of utafitilabs / pdf-scribe-bundle

1. Go to this page and download the library: Download utafitilabs/pdf-scribe-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/ */

    

utafitilabs / pdf-scribe-bundle example snippets


// config/bundles.php
return [
    // ...
    UtafitiLabs\PdfScribe\PdfScribeBundle::class => ['all' => true],
];

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use UtafitiLabs\PdfScribe\Contract\PdfGeneratorInterface;

final class InvoiceController extends AbstractController
{
    public function download(Invoice $invoice, PdfGeneratorInterface $pdf): Response
    {
        $html = $this->renderView('invoice/pdf.html.twig', ['invoice' => $invoice]);

        return new Response($pdf->fromHtml($html), 200, [
            'Content-Type' => 'application/pdf',
            'Content-Disposition' => 'attachment; filename="invoice.pdf"',
        ]);
    }
}

$pdf->fromUrl('https://example.test/report/2026', ['landscape' => true]);   // bytes
$pdf->saveFromHtml($html, '/var/reports/summary.pdf');                     // file