/**
* @Route("/")
* @Template()
*/
public function indexAction(Request $request)
{
$this->rebuildAction(false);
/** @var $snappy Snappy */
$snappy = $this->get('knp_snappy.pdf');
$cover = $snappy->getOutput($this->getPath('cover.html'));
$snappy->setOption('margin-top', '20');
$snappy->setOption('margin-right', '0');
$snappy->setOption('margin-bottom', '16');
$snappy->setOption('margin-left', '0');
$snappy->setOption('header-html', $this->getPath('header.html'));
$snappy->setOption('header-spacing', '5');
$snappy->setOption('footer-html', $this->getPath('footer.html'));
$snappy->setOption('footer-spacing', '5');
$snappy->setOption('xsl-style-sheet', $this->getPath('toc.xml'));
$html = file_get_contents($this->getPath('content.html'));
if ($request->query->get('ids')) {
$html = $this->addFilters($html, explode(',', $request->query->get('ids')));
}
$contents = $snappy->getOutputFromHtml($html, array('toc' => true));
$pdfMerger = new Merger();
$pdfMerger->addRaw($cover, new Pages('1'));
$pdfMerger->addRaw($contents);
$contents = $pdfMerger->merge();
return new Response($contents, 200, array('Content-Type' => 'application/pdf'));
}