我正在使用wkhtmltopdf在我的應用程序中生成pdf報告,但是當生成pdf時,我得到了pdf中的登錄頁面。Wkhtmltopdf重定向到symfony2中的登錄頁面
這是我的操作:
public function exportPdfAction($id = 0)
{
$em = $this->container->get('doctrine')->getEntityManager();
$id = $this->get('request')->get($this->admin->getIdParameter());
$object = $this->admin->getObject($id);
if (!$object) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
if (false === $this->admin->isGranted('VIEW', $object)) {
throw new AccessDeniedException();
}
$pageUrl = $this->generateUrl('admin_rh_leave_conge_show', array('id'=>$id), true); // use absolute path!
return new Response(
$this->get('knp_snappy.pdf')->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Fiche_conge.pdf"'
)
);
}
我怎樣才能解決這個問題呢?
如果你想得到一些有用的答案,你可能不得不提供更多的細節。 – cheesemacfly
所以我會更新我的問題 – soufiane
我的問題更新 – soufiane