advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Have you ever thought about using ASP to output content other than HTML? Do you think RTF is a good choice or do you prefer PDF files, or some other format? Do you even believe RTF is a reasonable cross-platform specification? What do you think of this approach? Let us know in the DevX Web discussion group.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

How To Output RTF-formatted Documents with ASP

HTML isn't your only choice for displaying content from ASP. Learn how to build a simple class to generate RTF documents and tables on the fly with basic text and paragraph formatting. 


advertisement
SP is a great technology for delivering custom HTML-based content to a Web page. You can also use ASP to create output for print and distribution beyond Web pages. In fact, ASP can be a great medium for creating complex reports in a variety of formats. This article shows you how to use ASP to generate RTF files, and gives you some simple functions for formatting blocks of text and paragraphs as well as a function to produce an RTF table from a SQL query. The ASP makeTable function produces a generic table containing data from a query that you can then format as needed in your favorite word processing application.

Why RTF?
RTF (Rich Text Format) is designed to be platform-independent without losing detailed formatting. According to Microsoft,

"The RTF Specification provides a format for text and graphics interchange that can be used with different output devices, operating environments, and operating systems. RTF uses the American National Standards Institute (ANSI), PC-8, Macintosh, or IBM PC character set to control the representation and formatting of a document, both on the screen and in print. With the RTF Specification, documents created under different operating systems and with different software applications can be transferred between those operating systems and applications."
Obviously, one advantage of outputting to RTF is platform-independence. Perhaps a more important advantage for some developers is that the ASP-to-RTF output code does not require any special configuration on the hosting Web server beyond permission to use the FileSystemObject in a specific location. Outputting a Microsoft Word file, for example, requires the hosting Web server to have Word installed and an requires an administrator to configure the server permissions so the ASP engine can run it. Unfortunately, running Word incurs server overhead (especially when multiple instances of Word are open and unused instances aren't closed appropriately). In addition, using Word automation creates another potential security problem: Word is VBA-aware. Running Word on a Web server remotely can expose the server to embedded macros. <

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement