我正在使用XML8和对象来创建ColdFusion文档,然后将数据写入我们内部网上现有的PDF文件中的字段。问题是我需要在新的浏览器窗口中打开PDF,而不是在相同的浏览器窗口中打开,这就是现在正在发生的事情。
有没有什么额外的信息可以和'destination=‘标签一起传递,以强制在新的浏览器窗口中打开?
提前感谢您的回复
发布于 2011-09-10 16:54:54
在未来提供代码示例将非常感谢,并应加快解决。但是,如果我对您的理解是正确的,并且根据您的偏好,那么以下解决方案之一应该就足够了。
ColdFusion (服务器端)
If you are NOT writing the newly to disk: (如果您正在将新填充的PDF写入磁盘,请注意:
<cfpdf name="variableName" />
<cfheader name="Content-Disposition" value="attachment; filename=filename.pdf" />
<cfcontent type="application/pdf" variable="#toBinary(variableName)#" />或
If you If writing the newly to disk: (如果您正在将新填充的PDF写入磁盘:
<cfpdf action="write" destination="c:\full\path\to\filename.pdf" />
<cfheader name="Content-Disposition" value="attachment; filename=filename.pdf" />
<cfcontent type="application/pdf" file="c:\full\path\to\filename.pdf" />或
HTML (客户端)
<a href="/relative/url/to/pdf/populate/template.cfm" target="_blank">Anchor Text</a>或
JavaScript (客户端)
window.open("/relative/url/to/pdf/populate/template.cfm", "windowName");发布于 2012-08-23 00:47:06
我一直在寻找答案,同事引导我朝着这个简单的解决方案前进。这将在新的web浏览器窗口中打开一个pdf。
<a href="showPdf.cfm?filePath=#filePath#" target="_blank">test.pdf</a>
index.cfm (调用页)
<cfheader name="Content-disposition" value="inline;filename=test.pdf">
<CFCONTENT TYPE="application/pdf" FILE="#url.filePath#" DELETEFILE="No">
showPdf.cfm
https://stackoverflow.com/questions/7368984
复制相似问题