Added basic PDF export feature for documents
Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -14,15 +14,23 @@ use KekRozsak\FrontBundle\Extensions\Slugifier;
|
||||
class DocumentController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/dokumentum/{slug}", name="KekRozsakFrontBundle_documentView")
|
||||
* @Route("/dokumentum/{slug}.{_format}", name="KekRozsakFrontBundle_documentView", defaults={"_format": "html"}, requirements={"_format": "html|pdf"})
|
||||
* @Template()
|
||||
* @ParamConverter("document")
|
||||
*/
|
||||
public function viewAction(Document $document)
|
||||
public function viewAction(Document $document, $_format)
|
||||
{
|
||||
return array(
|
||||
$templateParams = array(
|
||||
'document' => $document,
|
||||
);
|
||||
|
||||
if ($_format == 'pdf')
|
||||
{
|
||||
$html = $this->renderView('KekRozsakFrontBundle:Document:pdfView.html.twig', $templateParams);
|
||||
return $this->get('io_tcpdf')->quick_pdf($html);
|
||||
}
|
||||
|
||||
return $templateParams;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,5 @@
|
||||
{# vim: ft=htmljinja
|
||||
#}
|
||||
<h1>{{ document.title }}</h1>
|
||||
<h2>Írta: {{ document.createdBy.displayName }}</h2>
|
||||
{{ document.content|raw }}
|
Reference in New Issue
Block a user