<!-- #INCLUDE FILE="../library/rtflib_20050408.asp" -->
<%

dim RTF_OUTPUT, filename, filespec
dim objFSO, objTextStream

RTF_OUTPUT = ""
RTF_OUTPUT = QuickDrawRTFHeader(RTF_LANDSCAPE,"1","1","1","1",RTF_PROTECTED,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) 'put 1 inch margins all around
RTF_OUTPUT = RTF_OUTPUT & DrawParagraph("This saves the RTF content to a file, and then opens the file as a link for the user.  The remainder of the examples stream directly to the user's browser without creating a local file first.    ")
RTF_OUTPUT = RTF_OUTPUT & RTF_LINE_BREAK
RTF_OUTPUT = RTF_OUTPUT & DrawParagraph("For reports or documents that do not change very often, or that require a high volume of readership, or that are required to be archived, it might make sense to save them to file, instead of generating them on the fly.   ")
RTF_OUTPUT = RTF_OUTPUT & RTF_LINE_BREAK
RTF_OUTPUT = RTF_OUTPUT & DrawParagraph("For example, you could check the file date, and if it's over an hour hold, regenerate the file, else deliver the existing file to the user.   Alternately, you could schedule the web page to generate the report once an hour, and just link to the RTF file directly.")
RTF_OUTPUT = RTF_OUTPUT & QuickDrawRTFFooter()

filename = "sample_writetofile.rtf"
filespec = Server.MapPath(filename)

Set objFSO = CreateObject("Scripting.FileSystemObject")
set objTextStream = objFSO.OpenTextFile (filespec , 2, TRUE) 
objTextStream.Write(RTF_OUTPUT)
objTextStream.Close
SET objFSO = nothing

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>

<a href="<%=filename%>">OPEN THE GENERATED RTF DOC</A>

</body>
</html>