Force download PDF created by TCPDF, after Ajax post submit

你。 提交于 2019-12-06 00:44:05

问题


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?


回答1:


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



回答2:


Try

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

This will suggest client if he wants to save or open file.



来源:https://stackoverflow.com/questions/10962325/force-download-pdf-created-by-tcpdf-after-ajax-post-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!