ColdFusion 9.0 Resources |
cfdocumentsectionDescriptionDivides a PDF or FlashPaper document into sections. By using this tag in conjunction with a cfdocumentitem tag, each section can have unique headers, footers, and page numbers. Syntax<cfdocument ...> <cfdocumentsection authPassword = "authentication password" authUser = "authentication user name" marginBottom = "number" marginLeft = "number" marginRight = "number" marginTop = "number" mimeType = "text/plain|application/xmlimage/jpeg|image/png|image/bmp|image/gif" name = "bookmark for the section" src = "URL|path relative to web root" srcfile = "absolute path of file" userAgent = "HTTP user agent identifier"> HTML, CFML, and cfdocumentitem tags </cfdocumentsection> </cfdocument> Note: You can specify
this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
HistoryColdFusion 8: Added the name, authPassword, authUser, and userAgent attributes. ColdFusion MX 7.01: Added the src, srcfile, and mimetype attributes. ColdFusion MX 7: Added this tag and the margintop, marginbottom, marginleft, marginright attributes. Attributes
UsageUse the cfdocumentsection tag to divide a report into sections. Within each cfdocumentsection tag, you can use one or more cfdocumentitem tags to specify unique headers and footers for each section. When using cfdocumentsection, ColdFusion ignores HTML and CFML not enclosed within cfdocumentsection tags. The margin attributes override margins specified in previous sections or in the parent cfdocument tag. If you specify margin attributes, the units are controlled by the unit attribute of the parent cfdocument tag; the unit attribute has a default value of inches. The cfdocumentsection tag forces a page break so that each section starts on a new page. ColdFusion has added the name attribute to support bookmarks. Bookmarks defined at the documentsection tag level are children of the cfdocument root. ExampleExample 1 <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> Example 2: Bookmarks <!--- This example uses the name attribute to define bookmarks in a PDF document at the section level. ---> <cfdocument format="pdf" bookmark="yes"> <cfdocumentsection name="section 1"> <!--- Insert some HTML content here. ---> </cfdocumentsection> <cfdocumentsection name="section 2"> <!--- Insert some HTML content here. ---> </cfdocumentsection> </cfdocument> |