CFPDF从BLOB创建变量 [英] CFPDF create variable from a BLOB

查看:229
本文介绍了CFPDF从BLOB创建变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ColdFusion 9中,我们有pdf数据存储在数据库中的blob中。

In ColdFusion 9 we have pdf data stored in a blob in the database.

如何将它变成cfpdf变量?它似乎所有的选项需要一个文件名。有没有办法不写文件?

How do I get that into a cfpdf variable? It seems like all options require a filename. Is there a way to do it without writing a file?

推荐答案

CFPDF CFDOCUMENT 用于动态创建和修改PDF。因为您已经在数据库中的一个blob中使用PDF,所以只需要CF页面,使用 CFCONTENT 将其作为响应的一部分发送回来。假设您使用某种类型的ID来引用要从数据库检索的PDF,示例将如下所示:

CFPDF and CFDOCUMENT are for creating and modifying a PDF dynamically. As you already have the PDF in a blob in your database you simply need the CF page to send it back as part of the response using CFCONTENT. Assuming you are using some type of ID to reference which PDF you want to retrieve from your database an example would look like this:

<cfquery name="qryFile" datasource="MyDatasourceHere">
    SELECT id, name, data
    FROM files
    WHERE id = <cfqueryparam cfsqltype="cf_sql_integer" value="#URL.id#" />
</cfquery>
<cfheader name="content-length" value="#ArrayLen(qryFile.data)#" />
<cfheader name="content-disposition" value="attachment; filename=#qryFile.name#" />
<cfcontent type="application/octet-stream" variable="#qryFile.data#" />

这篇关于CFPDF从BLOB创建变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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