如何输出pdf变量?

fro*_*die 2 pdf coldfusion

我有一个cfdocument标签,看起来像这样:

<cfdocument name="myPDF" format="PDF" ... >
   ...
</cfdocument>
Run Code Online (Sandbox Code Playgroud)

我使用name属性将PDF保存在变量中,因为我将在多个地方使用它以进行多种用途.(附在电子邮件上,在屏幕上显示等)

我想在浏览器中显示这个pdf,只是输出它就像我在cfdocument中遗漏了name属性一样,但我无法弄清楚如何做到这一点.使用cfoutput(<cfoutput>#myPDF#</cfoutput>)给出了一个错误 - "ByteArray对象无法转换为字符串." 使用cfdump给我一个二进制对象.似乎pdf存储为二进制...如何强制它以PDF格式显示在屏幕上?

fro*_*die 8

找到一个解决方案(通过查看我们网站上其他地方的地方) - 使用了一个cfcontent:

<cfcontent type="application/pdf">
<cfoutput>#tostring(myPDF)#</cfoutput>
Run Code Online (Sandbox Code Playgroud)

更新:

我实际上发现了一种稍微简单的方法:

<cfcontent type="application/pdf" variable="#myPDF#">
Run Code Online (Sandbox Code Playgroud)