Jump to content

Recommended Posts

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.