exphp Posted January 20, 2013 Share Posted January 20, 2013 Hello everyone. I have a problem to generate PDF file using FPDF and PHP. I'll not ask you how to create the pdf file, but I need help to generate a link to PDF file so it can be downloaded automatically. I mean like this: I already created a php page that create PDF file, name: report.php. I must open the report.php page to see the pdf file then click "Save" or press Ctrl + S to save the PDF file. But, now I need to generate report.php become report.pdf automatically so the pdf file can be downloaded automatically. For example, if I click a button "Generate Link", so the value will be: echo "<a href='report.pdf' title='download pdf file'>Download PDF File</a>"; not echo "<a href='report.php' title='download pdf file'>Download PDF File</a>"; Do you have any ideas or solution for this case? I really appreciate it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/273378-how-to-generate-pdf-file-so-it-can-be-downloaded/ Share on other sites More sharing options...
requinix Posted January 20, 2013 Share Posted January 20, 2013 Except in IE, and hopefully just the older versions, the filename you link to doesn't matter. Along with the header() that says it's a PDF file, include a header("Content-Disposition: attachment; filename=report.pdf"); That will make the browser prompt to download and will use the filename "report.pdf" by default. Quote Link to comment https://forums.phpfreaks.com/topic/273378-how-to-generate-pdf-file-so-it-can-be-downloaded/#findComment-1407055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.