1. Go to this page and download the library: Download knplabs/knp-snappy-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/ */
use Knp\Bundle\SnappyBundle\Snappy\Response\JpegResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class SomeController extends AbstractController
{
public function imageAction(Knp\Snappy\Image $knpSnappyImage)
{
$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
'some' => $vars
));
return new JpegResponse(
$knpSnappyImage->getOutputFromHtml($html),
'image.jpg'
);
}
}
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class SomeController extends AbstractController
{
public function pdfAction(Knp\Snappy\Pdf $knpSnappyPdf)
{
$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
'some' => $vars
));
return new PdfResponse(
$knpSnappyPdf->getOutputFromHtml($html),
'file.pdf'
);
}
}
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class SomeController extends AbstractController
{
public function pdfAction(Knp\Snappy\Pdf $knpSnappyPdf)
{
$pageUrl = $this->generateUrl('homepage', array(), true); // use absolute path!
return new PdfResponse(
$knpSnappyPdf->getOutput($pageUrl),
'file.pdf'
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.