I'm using the fpdf library to output a pdf from html. The .pdf is being created because I can email it to myself and it arrives in the correct format but if I want to download the .pdf as an option without emailing, the output is illegible. The output appears in a browser window(see attached screen shot) and I'm unsure how to fix this issue.
I've also attached a screenshot of how we have our report options set up. 1. HTML 2. PDF 3. Download 4. Email -- the HTML and Email options work, the PDF and Download options do not. I'm focusing on the Download option in this question.
This is the output code that I've tried to test out but no luck
//$pdf->Output("D","D:/example2.pdf");
//$content = $pdf->Output("","S");
//$pdf->Output(); //Outputs on browser screen
//Outputs on browser screen
$pdf->Output();
//echo file_get_contents($pdf);
//readfile($pdf);
- the $pdf->Output(); is generating the illegible code the readfile
- echo and file_get_contents throw errors
- the $pdf->Output(... gives me an error that says Incorrect Output Destination (see attached screenshot)
Need guidance -- thanks for any help.
here is the full code:
<?php
$m_header = '<link href="shared/report.css" rel=stylesheet type="text/css">';
$m_body_tag = ' scroll=no';
require_once($DOCUMENT_ROOT."inc/top-2.inc.php");
$i_get_sid = isset($_GET["sid"]) ? (int)$_GET["sid"] : $i_sid;
$i_get_pass = isset($_GET["a"]) ? $_GET["a"] : $_SESSION['r_pass'];
$i_get_pass = addslashes($i_get_pass);
$i_pdf_file_url = 'report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=/report.pdf';
echo '<table cellpadding=0 cellspacing=0 border=0 width="100%">';
echo '<tr vAlign=top><td height=7><img src="images/1x1.gif" width=1 height=7></td></tr>';
echo '<tr height=28 style="background: url(images/bookm-bg.gif) repeat-x"><td width="100%"><nobr>';
echo '<img src="images/1x1.gif" width=5 height=1><a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'"><img src="images/bookm-42.gif" width=67 height=28 border=0></a><img src="images/bookm-s1.gif" width=10 height=28 border=0><img src="images/bookm-51.gif" width=65 height=28 border=0> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=/report.pdf"><img src="images/button-downloadpdf.gif" width=80 height=28 border=0></a> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=email"><img src="images/button-emailpdf.gif" width=80 height=28 border=0></a>';
echo '</nobr></td><td><nobr><font style="font-size: 10px;"><a href="javascript:window.close();">Close Window</a> </font></nobr></td></tr></table>';
(This is what I added as a workaround)echo '<p><a href="'.$i_pdf_file_url.'" name="plugin" width=100% height=100% fullscreen=yes style="position: absolute;">Click Here to open the PDF</p>';
(This is what should display the PDF in the browser but wont' work)
echo '<p><embed type="application/pdf" src="'.$i_pdf_file_url.'" name="plugin" width=100% height=100% fullscreen=yes style="position: absolute;"></p>';
require_once($DOCUMENT_ROOT."inc/btm-2.inc.php");
?>