1. Go to this page and download the library: Download massive/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/ */
massive / pdf-bundle example snippets
namespace AppBundle\Controller;
use Massive\Bundle\PdfBundle\Controller\RenderPdfTrait;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class YourController extends Controller
{
use RenderPdfTrait;
public function pdfAction(Request $request): Response
{
return $this->renderPdf(
'@pdfs/your.html.twig',
[
'parameter' => 'hello'
],
$request->getRequestFormat()
);
}
}
/** @var \Massive\Bundle\PdfBundle\Pdf\PdfFactory $pdfFactory */
$pdfFactory = $this->get('massive_pdf.pdf_factory'); // get the service or inject it in your services configuration
$pdf = $pdfFactory->create('pdf.html.twig');
php
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
new Massive\Bundle\PdfBundle\MassivePdfBundle(),