使用二进制数据作为Railo的cfpdf标记中的源

时间:2014-10-08 02:38:39

标签: coldfusion railo cfpdf

所以我将PDF blob保存在数据库中并尝试检索它并在页面上显示它。当我在Coldfusion 10上运行代码时,它按预期运行。但是,当我将相同的代码移到Railo 4.2.1.0时,我收到错误。

我很好奇是否可以将二进制数据传递到Railo中的CFPDF Source标签。如果没有人知道一个好的解决方法吗?

当我运行转储时,pdfBinary数据内部确实有正确的二进制信息。

由于

代码:     

<cfset tcpInformation = dataPopulatorController.getTCPInformation(session.requestID, session.personID) />

<cfset pdfBinary = tcpInformation.file_content[1]>

<cfpdf action="read" source="pdfBinary" name="TCPDocument">

<cfheader name="Content-Disposition" value="filename=TCP.pdf" />
<cfcontent type="application/pdf" variable="#toBinary(TCPDocument)#" />

错误我登上Railo:

发生错误 ///tcpviewer.cfm:line 7 5: 6: 7: 8: 9:

Java Stacktrace文件或目录pdfBinary不存在     at railo.commons.io.res.util.ResourceUtil.toResourceExisting(ResourceUtil.java:199):199     at railo.commons.io.res.util.ResourceUtil.toResourceExisting(ResourceUtil.java:164):164     at railo.runtime.tag.PDF.toPDFDocument(PDF.java:1207):1207     at railo.runtime.tag.PDF.doActionRead(PDF.java:1033):1033     at railo.runtime.tag.PDF.doEndTag(PDF.java:568):568     at onboarding.views.tcpviewer_cfm $ cf.call(/onboarding/views/tcpviewer.cfm:7):7     at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:913):913     at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:865):865     at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:206):206     at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18     at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2218):2218     at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2185):2185     at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:332):332     at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29     在javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472     在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171     在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99     在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947):947     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408):408     在org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200     at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589):589     at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310):310     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source): - 1     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source): - 1     在java.lang.Thread.run(未知来源): - 1

1 个答案:

答案 0 :(得分:1)

当从Railo中的二进制变量源读取时,似乎需要用#s:

包装它
<cfpdf action="read" source="#pdfBinary#" name="TCPDocument">

但正如Leigh所说,没有必要使用CFPDF重新读取变量以将内容输出到浏览器:

<cfset tcpInformation = dataPopulatorController.getTCPInformation(session.requestID, session.personID) />
<cfset pdfBinary = tcpInformation.file_content[1]>
<cfheader name="Content-Disposition" value="filename=TCP.pdf" />
<cfcontent type="application/pdf" variable="#pdfBinary#" />