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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>PDF Export Example</title>
	<style>
		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; }
	</style>
</head>
<body>
<h1>PDF Export Example</h1>
<p>This is an example, you can put any static or dynamic content here.</p>
</body>
</html></cfoutput>
</cfdocument>
Posted by
Snippet Viewed 15797 times.

Share your ColdFusion code snippets:

  • Get some recognition & link back to your site.
Submit | Browse

Most Recent coldfusion snippets

Most Viewed

The FitDesk Under Desk Elliptical