psliwa/PdfBundle — Issue #4: Cant print in PDF
Author: razeta
Created: 2011-12-15 06:56:25+00:00
State: open

Hello,

I have isntalled everything and I think everything si running fine, but when I try to print the pdf it renders the html only.

Do I have to enable something in regard of annotations maybe?

I am kinda lost here...

My code is as follows:

AUTOLOADER:
'Ps' => __DIR__.'/../vendor/bundles',
'PHPPdf' => __DIR__.'/../vendor/PHPPdf/lib',
'Zend' => __DIR__.'/../vendor/PHPPdf/lib/vendor',//If you have used ZF2 packages already, you should skip this entry

KERNEL:
new Ps\PdfBundle\PsPdfBundle(),

CONFIG:
ps_pdf:
fonts_file: ~
enhancements_file: ~
use_cache_in_stylesheet: ~
cache:
type: ~
options: ~
markdown_stylesheet_filepath: ~
markdown_document_template_filepath: ~
document_parser_type: ~

ROUTE:
BWSAspiranteBundle_imprimirSolicitudAspirnte:
pattern: /pdf/{id}
defaults: { _controller: BWSAspiranteBundle:Profile:UserApplicationToPdf }

CONTROLLER:

use Ps\PdfBundle\Annotation\Pdf;

/**
* @Pdf()
*/
public function UserApplicationToPdfAction()
{
$user = $this->container->get('security.context')->getToken()->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
throw new AccessDeniedException('This user does not have access to this section.');
}
/*@var $em Doctrine\ORM\EntityManager*/
$em = $this->container->get('doctrine.orm.entity_manager');
$documentos_ids = $em->getRepository("BWS\AspiranteBundle\Entity\Documento\Documento")->findNewByType($user->getId());
$documentos = $em->getRepository("BWS\AspiranteBundle\Entity\Documento\Documento")->findByIds($documentos_ids);

return
$this->container->get('templating')
->renderResponse('BWSAspiranteBundle:Profile:showPDF.pdf.twig',
array('name' => $user->getEmail(), 'user' => $user, 'documentos' => $documentos));

}

VIEW: showPDF.pdf.twig

Hello {{ name }}!

It renders the follows:

Hello NAME OF USER!

Thanks for the help