Force download PDF created by TCPDF, after Ajax post submit

35,010

Solution 1

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

Solution 2

Try

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

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

Share:
35,010
Admin
Author by

Admin

Updated on July 08, 2020

Comments

  • Admin
    Admin almost 4 years

    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?

  • Admin
    Admin about 11 years
    Solved! The problem is the ajax request that do not support the forcing download... I've changed the logic of the application...
  • Admin
    Admin about 11 years
    Solved! The problem is the ajax request that do not support the forcing download... I've changed the logic of the application...