使用上述技术,我想创建一个 PDF,将其存储在我的数据库中,然后通过电子邮件发送。只需单击一个按钮。
我还想调用它并让它能够显示超链接。
我对 FPDF 很陌生。因此,我试图开始非常缓慢。
我从这个链接开始stackoverflow Q
我将他的代码的两个部分放在同一个页面中,并尝试使用单独的页面。我进行了建议的更改/添加,甚至进行了逐行比较。
我仍然收到消息“格式错误:不是 PDF 或已损坏”
如果我只是 $pdf->Output(); 我得到要显示的pdf。它要么是字符串输出的方式,要么是 header() 函数。这不是存储方法,除非我的列设置不正确。但是一个blob就是一个blob,对吧?
如果你愿意,我可以上传经过清理的代码。让我知道什么可以帮助回答这个问题。
谢谢
JJ
这是应要求提供的代码,这是我输入的地方:
<?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;
?>
就像我说的,我在上面的另一个问题链接上尝试了其他想法。现在它只是位于添加斜杠的版本上。
谢谢你的帮助。