PHP code example of eckinox / pdf-bundle

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

    

eckinox / pdf-bundle example snippets




namespace App\Controller;

use Eckinox\PdfBundle\Pdf\PdfGeneratorInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class ReportController extends AbstractController
{
    /**
     * @Route("/my-report", name="my_report")
     */
    public function overview(PdfGeneratorInterface $pdfGenerator): Response
    {
        $pdf = $pdfGenerator->renderPdf("your_template.html.twig", [
            "key" => "value",
            "foo" => "bar",
        ]);

        return $pdf->output();
    }



namespace App\Controller;

use Eckinox\PdfBundle\Pdf\FormatFactory;
use Eckinox\PdfBundle\Pdf\PdfGeneratorInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class ReportController extends AbstractController
{
    /**
     * @Route("/my-report", name="my_report")
     */
    public function overview(PdfGeneratorInterface $pdfGenerator): Response
    {
        $pdf = $pdfGenerator->renderPdf("your_template.html.twig", [], FormatFactory::a4());

        return $pdf->output();
    }

$format = new Format("4.25in", "5.5in");