Added basic PDF export feature for documents

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-08-03 17:56:21 +02:00
parent a181bfd4db
commit 624e56389e
5 changed files with 25 additions and 5 deletions

View File

@ -22,6 +22,7 @@ class AppKernel extends Kernel
// 3rd party bundles // 3rd party bundles
new Ivory\CKEditorBundle\IvoryCKEditorBundle(), new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Io\TcpdfBundle\IoTcpdfBundle(),
// Own bundles // Own bundles
new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\FrontBundle\KekRozsakFrontBundle(),
new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(),

View File

@ -8,7 +8,6 @@ framework:
secret: %secret% secret: %secret%
router: router:
resource: "%kernel.root_dir%/config/routing.yml" resource: "%kernel.root_dir%/config/routing.yml"
strict_parameters: %kernel.debug%
form: true form: true
csrf_protection: true csrf_protection: true
validation: { enable_annotations: true } validation: { enable_annotations: true }

View File

@ -4,6 +4,12 @@
"autoload": { "autoload": {
"psr-0": { "": "src/" } "psr-0": { "": "src/" }
}, },
"repositories": [
{
"type": "vcs",
"url": "http://github.com/w00d5t0ck/IoTcpdfBundle"
}
],
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.3.3",
"symfony/symfony": "2.1.*", "symfony/symfony": "2.1.*",
@ -19,7 +25,8 @@
"jms/security-extra-bundle": "1.1.*", "jms/security-extra-bundle": "1.1.*",
"jms/di-extra-bundle": "1.0.*", "jms/di-extra-bundle": "1.0.*",
"doctrine/doctrine-migrations-bundle": "dev-master", "doctrine/doctrine-migrations-bundle": "dev-master",
"egeloen/ckeditor-bundle": "dev-master" "egeloen/ckeditor-bundle": "dev-master",
"gergelypolonkai/tcpdfbundle": "dev-master"
}, },
"scripts": { "scripts": {
"post-install-cmd": [ "post-install-cmd": [

View File

@ -14,15 +14,23 @@ use KekRozsak\FrontBundle\Extensions\Slugifier;
class DocumentController extends Controller 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() * @Template()
* @ParamConverter("document") * @ParamConverter("document")
*/ */
public function viewAction(Document $document) public function viewAction(Document $document, $_format)
{ {
return array( $templateParams = array(
'document' => $document, 'document' => $document,
); );
if ($_format == 'pdf')
{
$html = $this->renderView('KekRozsakFrontBundle:Document:pdfView.html.twig', $templateParams);
return $this->get('io_tcpdf')->quick_pdf($html);
}
return $templateParams;
} }
/** /**

View File

@ -0,0 +1,5 @@
{# vim: ft=htmljinja
#}
<h1>{{ document.title }}</h1>
<h2>Írta: {{ document.createdBy.displayName }}</h2>
{{ document.content|raw }}