Introduction
This article is about generating RTF documents from the source code. For this purpose, a free C-library is developed in order to help developers. Considering this release, 100% compatibility is achieved only with MS Word 97 to MS Word 2003 applications used as external RTF viewer to generated RTF documents. For the future, it is planned to extend this to all possible RTF viewers that support RTF specification 1.8 which is documented by Microsoft and can be found here.
Background
A developer may use CRichEditCtrl
, a MFC control, in order to get RTF output from the source code. This is the control upon which WordPad application is built. But, there are many limitations when considering the generated RTF file. Also, an RTF document can be created with any advanced text editor directly. This library, however, provides a low-level interface to RTF syntax which is not so easy to be hand-coded like HTML. It can be extended and adopted to custom needs. Also, a custom high-level interface is a challenge to be built on this low-level interface base.
Using the code
A full description of using the library code is provided in a separate guide (can be found in the download section above). To use the library in a custom project, include the provided header files (rtflib.h, errors.h, globals.h) and add links in project settings to rtflib.lib compiled module, or download library source and compile it and then include headers and add link to the compiled module. The library source is not hard-tested so memory leaks or some other bugs are possible to be found. If this is the case, please report. But, don't consider wrong output on destination RTF viewer as library error. It is stated here that full compatibility is achieved, for this release, only with MS Word 97 to MS Word 2003 applications.
See an example on using the library below:
Points of Interest
I am interested in continuing the work on this library and hope that interested developers will include with their ideas and solutions. A C++ class solution is very simple to be designed on this base. I also plan to write similar PDF generating libraries.
History
rtflib v1.0 features:
- document creating and formatting
- section creating and formatting
- paragraph creating and formatting
- character formatting
- images loading (*.bmp, *.jpg, *.gif)
- table creating and formatting
- tabs
- columns
- bullets and numbering
He has a master degree in Computer Science at Faculty of Electronics in Nis (Serbia), and works as a C++/C# application developer for Windows platforms since 2001. He likes traveling, reading and meeting new people and cultures.