Force download the PDF created by TCPDF, after sending Ajax send

My application allows users to fill out a form and submit it using an Ajax mail call. The si form has been submitted to the TCPDF class, which creates the PDF file. The class has a method "-> output (...)" that allows you to save the file on a web server, send it to the browser, ecc ... my goal is to create a PDF file after sending the form and force the user to download it (without updating ) The method does not work with ajax calls. The only solution I found was to create a file, transfer it to the web server and redirect the user to the file location on the web server; but this is not a good solution, I need to force download (automatic start). I read other similar solutions on the forum, but they are not very good. Any suggestions?

+6
source share
2 answers
$pdf->Output("filename.pdf",'D'); 
+29
source

Try

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

This will prompt the client whether he wants to save or open the file.

+15
source

Source: https://habr.com/ru/post/917691/


All Articles