创建pdf后,重定向到cakephp中的索引页面
我正在实现 PDF 文件生成,并使用此链接完成了它:
http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf
生成PDF后,调用另一个执行数据库更新的函数。并且应该重定向到索引页面。我已经完成了数据库更新。唯一的问题是重定向到索引页面。当我重定向到索引页时,PDF 逻辑未实现。
我认为这是因为我已经为pdf设置了布局,所以索引页和pdf创建都无法相继进行。
I am implementing PDF file generation and I have completed it using this link:
http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf
After generating PDF, it calls another function that performs update of my database. And should redirect to index page. I have done my database update. Only problem in redirecting to index page. When I am redirecting to index page PDF logic is not implementing.
I think it is because of i have set layout for pdf so both index page and pdf creation not works one after another.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已按照 Bakery 上的说明设置 PDF 布局,则无法重定向用户。
PDF 布局向您的浏览器发送了一个标头,表明 PDF 内容即将到来。 HTTP 重定向不是 PDF 内容,因此这不起作用。
如果您希望 PDF 生成在后台完成,而不是在用户浏览器窗口中“即时”生成,只需删除 PDF 布局并使用“默认”布局即可。然后,您只需从控制器调用
$this->redirect
即可。If you have set the PDF layout as stated on the Bakery, you can not redirect the user.
The PDF layout sent a header to your browser that states PDF content is coming it's way. A HTTP redirect is not PDF content, so this will not work.
If you want the PDF generation to be done on the background and not "on-the-fly" in the user's browser window, just drop the PDF layout and use your 'default' layout instead. You can then just call
$this->redirect
from your controller.