CFDocument: coldfusion.document.spi.DocumentExportException: java.lang.NullPointerException

萝らか妹 提交于 2019-12-13 04:39:44

问题


I am trying to create a pdf using cfdocument but ColdFusion keeps throwing an exception and I can't find a way to work around this.

This is the code that I am using:

<cfdocument format="pdf" filename="rep_report.pdf" overwrite="yes" name="rep_report">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
  </head>

  <body>
      <style>
          <cfinclude template="stylesheets/bootstrap.min.css">
      </style>

      <cfinclude template="views/_reputationTable.cfm">  
  </body>
</html>
</cfdocument>

And this is the exception:

An exception occurred when performing document processing.
The cause of this exception was that: coldfusion.document.spi.DocumentExportException: java.lang.NullPointerException.

The error occurred in E:/sites/xAmplifier.com/admin/rep_report_template.cfm: line 43
Called from E:/sites/xAmplifier.com/admin/wheels/events/onrequest.cfm: line 1
Called from E:/sites/xAmplifier.com/admin/rep_report_template.cfm: line 43
Called from E:/sites/xAmplifier.com/admin/wheels/events/onrequest.cfm: line 1
41 :       </style>
42 :       
43 :       <cfinclude template="views/_reputationTable.cfm">  
44 :   </body>
45 : </html>

It seems that my issue is the part where I am trying to include a template but unfortunately I don't have a way around this.

Any suggestions on how I can keep the included template and use cfdocument?


回答1:


This is a CF8 and CF9 bug. I am unsure that this bug was fixed with CF9.1

http://blog.dkferguson.com/index.cfm/2008/1/11/CFDocument--pdf-generation-broke-after-CF8-upgrade




回答2:


I find sometimes when CFDOCUMENT breaks that the easiest path to finding the underlying problem is to use CFSAVECONTENT to generate the HTML, then pass the completed and expanded HTML to CFDOCUMENT to render it. That way, if you do hit an error in HTML generation, the error itself will be obvious.

This also minimises the time the document rendering is taking place, which is single-threaded unless you are using CF Enterprise.



来源:https://stackoverflow.com/questions/22945698/cfdocument-coldfusion-document-spi-documentexportexception-java-lang-nullpoint

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