Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Using the cfdocument Tag

Using the cfdocument Tag

This is the most exciting part of introducing this feature—showing you how to use it!

Sample 1: Using the cfdocument with cfhttp tag

This is what makes the cfdocument tag powerful. There is no need to edit your current HTML. You just redirect the content of the HTTP request through the cfdocument tag (see Figure 1):

<cfhttp url="http://www.w3.org/TR/REC-html32" method="get" resolveURL="true">
<cfdocument format="flashpaper">
<cfoutput>#cfhttp.filecontent#</cfoutput>
</cfdocument>

Code in Sample 1 printing the HTML content as you see it on the web page

Figure 1. Code in Sample 1 printing the HTML content as you see it on the web page

Sample 2: Using the cfdocument tag with existing third-party report output

If you use a third-party reporting engine and plan to output the results in HTML, you can use the cfdocument tag to help create a portable document exactly as it appears. This saves much time and effort on your part because you don’t need to recreate reports just for the purpose of printing to rich document formats. You simply wrap your query/report result with the tag and it gives you the desired printing result (see Figure 2).

Creating portable documents from third-party reporting engines

Figure 2. Creating portable documents from third-party reporting engines

Sample 3: Creating portable documents for easier sharing

Besides printing in a visually appealing format, you can use the cfdocument tag to create documents that are portable and that you can combine with the cfmail tag to send output to other users:

<cfhttp url="http://www.w3.org/TR/REC-html32" method="get" resolveURL="true">
<cfdocument format="flashpaper" filename="c: empw3spec.swf">
<cfoutput>#cfhttp.filecontent#</cfoutput>
</cfdocument>
<cfmail to = "recipient"
from = "sender"
subject = "msg_subject"
MIMEAttach = "c: empw3spec.swf">
Hi John, here is the spec you were looking for. Regards, </cfmail>

Sample 4: Bidirectional text support

If you write text from right to left, you can now use the cfdocument tag to print (only available in PDF).

Bidirectional language support in PDF format

Figure 3. Bidirectional language support in PDF format

Comments