Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Both SrcFile And CFDocumentItem In The Same CFDocument Tag In Lucee CFML 5.3.7.47
<cfscript>
document
format = "pdf"
filename = "my-doc.pdf"
overwrite = true
{
```
<p>
I can haz PDF?!
</p>
```
}
</cfscript>
<cfscript>
stub = "./out/doc-#createUniqueId()#";
// Evaluate the CFML body that we're going to use for the PDF generation.
savecontent variable = "bodyContent" {
include "./render-body.cfm";
}
// Save the CFML document as a static HTML document. This is what we're going to use
// as the "srcfile" for the CFDocument tag.
fileWrite( "#stub#-body.html", bodyContent );
document
format = "pdf"
filename = "#stub#.pdf"
srcfile = "#stub#-body.html"
overwrite = true
localurl = true
{
// Note that we can mix both "srcfile" and CFDocumentItem techniques.
documentItem type = "header" {
```
<table width="100%" cellpadding="0" cellspacing="0" class="page-header">
<tr>
<td class="page-header__left">
Testing CFDocument
</td>
<td class="page-header__right">
SrcFile &amp; DocumentItem(s)
</td>
</tr>
</table>
```
}
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment