ColdFusion PDF export example using cfdocument tag

<cfsetting enablecfoutputonly="true">
<cfcontent type="application/pdf">
<cfheader name="Content-Disposition" value="attachment;filename=test.pdf">
<cfdocument format="PDF" localurl="yes" 
	marginTop=".25" marginLeft=".25" marginRight=".25" marginBottom=".25" 
	pageType="custom" pageWidth="8.5" pageHeight="10.2">
<cfoutput><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
	<title>PDF Export Example</title>
		body { font-family: Verdana,Arial,Helvetica; }
		h1 { font-size: 14px; }
		h2 { font-size: 13px; }
		h3 { font-size: 12px; }
		p { font-size: 11px; line-height: 1.25em; }
<h1>PDF Export Example</h1>
<p>This is an example, you can put any static or dynamic content here.</p>
Posted by
Snippet Viewed 16112 times.

Share your ColdFusion code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.
Submit | Browse

Most Recent coldfusion snippets

Most Viewed

The FitDesk Under Desk Elliptical