Introducing cfdocument


Introducing <cfdocument>

The inability to be able to easily generate printable content from within Web pages has long been a source of serious aggravation for Web application developers (all developers, not just ColdFusion developers). And considering that a very significant chunk of Web application development tends to be data reporting and presentation type applications, this is even a bigger problem.

The truth is, Web browsers just don't print Web pages properly, and so developers have had to resort to complex and painful workarounds so as to generate content in a format that is indeed printable.

ColdFusion solves this problem simply with the <cfdocument> family of tags, as seen in this snippet:

 <cfdocument format="pdf"> Hello world! </cfdocument> 

By wrapping text in between <cfdocument> and </cfdocument> tags, content between those tags is converted into a PDF file on-the-fly, and embedded in the page.

NOTE

When generating printable output using <cfdocument> it is not necessary to set the MIME type using <cfcontent>, ColdFusion does this automatically.


In addition to PDF, ColdFusion can generate Flash paper, a lightweight alternative to PDF, and one that only requires that the Flash Player be present on the browser. To generate FlashPaper, simple change format="pdf" to format="flashpaper".

Printable content is not limited to static text, and can use dynamic CFML within the document content too. <cfdocument> thus makes generating printable versions of existing pages (static or dynamic) incredibly easy.

TIP

The easiest way to create both screen and print versions of the same page is to create the page as you'd do now, and then create a print version which contains <cfdocument> and </cfdocument> tags with a <cfinclude> in between them (including the page to be printed).




Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net