Whatever message this page gives is out now! Go check it out!
<cfdocument
format = "PDF|FlashPaper"
authPassword = "authentication password"
authUser = "authentication user name"
backgroundVisible = "yes|no"
bookmark = "yes|no"
encryption = "128-bit|40-bit|none"
filename = "filename"
fontEmbed = "yes|no"
formfields = "yes|no"
formsType = "FDF|PDF|HTML|XML"
localUrl = "yes|no"
marginBottom = "number"
marginLeft = "number"
marginRight = "number"
marginTop = "number"
mimeType = "text/plain|application/xml|image/jpeg|image/png|image/bmp|image/gif"
name = "output variable name"
openpassword = "password to open protected documents"
orientation = "portrait|landscape"
overwrite = "yes|no"
ownerPassword = "password"
pageHeight = "page height in inches"
pageType = "page type"
pageWidth = "page width in inches"
pdfa = "yes|no"
permissions = "permission list"
permissionspassword = "password to access restricted permissions"
proxyHost = "IP address or server name for proxy host"
proxyPassword = "password for the proxy host"
proxyPort = "port of the proxy host"
proxyUser = "user name for the proxy host"
saveAsName = "PDF filename"
scale = "percentage less than 100"
src = "URL|pathname relative to web root"
srcfile = "absolute pathname to a file"
tagged = "yes|no"
unit = "in|cm"
userAgent = "HTTP user agent identifier"
userPassword = "password">
HTML and CFML code
</cfdocument>Attribute | Req/Opt | Default | Description |
authPassword | Optional | Password sent to the target URL for Basic Authentication. Combined with username to form a base64 encoded string that is passed in the Authenticate header. Does not provide support for Integrated Windows, NTLM, or Kerebos authentication. | |
authUser | Optional | User name sent to the target URL for Basic Authentication. Combined with password to form a base64 encoded string that is passed in the Authenticate header. Does not provide support for Integrated Windows, NTLM, or Kerebos authentication. | |
backgroundVisible | Optional | no | Specifies whether the background prints when the user prints the document:
|
bookmark | Optional | no | Specifies whether bookmarks are created in the document:
|
encryption | Optional | none | (format="PDF" only) Specifies whether the output is encrypted:
|
filename | Optional | Pathname of a file to contain the PDF or FlashPaper output. If you omit the filename attribute, ColdFusion displays the output in the browser. | |
fontEmbed | Optional | yes | Specifies whether ColdFusion embeds fonts in the output:
|
format | Required | Report format:
| |
formfields | Optional | yes | This attribute is available only if you have integrated OpenOffice with ColdFusion.A Boolean value that specifies if form fields are exported as widgets or only their fixed print representation is exported. |
formstype | Optional | FDF | This attribute is available only if you have integrated OpenOffice with ColdFusion.Specifies the submitted format of a PDF form. It can be one of the following values:
|
localUrl | Optional | no | Specifies whether to retrieve image files directly from the local drive:
|
marginBottom | Optional | Bottom margin in inches (default) or centimeters. To specify the bottom margin in centimeters, include the unit=cm attribute. | |
marginLeft | Optional | Left margin in inches (default) or centimeters. To specify the left margin in centimeters, include the unit=cm attribute. | |
marginRight | Optional | Right margin in inches (default) or centimeters. To specify the right margin in centimeters, include the unit=cm attribute. | |
marginTop | Optional | Top margin in inches (default) or centimeters. To specify the top margin in centimeters, include the unit=cm attribute. | |
mimeType | Optional | text/ html | MIME type of the source document. Supported MIME types are:
|
name | Optional | Name of an existing variable into which the tag stores the PDF or FlashPaper output. | |
openpassword | Optional | This attribute is available only if you have integrated OpenOffice with ColdFusion.Password required to open a password-protected document. | |
orientation | Optional | portrait | Page orientation:
|
overwrite | Optional | no | Specifies whether ColdFusion overwrites an existing file. Used in conjunction with the filename attribute. |
ownerPassword | Optional | (format="PDF" only) Specifies the owner password.Cannot be same as userPassword. | |
pageHeight | Optional | Page height in inches (default) or centimeters. This attribute is only valid if pagetype=custom. To specify page height in centimeters, include the unit=cm attribute. | |
pageType | Optional | letter | Page type into which ColdFusion generates the report:
|
pageWidth | Optional | Page width in inches (default) or centimeters. This attribute is only valid if pageType=custom. To specify page width in centimeters, include the unit=cm attribute. | |
pdfa | Optional | no | This attribute is available only if you have integrated OpenOffice with ColdFusion.A Boolean value that specifies if you need to create a PDF of type PDF/A-1 (ISO 19005-1:2005 ) . |
permissionpasswrd | Optional | This attribute is available only if you have integrated OpenOffice with ColdFusion.Password required to access restricted permissions. The restricted permissions are specified using the permissions attribute. | |
permissions | Optional | (format="PDF" only) Sets one or more of the following permissions:
| |
proxyHost | Optional | Host name or IP address of a proxy server to which to send the request. | |
proxyPassword | Optional | Password required by the proxy server. | |
proxyPort | Optional | 80 | The port to connect to on the proxy server. |
proxyUser | Optional | User name to provide to the proxy server. | |
scale | Optional | Calculated by ColdFusion | Scale factor as a percentage. Use this option to reduce the size of the HTML output so that it fits on that paper. Specify a number less than 100. |
saveAsName | Optional | (format="PDF" only) The filename that appears in the SaveAs dialog when a user saves a PDF file written to the browser. | |
src | Optional | URL or the relative path to the web root. You cannot specify both the src and srcfile attributes. The file must be in a browser-writable format such as, HTML, HTM, BMP, PNG, and so on. | |
srcfile | Optional | Absolute path of a file that is on the server. You cannot specify both the src and srcfile attributes. The file must be a PPT file, a Word file, or be in a browser-writable format such as, HTML, HTM, BMP, PNG, and so on. | |
tagged | Optional | no | This attribute is available only if you have integrated OpenOffice with ColdFusion.A Boolean value that determines if the PDF is created using the Tagged PDF tag. |
unit | Optional | in | Default unit for the pageHeight, pageWidth , and margin attributes:
|
userAgent | Optional | ColdFusion | Text to put in the HTTP User-Agent request header field. Used to identify the request client software. |
userPassword | Optional | (format="PDF" only) Specifies a user password.Cannot be same as ownerPassword . |
ram:///filepath |
background | background-attachment | background-color | background-image |
background-position | background-repeat | border | border-bottom |
border-bottom-color | border-bottom-style (solid border only) | border-bottom-width | border-color |
border-left | border-left-color | border-left-style (solid border only) | border-left-width |
border-right | border-right-color | border-right-style (solid border only) | border-right-width |
border-spacing | border-style (solid border only) | border-top | border-top-color |
border-top-style (solid border only) | border-top-width | border-width | bottom |
clear | clip | color | content (strings, counters only) |
counter-increment | counter-reset | cursor | display |
float | font | font-family | font-size |
font-style | font-weight | height | left |
| line-height | line-style-type | margin | |
margin-bottom | margin-left | margin-right | margin-top |
outline | outline-color | outline-style (solid, dotted, dashed only) | outline-width |
padding | padding-bottom | padding-left | padding-right |
padding-top | page-break-after | page-break-before | page-break-inside |
position | right | text-align (left, right, and center) | text-decoration |
text-indent | top | unicode-bidi | vertical-align |
visibility | white space (normal, nowrap only) | width | z-index |
<cfdocument format="PDF">
<table>
<tr>
<td>bird</td>
<td><img src="images/bird.jpg"></td>
</tr>
<tr>
<td>fruit</td>
<td><img src="images/fruit.jpg"></td>
</tr>
<tr>
<td>rose</td>
<td><img src="images/rose.jpg"></td>
</tr>
</table>
</cfdocument><cfdocument localUrl="yes" format="PDF">
<table>
<tr>
<td>bird</td>
<td><img src="images/bird.jpg"></td>
</tr>
<tr>
<td>fruit</td>
<td><img src="images/fruit.jpg"></td>
</tr>
<tr>
<td>rose</td>
<td><img src="images/rose.jpg"></td>
</tr>
</table>
</cfdocument><cfdocument format="flashpaper">
<cfdocumentitem type="header" evalAtPrint="true">
<cfif (cfdocument.currentpagenumber mod 2) is 0>
<cfoutput>#cfdocument.totalpagecount#</cfoutput>
<cfelse>
<cfoutput>#cfdocument.currentpagenumber#</cfoutput>
</cfif>
</cfdocumentitem>
...
</cfdocument><cfdocument format="pdf">
<cfdocumentitem type="header" evalatprint="true" >
<cfif (cfdocument.currentpagenumber mod 2) is 0>
<cfoutput>#cfdocument.totalpagecount#</cfoutput>
<cfelse>
<cfoutput>#cfdocument.currentpagenumber#</cfoutput>
</cfif>
<cfoutput>cfdocument.currentpagenumber :#cfdocument.currentpagenumber#</cfoutput>
<cfoutput>cfdocument.totalpagecount :#cfdocument.totalpagecount#</cfoutput>
<cfoutput>cfdocument.totalsectionpagecount :#cfdocument.totalsectionpagecount#</cfoutput>
<cfoutput>cfdocument.currentsectionpagenumber :#cfdocument.currentsectionpagenumber#</cfoutput>
</cfdocumentitem>
<cfdocumentitem type="footer" evalatprint="true" >
<cfif ! (cfdocument.currentpagenumber mod 2) is 0>
<cfoutput>if#cfdocument.totalpagecount#</cfoutput>
<cfelse>
<cfoutput>else#cfdocument.currentpagenumber#</cfoutput>
</cfif>
</cfdocumentitem>
<cfdocumentsection >Example Text
</cfdocumentsection>
</cfdocument><!--- This example creates two bookmarks named "Section 1" and "Section 2" in a PDF file. --->
<cfdocument format="pdf" bookmark="yes">
<cfdocumentsection name="Section 1">
<!--- Insert HTML content here.--->
</cfdocumentsection>
<cfdocumentsection name="Section 2">
<!--- Insert HTML content here. --->
</cfdocumentsection>
</cfdocument><cfdocument format="PDF">
<cfoutput>#xmlFormat("This is a test content whose value is <= 0.89")#</cfoutput>
</cfdocument><!--- The following example shows how to use the cfdocument scope variables to generate section numbers and page numbers. --->
<cfdocument format="pdf">
<cfdocumentitem type="header" evalatprint="true">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="right"><cfoutput>#cfdocument.currentsectionpagenumber# of
#cfdocument.totalsectionpagecount#</cfoutput></td></tr>
</table>
</cfdocumentitem>
<cfdocumentitem type="footer" evalatprint="true">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center"><cfoutput>#cfdocument.currentpagenumber# of
#cfdocument.totalpagecount#</cfoutput></td></tr>
</table>
</cfdocumentitem>
<cfdocumentsection>
<h1>Section 1</h1>
<cfloop from=1 to=50 index="i">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<p>
</cfloop>
</cfdocumentsection>
<cfdocumentsection>
<h1>Section 2</h1>
<cfloop from=1 to=50 index="i">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<p>
</cfloop>
</cfdocumentsection>
<cfdocumentsection>
<h1>Section 3</h1>
<cfloop from=1 to=50 index="i">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<p>
</cfloop>
</cfdocumentsection>
</cfdocument><h1>Invoice PDF Generator Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfdocument to generate professional PDF invoices.</p>
<hr>
<cfscript>
// Sample invoice data
invoice = {
invoiceNumber: "INV-2024-001234",
invoiceDate: now(),
dueDate: dateAdd("d", 30, now()),
// Company information
company: {
name: "TechStore Inc.",
address: "123 Commerce Street",
city: "San Francisco, CA 94102",
phone: "(555) 123-4567",
email: "billing@techstore.com"
},
// Customer information
customer: {
name: "John Smith",
company: "Acme Corporation",
address: "456 Business Ave",
city: "New York, NY 10001",
email: "john.smith@acme.com"
},
// Line items (pre-sorted)
items: [
{id: 1, description: "Wireless Mouse", quantity: 2, unitPrice: 29.99},
{id: 2, description: "USB-C Cable (6ft)", quantity: 3, unitPrice: 12.99},
{id: 3, description: "Laptop Stand", quantity: 1, unitPrice: 45.50},
{id: 4, description: "Keyboard - Mechanical", quantity: 1, unitPrice: 89.99}
],
// Totals
subtotal: 0,
taxRate: 0.085,
taxAmount: 0,
shippingCost: 15.00,
total: 0
};
// Calculate totals
for (item in invoice.items) {
invoice.subtotal += item.quantity * item.unitPrice;
}
invoice.taxAmount = invoice.subtotal * invoice.taxRate;
invoice.total = invoice.subtotal + invoice.taxAmount + invoice.shippingCost;
</cfscript>
<h2>Example 1: Generate Invoice PDF (Display in Browser)</h2>
<cfdocument format="pdf" pageType="letter" orientation="portrait"
margintop="0.5" marginbottom="0.5" marginleft="0.75" marginright="0.75">
<!--- Header --->
<cfdocumentitem type="header">
<table width="100%" style="border-bottom: 2px solid ##333; padding-bottom: 10px;">
<tr>
<td style="width: 70%; font-size: 18px; font-weight: bold; color: ##0066cc;">
<cfoutput>#invoice.company.name#</cfoutput>
</td>
<td style="width: 30%; text-align: right; font-size: 12px;">
<cfoutput>Invoice ##: #invoice.invoiceNumber#</cfoutput>
</td>
</tr>
</table>
</cfdocumentitem>
<!--- Footer --->
<cfdocumentitem type="footer">
<table width="100%" style="border-top: 1px solid ##ccc; padding-top: 10px; font-size: 10px; color: ##666;">
<tr>
<td style="width: 50%;">
<cfoutput>#invoice.company.name# | #invoice.company.phone# | #invoice.company.email#</cfoutput>
</td>
<td style="width: 50%; text-align: right;">
<cfoutput>Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput>
</td>
</tr>
</table>
</cfdocumentitem>
<!--- Document body --->
<div style="font-family: Arial, sans-serif; font-size: 12px;">
<h1 style="color: ##0066cc; margin-top: 20px;">INVOICE</h1>
<!--- Company and Customer Info --->
<table width="100%" style="margin-top: 20px;">
<tr>
<td style="width: 50%; vertical-align: top;">
<p style="font-weight: bold;">From:</p>
<cfoutput>
<p>#invoice.company.name#<br>
#invoice.company.address#<br>
#invoice.company.city#<br>
Phone: #invoice.company.phone#<br>
Email: #invoice.company.email#</p>
</cfoutput>
</td>
<td style="width: 50%; vertical-align: top;">
<p style="font-weight: bold;">Bill To:</p>
<cfoutput>
<p>#invoice.customer.name#<br>
#invoice.customer.company#<br>
#invoice.customer.address#<br>
#invoice.customer.city#<br>
Email: #invoice.customer.email#</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Invoice Details --->
<table width="100%" style="margin-top: 20px; background-color: ##f0f0f0; padding: 10px;">
<tr>
<td style="width: 50%;">
<cfoutput>
<p><strong>Invoice Date:</strong> #dateFormat(invoice.invoiceDate, "mmmm d, yyyy")#</p>
</cfoutput>
</td>
<td style="width: 50%;">
<cfoutput>
<p><strong>Due Date:</strong> #dateFormat(invoice.dueDate, "mmmm d, yyyy")#</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Line Items --->
<table width="100%" style="margin-top: 30px; border-collapse: collapse;" border="1" cellpadding="8">
<tr style="background-color: ##0066cc; color: white;">
<th style="text-align: left;">Item</th>
<th style="text-align: center;">Quantity</th>
<th style="text-align: right;">Unit Price</th>
<th style="text-align: right;">Total</th>
</tr>
<cfloop array="#invoice.items#" index="item">
<cfset itemTotal = item.quantity * item.unitPrice>
<cfoutput>
<tr>
<td>#item.description#</td>
<td style="text-align: center;">#item.quantity#</td>
<td style="text-align: right;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="text-align: right;">$#numberFormat(itemTotal, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
</table>
<!--- Totals --->
<table width="100%" style="margin-top: 20px;">
<tr>
<td style="width: 70%;"></td>
<td style="width: 30%;">
<table width="100%" border="1" cellpadding="8" style="border-collapse: collapse;">
<cfoutput>
<tr>
<td><strong>Subtotal:</strong></td>
<td style="text-align: right;">$#numberFormat(invoice.subtotal, "0.00")#</td>
</tr>
<tr>
<td><strong>Tax (#numberFormat(invoice.taxRate * 100, "0.0")#%):</strong></td>
<td style="text-align: right;">$#numberFormat(invoice.taxAmount, "0.00")#</td>
</tr>
<tr>
<td><strong>Shipping:</strong></td>
<td style="text-align: right;">$#numberFormat(invoice.shippingCost, "0.00")#</td>
</tr>
<tr style="background-color: ##0066cc; color: white; font-size: 14px;">
<td><strong>TOTAL:</strong></td>
<td style="text-align: right;"><strong>$#numberFormat(invoice.total, "0.00")#</strong></td>
</tr>
</cfoutput>
</table>
</td>
</tr>
</table>
<!--- Payment Terms --->
<div style="margin-top: 40px; padding: 15px; background-color: ##f9f9f9; border-left: 4px solid ##0066cc;">
<p style="font-weight: bold;">Payment Terms:</p>
<p>Payment is due within 30 days of invoice date. Please include invoice number with payment.</p>
<p><strong>Make checks payable to:</strong> <cfoutput>#invoice.company.name#</cfoutput></p>
<p style="margin-top: 20px;"><strong>Thank you for your business!</strong></p>
</div>
</div>
</cfdocument>
<hr>
<p><strong>PDF generated successfully!</strong> The invoice was displayed inline in your browser.</p>
<h2>Example 2: Save Invoice PDF to File</h2>
<cfscript>
// Create a simple invoice for file save demo
simpleInvoice = {
number: "INV-2024-" & randRange(1000, 9999),
date: now(),
customerName: "Jane Doe",
amount: 299.99
};
</cfscript>
<cfset pdfFilename = "invoice_" & dateFormat(now(), "yyyymmdd") & "_" & timeFormat(now(), "HHmmss") & ".pdf">
<cfset pdfPath = expandPath("./") & pdfFilename>
<cftry>
<cfdocument format="pdf" filename="#pdfPath#" overwrite="true">
<div style="font-family: Arial; padding: 40px;">
<h1>Invoice</h1>
<cfoutput>
<p><strong>Invoice Number:</strong> #simpleInvoice.number#</p>
<p><strong>Date:</strong> #dateFormat(simpleInvoice.date, "mmmm d, yyyy")#</p>
<p><strong>Customer:</strong> #simpleInvoice.customerName#</p>
<p><strong>Amount Due:</strong> $#numberFormat(simpleInvoice.amount, "0.00")#</p>
</cfoutput>
</div>
</cfdocument>
<cfoutput>
<p><strong>✓ PDF saved successfully!</strong></p>
<p>Filename: #pdfFilename#</p>
<p>Location: #pdfPath#</p>
<p><a href="#pdfFilename#" target="_blank">Download Invoice PDF</a></p>
</cfoutput>
<cfcatch type="any">
<cfoutput>
<p><strong>✗ Error saving PDF:</strong> #cfcatch.message#</p>
</cfoutput>
</cfcatch>
</cftry>
<hr><h1>Monthly Sales Report PDF Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfdocument to generate multi-page business reports with sections and page breaks.</p>
<hr>
<cfscript>
// Report data
reportData = {
month: "November",
year: 2024,
generatedDate: now(),
// Summary metrics
summary: {
totalSales: 487500.00,
totalOrders: 342,
averageOrderValue: 1425.73,
newCustomers: 45,
returningCustomers: 89
},
// Regional sales (pre-sorted)
regionalSales: [
{region: "East", sales: 145000.00, orders: 98, growth: 12.5},
{region: "West", sales: 198000.00, orders: 134, growth: 18.3},
{region: "North", sales: 87500.00, orders: 67, growth: -3.2},
{region: "South", sales: 57000.00, orders: 43, growth: 5.8}
],
// Top products
topProducts: [
{name: "Laptop Pro 15", units: 145, revenue: 217500.00},
{name: "Wireless Mouse", units: 342, revenue: 10260.00},
{name: "Monitor 27 inch", units: 89, revenue: 35600.00},
{name: "Keyboard Mechanical", units: 156, revenue: 14040.00}
]
};
</cfscript>
<h2>Generate Monthly Sales Report PDF</h2>
<cfdocument format="pdf" pageType="letter" orientation="portrait" bookmark="yes"
margintop="0.75" marginbottom="0.75" marginleft="0.75" marginright="0.75">
<!--- Header --->
<cfdocumentitem type="header" evalatprint="true">
<table width="100%" style="border-bottom: 2px solid ##0066cc;">
<tr>
<td style="width: 60%; font-size: 14px; font-weight: bold; color: ##0066cc;">
<cfoutput>Monthly Sales Report - #reportData.month# #reportData.year#</cfoutput>
</td>
<td style="width: 40%; text-align: right; font-size: 10px; color: ##666;">
<cfoutput>Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput>
</td>
</tr>
</table>
</cfdocumentitem>
<!--- Footer --->
<cfdocumentitem type="footer" evalatprint="true">
<table width="100%" style="border-top: 1px solid ##ccc; padding-top: 5px;">
<tr>
<td style="width: 50%; font-size: 9px; color: ##666;">
<cfoutput>Generated: #dateFormat(reportData.generatedDate, "mm/dd/yyyy")# at #timeFormat(reportData.generatedDate, "h:mm tt")#</cfoutput>
</td>
<td style="width: 50%; text-align: right; font-size: 9px; color: ##666;">
Confidential - For Internal Use Only
</td>
</tr>
</table>
</cfdocumentitem>
<!--- Section 1: Executive Summary --->
<cfdocumentsection name="Executive Summary">
<div style="font-family: Arial, sans-serif; font-size: 12px;">
<h1 style="color: ##0066cc; margin-top: 20px;">
<cfoutput>#reportData.month# #reportData.year# Sales Report</cfoutput>
</h1>
<h2 style="color: ##333; border-bottom: 2px solid ##0066cc; padding-bottom: 5px;">Executive Summary</h2>
<!--- Key Metrics Grid --->
<table width="100%" style="margin-top: 20px;" cellpadding="15">
<tr>
<td style="width: 33%; background-color: ##e3f2fd; text-align: center; border: 1px solid ##90caf9;">
<p style="font-size: 10px; color: ##666; margin: 0;">Total Sales</p>
<cfoutput>
<p style="font-size: 24px; font-weight: bold; color: ##0066cc; margin: 5px 0;">$#numberFormat(reportData.summary.totalSales, "0,000")#</p>
</cfoutput>
</td>
<td style="width: 33%; background-color: ##e8f5e9; text-align: center; border: 1px solid ##a5d6a7;">
<p style="font-size: 10px; color: ##666; margin: 0;">Total Orders</p>
<cfoutput>
<p style="font-size: 24px; font-weight: bold; color: ##2e7d32; margin: 5px 0;">#reportData.summary.totalOrders#</p>
</cfoutput>
</td>
<td style="width: 33%; background-color: ##fff3e0; text-align: center; border: 1px solid ##ffb74d;">
<p style="font-size: 10px; color: ##666; margin: 0;">Avg Order Value</p>
<cfoutput>
<p style="font-size: 24px; font-weight: bold; color: ##e65100; margin: 5px 0;">$#numberFormat(reportData.summary.averageOrderValue, "0,000")#</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Customer Metrics --->
<div style="margin-top: 30px; padding: 15px; background-color: ##f5f5f5;">
<h3 style="color: ##333; margin-top: 0;">Customer Metrics</h3>
<cfoutput>
<p>New Customers: <strong>#reportData.summary.newCustomers#</strong></p>
<p>Returning Customers: <strong>#reportData.summary.returningCustomers#</strong></p>
<p>Customer Retention Rate: <strong>#numberFormat((reportData.summary.returningCustomers / (reportData.summary.newCustomers + reportData.summary.returningCustomers)) * 100, "0.0")#%</strong></p>
</cfoutput>
</div>
</div>
</cfdocumentsection>
<!--- Page Break --->
<cfdocumentitem type="pagebreak" />
<!--- Section 2: Regional Performance --->
<cfdocumentsection name="Regional Performance">
<div style="font-family: Arial, sans-serif; font-size: 12px;">
<h2 style="color: ##333; border-bottom: 2px solid ##0066cc; padding-bottom: 5px;">Regional Performance</h2>
<table width="100%" style="margin-top: 20px; border-collapse: collapse;" border="1" cellpadding="10">
<tr style="background-color: ##0066cc; color: white;">
<th style="text-align: left;">Region</th>
<th style="text-align: right;">Sales</th>
<th style="text-align: right;">Orders</th>
<th style="text-align: right;">Growth</th>
</tr>
<cfloop array="#reportData.regionalSales#" index="region">
<cfset growthColor = region.growth GTE 0 ? "##2e7d32" : "##c62828">
<cfset growthIcon = region.growth GTE 0 ? "▲" : "▼">
<cfoutput>
<tr>
<td><strong>#region.region#</strong></td>
<td style="text-align: right;">$#numberFormat(region.sales, "0,000")#</td>
<td style="text-align: right;">#region.orders#</td>
<td style="text-align: right; color: #growthColor#;">
#growthIcon# #numberFormat(abs(region.growth), "0.0")#%
</td>
</tr>
</cfoutput>
</cfloop>
<cfoutput>
<tr style="background-color: ##f5f5f5; font-weight: bold;">
<td>TOTAL</td>
<td style="text-align: right;">$#numberFormat(reportData.summary.totalSales, "0,000")#</td>
<td style="text-align: right;">#reportData.summary.totalOrders#</td>
<td></td>
</tr>
</cfoutput>
</table>
<!--- Regional Insights --->
<div style="margin-top: 30px; padding: 15px; background-color: ##e3f2fd; border-left: 4px solid ##0066cc;">
<h3 style="margin-top: 0;">Key Insights:</h3>
<ul>
<li><strong>West Region</strong> continues to lead with 18.3% growth</li>
<li><strong>East Region</strong> shows steady 12.5% growth</li>
<li><strong>North Region</strong> requires attention (-3.2% decline)</li>
<li><strong>South Region</strong> demonstrates stable 5.8% growth</li>
</ul>
</div>
</div>
</cfdocumentsection>
<!--- Page Break --->
<cfdocumentitem type="pagebreak" />
<!--- Section 3: Top Products --->
<cfdocumentsection name="Top Products">
<div style="font-family: Arial, sans-serif; font-size: 12px;">
<h2 style="color: ##333; border-bottom: 2px solid ##0066cc; padding-bottom: 5px;">Top Performing Products</h2>
<table width="100%" style="margin-top: 20px; border-collapse: collapse;" border="1" cellpadding="10">
<tr style="background-color: ##2e7d32; color: white;">
<th style="text-align: left;">Product Name</th>
<th style="text-align: right;">Units Sold</th>
<th style="text-align: right;">Revenue</th>
</tr>
<cfloop array="#reportData.topProducts#" index="product">
<cfoutput>
<tr>
<td><strong>#product.name#</strong></td>
<td style="text-align: right;">#product.units#</td>
<td style="text-align: right;">$#numberFormat(product.revenue, "0,000")#</td>
</tr>
</cfoutput>
</cfloop>
</table>
<!--- Recommendations --->
<div style="margin-top: 30px; padding: 15px; background-color: ##fff3e0; border-left: 4px solid ##ff9800;">
<h3 style="margin-top: 0;">Recommendations:</h3>
<ol>
<li>Increase inventory for Laptop Pro 15 based on strong demand</li>
<li>Bundle Wireless Mouse with laptop purchases for higher margins</li>
<li>Promote Monitor 27" to existing laptop customers</li>
<li>Develop marketing campaign for mechanical keyboards</li>
</ol>
</div>
<!--- Report Summary --->
<div style="margin-top: 40px; padding: 20px; background-color: ##f5f5f5; border: 2px solid ##0066cc;">
<h3 style="color: ##0066cc; margin-top: 0;">Report Summary</h3>
<cfoutput>
<p><strong>#reportData.month# #reportData.year#</strong> shows strong overall performance with total sales of <strong>$#numberFormat(reportData.summary.totalSales, "0,000")#</strong> across <strong>#reportData.summary.totalOrders#</strong> orders.</p>
<p>West and East regions drive growth, while North region requires strategic attention. Product portfolio demonstrates healthy diversification with strong performance in high-value items.</p>
</cfoutput>
</div>
</div>
</cfdocumentsection>
</cfdocument>
<p><strong>✓ Multi-page sales report PDF generated successfully!</strong></p>
<p>The report includes 3 sections with bookmarks, headers, footers, and automatic pagination.</p>
<hr><cfscript>
// Certificate data
certificate = {
certificateNumber: "CERT-" & year(now()) & "-" & randRange(10000, 99999),
studentName: "Jennifer Martinez",
courseName: "Advanced ColdFusion Development",
courseHours: 40,
completionDate: dateAdd("d", -5, now()),
instructorName: "Dr. Michael Chen",
issueDate: now(),
institution: "TechLearning Academy"
};
</cfscript>
<h2>Generate Certificate of Completion PDF</h2>
<cfdocument format="pdf" pageType="letter" orientation="landscape"
margintop="0" marginbottom="0" marginleft="0" marginright="0">
<div style="
width: 100%;
height: 100vh;
background: linear-gradient(135deg, ##667eea 0%, ##764ba2 100%);
font-family: Georgia, serif;
position: relative;
padding: 40px;
box-sizing: border-box;
">
<!--- Decorative border --->
<div style="
border: 8px solid gold;
border-radius: 10px;
background-color: white;
padding: 50px;
height: calc(100% - 80px);
position: relative;
">
<!--- Inner decorative border --->
<div style="
border: 2px solid ##333;
padding: 40px;
height: 100%;
text-align: center;
">
<!--- Certificate Header --->
<div style="margin-bottom: 30px;">
<cfoutput>
<p style="font-size: 16px; color: ##666; letter-spacing: 3px; margin: 0;">
#uCase(certificate.institution)#
</p>
</cfoutput>
</div>
<!--- Certificate Title --->
<h1 style="
font-size: 48px;
color: ##1a1a1a;
margin: 20px 0;
font-weight: normal;
letter-spacing: 2px;
">
Certificate of Completion
</h1>
<!--- Divider --->
<div style="
width: 200px;
height: 3px;
background-color: gold;
margin: 20px auto;
"></div>
<!--- This is to certify text --->
<p style="font-size: 16px; color: ##666; margin: 30px 0 10px 0;">
This is to certify that
</p>
<!--- Student Name --->
<cfoutput>
<h2 style="
font-size: 42px;
color: ##1a1a1a;
margin: 10px 0 30px 0;
font-style: italic;
text-decoration: underline;
">
#certificate.studentName#
</h2>
</cfoutput>
<!--- Has successfully completed text --->
<p style="font-size: 16px; color: ##666; margin: 10px 0;">
has successfully completed the course
</p>
<!--- Course Name --->
<cfoutput>
<h3 style="
font-size: 28px;
color: ##1a1a1a;
margin: 15px 0;
font-weight: bold;
">
#certificate.courseName#
</h3>
</cfoutput>
<!--- Course Details --->
<cfoutput>
<p style="font-size: 14px; color: ##666; margin: 5px 0 30px 0;">
(#certificate.courseHours# hours | Completed on #dateFormat(certificate.completionDate, "mmmm d, yyyy")#)
</p>
</cfoutput>
<!--- Signature Section --->
<table width="100%" style="margin-top: 60px;">
<tr>
<td style="width: 50%; text-align: center; vertical-align: bottom;">
<div style="
border-top: 2px solid ##333;
width: 60%;
margin: 0 auto 10px auto;
"></div>
<cfoutput>
<p style="font-size: 14px; color: ##333; margin: 0; font-weight: bold;">
#certificate.instructorName#
</p>
<p style="font-size: 12px; color: ##666; margin: 5px 0 0 0;">
Course Instructor
</p>
</cfoutput>
</td>
<td style="width: 50%; text-align: center; vertical-align: bottom;">
<div style="
border-top: 2px solid ##333;
width: 60%;
margin: 0 auto 10px auto;
"></div>
<cfoutput>
<p style="font-size: 14px; color: ##333; margin: 0; font-weight: bold;">
#dateFormat(certificate.issueDate, "mmmm d, yyyy")#
</p>
<p style="font-size: 12px; color: ##666; margin: 5px 0 0 0;">
Date Issued
</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Certificate Number (bottom right) --->
<cfoutput>
<div style="
position: absolute;
bottom: 20px;
right: 40px;
font-size: 10px;
color: ##999;
">
Certificate No: #certificate.certificateNumber#
</div>
</cfoutput>
</div>
</div>
</div>
</cfdocument>
<p><strong>✓ Certificate PDF generated successfully!</strong></p>
<p>The certificate features a professional landscape layout with elegant styling.</p>
<hr>
<h2>Example 2: Batch Generate Certificates</h2>
<cfscript>
// Multiple students who completed a course
completedStudents = [
{name: "Sarah Johnson", completionDate: createDate(2024, 11, 1)},
{name: "Michael Brown", completionDate: createDate(2024, 11, 3)},
{name: "Emily Davis", completionDate: createDate(2024, 11, 5)}
];
courseName = "Introduction to Web Development";
instructorName = "Prof. Amanda Lee";
</cfscript>
<p><strong>Generating certificates for <cfoutput>#arrayLen(completedStudents)#</cfoutput> students...</strong></p>
<cfloop array="#completedStudents#" index="student">
<cfset certNumber = "CERT-" & year(now()) & "-" & randRange(10000, 99999)>
<cfdocument format="pdf" filename="#expandPath('./')#certificate_#replace(student.name, ' ', '_', 'ALL')#.pdf" overwrite="true">
<div style="
width: 100%;
min-height: 600px;
background-color: ##f5f5f5;
font-family: Arial, sans-serif;
padding: 40px;
text-align: center;
">
<div style="
background-color: white;
border: 5px solid ##0066cc;
padding: 40px;
border-radius: 15px;
">
<h1 style="color: ##0066cc; font-size: 36px;">Certificate of Completion</h1>
<p style="font-size: 14px; color: ##666; margin: 20px 0;">This certifies that</p>
<cfoutput>
<h2 style="font-size: 32px; color: ##333; margin: 15px 0;">#student.name#</h2>
</cfoutput>
<p style="font-size: 14px; color: ##666;">has successfully completed</p>
<cfoutput>
<h3 style="font-size: 24px; color: ##0066cc; margin: 15px 0;">#courseName#</h3>
</cfoutput>
<cfoutput>
<p style="font-size: 14px; color: ##666; margin: 30px 0;">
Completion Date: #dateFormat(student.completionDate, "mmmm d, yyyy")#
</p>
</cfoutput>
<div style="margin-top: 50px;">
<div style="display: inline-block; width: 200px; border-top: 2px solid ##333;">
<cfoutput>
<p style="margin: 10px 0 0 0; font-size: 12px;">#instructorName#</p>
<p style="margin: 0; font-size: 10px; color: ##666;">Instructor</p>
</cfoutput>
</div>
</div>
<cfoutput>
<p style="font-size: 9px; color: ##999; margin-top: 40px;">Certificate No: #certNumber#</p>
</cfoutput>
</div>
</div>
</cfdocument>
<cfoutput>
<p>✓ Generated: certificate_#replace(student.name, " ", "_", "ALL")#.pdf</p>
</cfoutput>
</cfloop>
<p><strong>Batch generation complete!</strong> All certificates have been saved to the current directory.</p>
<hr><h1>Contract/Agreement Generator Demo</h1>
<p><strong>What This Demo Shows:</strong> How to use cfdocument to generate professional contracts and service agreements.</p>
<hr>
<cfscript>
// Contract data
contract = {
contractNumber: "SA-" & year(now()) & "-" & randRange(1000, 9999),
effectiveDate: now(),
expirationDate: dateAdd("y", 1, now()),
// Service provider (company)
provider: {
name: "TechServices Inc.",
address: "123 Business Plaza",
city: "San Francisco, CA 94102",
phone: "(555) 123-4567",
email: "contracts@techservices.com"
},
// Client information
client: {
name: "John Smith",
company: "Acme Corporation",
address: "456 Client Street",
city: "New York, NY 10001",
phone: "(555) 987-6543",
email: "john.smith@acme.com"
},
// Service details
service: {
name: "Premium Cloud Hosting",
description: "24/7 managed cloud hosting with 99.9% uptime guarantee",
monthlyFee: 299.99,
setupFee: 499.99,
billingCycle: "Monthly"
}
};
</cfscript>
<h2>Generate Service Agreement PDF</h2>
<cfdocument format="pdf" pageType="letter" orientation="portrait"
margintop="1" marginbottom="1" marginleft="1" marginright="1">
<!--- Header --->
<cfdocumentitem type="header">
<table width="100%" style="border-bottom: 1px solid ##333; padding-bottom: 5px;">
<tr>
<td style="font-size: 10px; font-weight: bold;">
<cfoutput>SERVICE AGREEMENT - #contract.contractNumber#</cfoutput>
</td>
<td style="text-align: right; font-size: 9px;">
<cfoutput>Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput>
</td>
</tr>
</table>
</cfdocumentitem>
<!--- Footer --->
<cfdocumentitem type="footer">
<p style="font-size: 8px; color: ##666; text-align: center; border-top: 1px solid ##ccc; padding-top: 5px;">
<cfoutput>
This is a legally binding agreement. Contract ##: #contract.contractNumber# | Generated: #dateFormat(now(), "mm/dd/yyyy")#
</cfoutput>
</p>
</cfdocumentitem>
<!--- Contract Content --->
<div style="font-family: Times New Roman, serif; font-size: 12px;">
<!--- Title --->
<h1 style="text-align: center; font-size: 20px; margin: 20px 0;">SERVICE AGREEMENT</h1>
<cfoutput>
<p style="text-align: center; font-size: 11px; margin: 5px 0;">
Contract Number: #contract.contractNumber#
</p>
<p style="text-align: center; font-size: 11px; margin: 5px 0 30px 0;">
Effective Date: #dateFormat(contract.effectiveDate, "mmmm d, yyyy")#
</p>
</cfoutput>
<!--- Parties Section --->
<p style="font-weight: bold; margin-top: 20px;">THIS AGREEMENT is entered into as of the date specified above between:</p>
<table width="100%" style="margin: 20px 0;" cellpadding="10">
<tr>
<td style="width: 50%; vertical-align: top; border: 1px solid ##ddd; background-color: ##f9f9f9;">
<p style="font-weight: bold;">SERVICE PROVIDER:</p>
<cfoutput>
<p>#contract.provider.name#<br>
#contract.provider.address#<br>
#contract.provider.city#<br>
Phone: #contract.provider.phone#<br>
Email: #contract.provider.email#</p>
</cfoutput>
</td>
<td style="width: 50%; vertical-align: top; border: 1px solid ##ddd; background-color: ##f9f9f9;">
<p style="font-weight: bold;">CLIENT:</p>
<cfoutput>
<p>#contract.client.name#<br>
#contract.client.company#<br>
#contract.client.address#<br>
#contract.client.city#<br>
Phone: #contract.client.phone#<br>
Email: #contract.client.email#</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Services Section --->
<h2 style="font-size: 14px; border-bottom: 2px solid ##333; padding-bottom: 5px;">1. SERVICES PROVIDED</h2>
<cfoutput>
<p><strong>Service Name:</strong> #contract.service.name#</p>
<p><strong>Description:</strong> #contract.service.description#</p>
</cfoutput>
<!--- Term Section --->
<h2 style="font-size: 14px; border-bottom: 2px solid ##333; padding-bottom: 5px; margin-top: 20px;">2. TERM</h2>
<cfoutput>
<p>This Agreement shall commence on #dateFormat(contract.effectiveDate, "mmmm d, yyyy")# and shall continue for a period of one (1) year, expiring on #dateFormat(contract.expirationDate, "mmmm d, yyyy")#, unless earlier terminated as provided herein.</p>
</cfoutput>
<!--- Fees Section --->
<h2 style="font-size: 14px; border-bottom: 2px solid ##333; padding-bottom: 5px; margin-top: 20px;">3. FEES AND PAYMENT</h2>
<cfoutput>
<p><strong>Setup Fee:</strong> $#numberFormat(contract.service.setupFee, "0,000.00")# (one-time, due upon signing)</p>
<p><strong>Monthly Service Fee:</strong> $#numberFormat(contract.service.monthlyFee, "0,000.00")#</p>
<p><strong>Billing Cycle:</strong> #contract.service.billingCycle#</p>
</cfoutput>
<p>Payment is due within fifteen (15) days of invoice date. Late payments may incur a 1.5% monthly interest charge.</p>
<!--- Terms and Conditions --->
<h2 style="font-size: 14px; border-bottom: 2px solid ##333; padding-bottom: 5px; margin-top: 20px;">4. TERMS AND CONDITIONS</h2>
<p><strong>4.1 Service Availability:</strong> Provider agrees to use commercially reasonable efforts to maintain 99.9% uptime for the services.</p>
<p><strong>4.2 Client Responsibilities:</strong> Client agrees to provide accurate information and maintain security of account credentials.</p>
<p><strong>4.3 Confidentiality:</strong> Both parties agree to maintain confidentiality of proprietary information shared during the term of this agreement.</p>
<p><strong>4.4 Termination:</strong> Either party may terminate this agreement with thirty (30) days written notice. Early termination fees may apply.</p>
<!--- Page Break --->
<cfdocumentitem type="pagebreak" />
<!--- Signatures Section --->
<h2 style="font-size: 14px; border-bottom: 2px solid ##333; padding-bottom: 5px; margin-top: 20px;">5. ACCEPTANCE AND SIGNATURES</h2>
<p>By signing below, both parties acknowledge that they have read, understood, and agree to be bound by the terms and conditions of this Agreement.</p>
<table width="100%" style="margin-top: 60px;">
<tr>
<td style="width: 50%; padding-right: 20px;">
<div style="border-top: 2px solid ##333; margin-bottom: 10px;"></div>
<cfoutput>
<p style="margin: 0;"><strong>Provider Signature</strong></p>
<p style="margin: 5px 0 0 0; font-size: 11px;">#contract.provider.name#</p>
<p style="margin: 5px 0 0 0; font-size: 11px;">Date: ____________________</p>
</cfoutput>
</td>
<td style="width: 50%; padding-left: 20px;">
<div style="border-top: 2px solid ##333; margin-bottom: 10px;"></div>
<cfoutput>
<p style="margin: 0;"><strong>Client Signature</strong></p>
<p style="margin: 5px 0 0 0; font-size: 11px;">#contract.client.name#</p>
<p style="margin: 5px 0 0 0; font-size: 11px;">Date: ____________________</p>
</cfoutput>
</td>
</tr>
</table>
<!--- Legal Notice --->
<div style="margin-top: 60px; padding: 15px; background-color: ##f5f5f5; border: 1px solid ##ddd;">
<p style="font-size: 10px; margin: 0;">
<strong>LEGAL NOTICE:</strong> This is a legally binding agreement. If you do not understand any provision of this agreement, please consult with legal counsel before signing.
</p>
</div>
</div>
</cfdocument>
<p><strong>✓ Service agreement PDF generated successfully!</strong></p>
<p>The contract is ready for review and signatures.</p>
<hr>