从数据库中显示pdf blob文件 [英] Display pdf blob file from database

查看:593
本文介绍了从数据库中显示pdf blob文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将pdf文件存储到数据库中,即blob类型。
现在我想要显示PDF格式,如

  $ sqll =select * from pdff; 
$ query = mysql_query($ sqll)或die(mysql_error());
$ result = mysql_fetch_array($ query);
$ content = $ result ['pdf'];
< object data =<?php echo $ content;?> type =application / pdfstyle =height:200px; width:60%>< / object>

但在浏览器中显示..

 > endobj 6 0 obj<< / ProcSet [/ PDF / Text / ImageB / ImageC / ImageI] / ColorSpace<< / Cs1 7 0 R / Cs2 10 0 R>> / ExtGState<< / Gs2 34 0 R / Gs1 35 0 R>> / Font<< /F1.0 31 0 R>> / XObject<< / Im4 21 0 R / Im1 8 0 R / Im3 16 0 R / Im2 11 0 R / Im5 26 0 R / Im6 32 0 R / Fm3 23 0 R / Fm1 13 0 R / Fm2 18 0 R / Fm4 28 0 R >> / Properties  / Pl 2 36 0 R / Pl 1 37 0 R>> >> endobj 23 0 obj<< / Length 24 0 R / Filter / FlateDecode / Type / XObject / Subtype / Form / FormType 1 / BBox [649 536 669 556] / Resources 25 0 R / Group< / S / Transparency / CS 10 0 R / I true / K false>> >> streamxMŽAƒ0ï}ÅáÀÀ‰mȹ/àÄU+Íÿ¥:(\ |〜〜)ïîetc 

和我试过了:

pre $ < object data =<?php echo base64_decode($ content);?>type = application / pdfstyle =height:200px; width:60%>< / object>



<如果您的数据仍然在 Blob

中,那么您的数据仍在 Blob

code>,您需要使用 base64_encode()
编码您的数据请尝试使用

 < object data =data:application / pdf; base64,<?php echo base64_encode(content)?>type =application / pdfstyle =height: 200px; width:60%>< / object> 


I have stored pdf file into database i.e blob type. Now I wanna display pdf like

$sqll="select * from pdff";
$query=mysql_query($sqll) or die(mysql_error());
$result=mysql_fetch_array($query);
$content=$result['pdf'];
<object data="<?php echo $content;?>" type="application/pdf" style="height:200px;width:60%"></object>

but in browser it shows..

> endobj 6 0 obj << /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /ColorSpace << /Cs1 7 0 R /Cs2 10 0 R >> /ExtGState << /Gs2 34 0 R /Gs1 35 0 R >> /Font << /F1.0 31 0 R >> /XObject << /Im4 21 0 R /Im1 8 0 R /Im3 16 0 R /Im2 11 0 R /Im5 26 0 R /Im6 32 0 R /Fm3 23 0 R /Fm1 13 0 R /Fm2 18 0 R /Fm4 28 0 R >> /Properties << /Pl2 36 0 R /Pl1 37 0 R >> >> endobj 23 0 obj << /Length 24 0 R /Filter /FlateDecode /Type /XObject /Subtype /Form /FormType 1 /BBox [649 536 669 556] /Resources 25 0 R /Group << /S /Transparency /CS 10 0 R /I true /K false >> >> stream xMŽAƒ0ï}žÀĉmȹ/àÄU+Íÿ¥:(\|˜]ïî etc

and I tried

 <object data="<?php echo base64_decode($content);?>" type="application/pdf" style="height:200px;width:60%"></object>

but no use...please help meeee

解决方案

If your data still in Blob, you need to encode your data using base64_encode(). Please try it

<object data="data:application/pdf;base64,<?php echo base64_encode(content) ?>" type="application/pdf" style="height:200px;width:60%"></object>

这篇关于从数据库中显示pdf blob文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆