I want to download a pdf file with result, I have already generate the pdf using fpdf [$pdf->Output($output_file, 'F');], the pdf file generated is saved in server.
I want user to be able to download the pdf file generated from fpdf anyway. I even tried using other output (http://www.fpdf.org/en/doc/output.htm) but none of them work except for "F". $pdf->Output($output_file, 'F');(generate pdf successful using this)
I also tried to add a form which will download the existed generated file from server to browser but nothing is working . My code is as below:
<form method="post" target="_blank">
<input type="submit" name="download" value="Download Most Recent PDF">
<h3>Please check the content of PDF.</h3>
</form>
$file = plugin_dir_path(__FILE__) . "../pdf/Result.pdf";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
I want to generate result(which i successfully did) and let user download the result in pdf version.(where i am stuck).