通过TCPDF产生的力下载PDF文件,阿贾克斯后提交后 [英] Force download PDF created by TCPDF, after Ajax post submit

查看:164
本文介绍了通过TCPDF产生的力下载PDF文件,阿贾克斯后提交后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序,可以让用户填写一份表格,并与一个Ajax调用后发送。 形式SI发送到创建一个PDF文件中的TCPDF类。 这个类有方法 - >输出(...),允许将文件保存到网络服务器,将它发送给浏览器,ECC ... 我的目标是,经过表单提交,创建PDF文件,并​​强制用户进行下载(不清爽)。 该方法不使用Ajax调用工作。 我发现的唯一的解决办法就是建立档案,塞弗成Web服务器,并且比将用户重定向到文件到Web服务器的位置;但它不是一个很好的解决方案,我需要强制下载(自动启动)。 我读过他人在论坛上类似的解决方案,但大公并不好形式 有什么建议么?

解决方案

  $ PDF->输出(filename.pdf,'D');
 

My application allow the users to complete a form, and send it with an Ajax post call. The form si sent to the TCPDF class that create a PDF file. The class has the method "->output(...)" that permit to save the file into web server, send it to the browser, ecc... my goal is, after the form submit, create the PDF file, and force the user to download it (with no refreshing). The method doesn't work with ajax calls. The only solution I've found is create the file, seve it into web server, and than redirect the user to the location of the file to the web server; but it isn't a nice solution, I need to force the download (auto starting). I've read others similar solution on the forum, but thay aren't good form Any suggestions?

解决方案

$pdf->Output("filename.pdf",'D');

这篇关于通过TCPDF产生的力下载PDF文件,阿贾克斯后提交后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆