monty
monty

Reputation: 31

cfdocument issue - cfdocument has no body

I am working with Coldfusion10 and am facing this error:

The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
cfdocument tag has no body.
It must have a body or a source file or URL.

I checked the website and detected that cfsettings is not defined at the top or anywhere which can cause this issue, I am using it as

<cfdocument format="pdf">
<cfdocumentsection>
<cfdocumentitem  type="header"></cfdocumentitem> - Footer is used too 
</cfdocumentsection>

I tried using evalAtPrint= true but still no success. Am I missing something here?

Upvotes: 3

Views: 1126

Answers (2)

Miguel-F
Miguel-F

Reputation: 13548

The error message you included in your question indicates that there is no content between your <cfdocument> tags. The code that you included corroborates that. If this is not your actual code then we cannot be of much help.

You need to include the content that you would like to be converted into PDF between the <cfdocument> tags. You need something like this:

<cfquery datasource="cfdocexamples" name="empSalary"> 
    SELECT Emp_ID, firstname, lastname, e.dept_id, salary, d.dept_name  
    FROM employee e, departmt d 
    WHERE e.dept_id = d.dept_id 
    ORDER BY d.dept_name 
</cfquery> 

<cfdocument format="PDF"> 
    <cfoutput query="empSalary" group="dept_id"> 
        <cfdocumentsection> 
            <cfdocumentitem type="header"> 
                <font size="-3"><i>Salary Report</i></font> 
            </cfdocumentitem> 
            <cfdocumentitem type="footer"> 
                <font size="-3">Page #cfdocument.currentpagenumber#</font> 
            </cfdocumentitem>         
            <h2>#dept_name#</h2> 
            <table width="95%" border="2" cellspacing="2" cellpadding="2" > 
            <tr> 
                <th>Employee</th> 
                <th>Salary</th> 
            </tr> 
            <cfset deptTotal = 0 > 
            <!--- inner cfoutput ---> 
            <cfoutput> 
                <tr> 
                <td>
                    <font size="-1">#empSalary.lastname#, #empSalary.firstname#</font> 
                </td> 
                <td align="right">
                    <font size="-1">#DollarFormat(empSalary.salary)#</font> 
                </td> 
                </tr> 
                <cfset deptTotal = deptTotal + empSalary.salary> 
            </cfoutput> 
            <tr> 
                <td align="right"><font size="-1">Total</font></td> 
                <td align="right"><font size="-1">#DollarFormat(deptTotal)#</font></td> 
            </tr> 
            <cfset deptTotal = 0> 
            </table> 
        </cfdocumentsection> 
    </cfoutput> 
</cfdocument>

Copied from the ColdFusion documentation here

Upvotes: 0

Chris Tierney
Chris Tierney

Reputation: 1549

Make sure you are actually putting in at the end. I'm assuming you just missed this here.

Otherwise everything seems to align up with the Wiki Docs.

I would suggest two things.

  1. Verify you are using ColdFusion 11 Update 3. Update 3 was a major update and may have addressed this issue.
  2. If you are using update 3, open a bug at bugbase.adobe.com

Upvotes: 1

Related Questions