Using the above technologies, I want to create a PDF, store it in my db, and email it. All with the click of one button.
I also want to call it up and have it be able to display with a hyperlink.
I am very new to FPDF. Therefore, I am trying to start off very slowly.
I began with this link stackoverflow Q
I put both parts of his code into the same page and also tried with separate pages. I made the suggested changes/additions and even did a line by line comparison.
I still get the message, "format error: not a PDF or corrupted"
If I just
$pdf->Output();
I get the pdf to display. It's either the way the string is being Output, or it's the header() function. It's not the storage method, unless my column setup is incorrect. BUt a blob is a blob, right?
here's the code where I enter it in:
<?php
session_start();
include "server.php";//my file to connect to db
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$content = $pdf->Output("", "S"); //return the pdf file content as string
$sql = "update table set table_pdf= '".addslashes($content)."' " .
"where table_id = '188'";
mysql_query($sql);
//here's where I retrieve it
$sql2 = "select table_pdf from table where table_id = '188'";
$result2 = mysql_query($sql2);
$rs = mysql_fetch_assoc($result2);
$content2 = $rs['rdngs_hdr_pdf'];
header('Content-Type: application/pdf');
header("Content-Length: ".strlen(content2));
header('Content-Disposition: attachment; filename=myfile.pdf');
print $content2;
?>
I've also tried this...from another source. I still get the same error message.
$content = $pdf->Output("", "S"); //return the pdf file content as string
$data = unpack("H*hex", $content);
$sql = "update table set table_pdf= " . 0x".$data['hex']." . " " .
"where table_id = '188'";
The $sql from above gives a parse error, so I tried to fix it by adding " in between . & 0. It doesn't seem right, nor does it fix the problem.
Like I said, I have tried the other ideas on the other question link above. right now it just sits on the version where the addslashes is there.
I would appreciate anyone who answers this thread and follows it as I will attempt your solutions promptly and let you know if it worked. Thank you in advance.