I am using fpdf to create a custom invoice for our customers to print. It appears to be working fine and I save the output from it in $_SESSION['pdf']. I have put a open/save-as link on the checkout.thankyou page in virtuemart. Everything appears to be working fine, as the dialog box opens fine and adobe opens up but the pdf throws out an error when it tries to load.
Quote:
Adobe Reader could not open 'invoice.pdf' because it is either not a supported file type or because the file has been corrupted(for exaple, it was sent as an email attachment and wasn't correctly decoded)
Here is the link for the pdf:
Code:
<p>To print your invoice in PDF-form you can <a href="index2.php?page=checkout.thankyou&order_id=134&option=com_virtuemart&action=print_pdf" title="Download Invoice">download it here</a> <img src="hyperlms/lms/images/icons/pdf16.gif" style="vertical-align: bottom;" alt="PDF" />.</p>
Here is the code for opening the pdf:
Code:
if($_GET['action'] == 'print_pdf'){
require_once('administrator/components/com_virtuemart/modules/model/invoiceClass.php');
//Create invoice and store
$course_invoice = new course_invoice();
// Store PDF Invoice in _SESSION.
$_SESSION['pdf'] = $course_invoice->generate_invoice();
if(get_magic_quotes_runtime()){
stripslashes($_SESSION['pdf']);
}
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private');
header('Content-type: application/pdf');
header('Content-Length: ' . strlen($_SESSION['pdf']));
// Displays Save As dialog box.
header('Content-Disposition: attachment; filename="bkcourse_invoice.pdf";');
header('Content-Transfer-Encoding: binary');
print $_SESSION['pdf'];
}
Any ideas on what might be the problem? I can't tell if its a Joomla problem or what.
