Rathinagiri wrote:I wanted to create rtf files from inside the program. Is it possible? If it is, we can create report files in rtf.
Especially we have to create tables.
WordScribe and WordWriter are word processors and can write to RTF files as well as several formats of TXT files. They do this through the EX...SAVEFILE method of a rich edit control, which sends a Windows message to write the rich edit control to the file. This message can only be used on rich edit controls.
If you had a text buffer and wanted to write it to RTF, you could define an invisible rich edit box, write the buffer to a temporary text file, use the EX...LOADFILE method to read the temp file, then use EX...SAVEFILE to write it to an RTF file. But you would not have any formatting other than tabs and line breaks, so I don't see what the advantage of this would be. Tabs would be the only way to format table data, since rich edit controls cannot create tabs but not tables. Tabs are not a very good way to format table data.
An RTF file is just a series of text based commands, however, so it is not very hard for you to write functions that output RTF commands into an RTF file. I did this once to generate an RTF table in one of my applications, Akshara Bridge (http://kevincarmody.com/software/aksharabridge.html
). This program transliterates between various Indian scripts, and when it encounters errors in the input, it can generate an error file. If you select an error file name ending in .rtf, it generates an RTF table for each error. You can download the source and look at ErrorChar() in AksharaBridgeBack.prg. I've attached a zip file containing a sample RTF file generated by this function.
Hope this helps.