I figured when I first started this project that it would require the use of CFPDF in order to create a PDF in Coldfusion - wrong. CFPDF is only used to manipulate already existing PDF's.
It is the CFDOCUMENT tag that you use to actually do the initial creation.
Here is an example of how you would create a PDF and output it to the browser window:
2<cfdocument format="pdf" >
3 <cfoutput>
4
5 .... The PDF Content ....
6
7 <cfdocumentitem type="footer" evalatprint="true">
8 <table width="100%" border="0" cellpadding="0" cellspacing="0">
9 <tr><td align="center">Page #cfdocument.currentpagenumber# of
10 #cfdocument.totalpagecount#</td></tr>
11 </table>
12 </cfdocumentitem>
13 </cfoutput>
14</cfdocument>
If you want to be able to manipulate the PDF that you just created, like by adding or removing permissions, you would add the name attribute to the CFDOCUMENT tag and then use that variable with the CFPDF tag. Once you alter the tag though, you still need to output it to the browser, here we'll use the CFCONTENT tag, like we do with the excel documents that we create but we have to convert the variable to binary:
2<cfdocument format="pdf" localUrl="yes" name="contract_pdf" >
3 <cfoutput>
4
5 .... The PDF Content ....
6
7 <cfdocumentitem type="footer" evalatprint="true">
8 <table width="100%" border="0" cellpadding="0" cellspacing="0">
9 <tr><td align="center">Page #cfdocument.currentpagenumber# of
10 #cfdocument.totalpagecount#</td></tr>
11 </table>
12 </cfdocumentitem>
13 </cfoutput>
14</cfdocument>
15
16<!--- take away all permissions but the ability to print --->
17<cfpdf permissions="AllowPrinting" action="protect" newOwnerpassword="password" source="contract_pdf" >
18
19<!--- output the PDF to the browser --->
20<cfcontent type="application/pdf" variable="#tobinary(contract_pdf)#" reset="No" >
Team Ravenglass