I'm trying to use the WkHtmlToPdf Component, it seems like a nice tool when facing the problem of generating pdf files.
However - I can't get it to work with the Auth Component. The problem is that I always get the login page generated to pdf. I'm logged, the action is allowed in beforeFilter and it still somehow gets into the way of it.
EDIT:
AppController:
var $components = array('Auth', 'Session');
function beforeFilter()
{
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
if (!$this->Aut开发者_Python百科h->user())
{
$this->layout = 'login';
}
}
Controller:
var $components = array('WkHtmlToPdf');
function beforeFilter() // I am logged in, so this shouldn't even be needed
{
$this->Auth->allow('pdf');
}
function pdf()
{
$this->WkHtmlToPdf->createPdf();
}
// this function is required for wkhtmltopdf to retrieve
// the viewdump once it's rendered
function getViewDump($fileName)
{
$this->WkHtmlToPdf->getViewDump($fileName);
}
Any help would be greatly appreciated, Paul
It turns out, you have to allow the getViewDump
method. It doesn't seem to work with Auth, but there is no threat with allowing it for everyone, and it works.
controller:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('getViewDump');
}
精彩评论