CFPDF create variable from a BLOB

拜拜、爱过 提交于 2019-12-23 05:16:41

问题


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

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?


回答1:


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#" />


来源:https://stackoverflow.com/questions/5069717/cfpdf-create-variable-from-a-blob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!