Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created May 7, 2021 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennadel/2deecd79df710794cdb84f9a72927d06 to your computer and use it in GitHub Desktop.
Save bennadel/2deecd79df710794cdb84f9a72927d06 to your computer and use it in GitHub Desktop.
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