Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RichEdit contents to RTF file...

Status
Not open for further replies.

ukusa

Programmer
Oct 8, 2001
49
AU
Hiya all,

I'm trying to get the contents of a TRichEdit into a RTF file. At the moment I have it going to a text file but like to keep the formatting (bold, Italic etc). I've looked in the Demo that Borland provide but can't work out how they save any typed data to a working RTF document.

Do I have to use a third party product to achieve this?

Thanks!
Allen
 
I do this in many of my programs so that all formatting changes are saved. You can simply do it like this

Form6.RichEdit1.Lines.SaveToFile(Path + '\' + Edit1.Text + '.RTF');

where Edit1.Text is the user entered filename and path is just a string containg the specific directory I would like to save to. Arte Et Labore
 
If you want to save the formatting information you must ensure that the PlainText property is set to False in your TRichEdit component otherwise the formatting information will not be saved.
 
Thanks for those! I have already set the plaintext to false, and am using a saveDialog box as RTF being the filter. No matter how I code it, it just doesn't keep the formatting and just has plain text in the RTF file. What happens is that I let a user edit a DBRichedit field, it maintains the font changes and so on, but the formatting won't transfer to file. As a test I did put in a general RichEdit field in the same form and that worked well. So is there a problem saving the DBRichEdit's text into a file? The data is saved in a formatted memo (Paradox table). Thanks

Allen
 
Another thing that is strange is... when I do a copy of the DBRichEdit text and paste it into Word, it keeps the formatting but if I paste it but if I do a RichEdit.text:=DBRichEdit.text it doesn't keep the formatting and shows plaintext and that is with both plaintext:=false!

Thanks
Allen
 
If you want to be serious about RTF check out wptools.com. Third party rtf component that provides a fully featured word processor with full programmer control. I had good result for several years.

Have fun

 
The only problem with WPTools is that it adds over half a meg to the size of your executable. Ukusa, why do you need to use a DBRichEdit if you are trying to save your files as RTF format? Arte Et Labore
 
Might it be that a RTF memo can only be stored in a Blob-field inside a Paradox table?
 
Ah Ok, To explain. My system is a Psychosocial Assessment tool, fifth gen but this time in Delphi. Numbers are recorded but at reporting time, an English formatted report sensing gender (himself, herself)is generated and knows where to put a full stop if no more data in one section and so on - all one has to do is to sign it for court. At a click of a button this report is generated and saved as part of the clients data which gives archival ability of all generated reports. The REPORT table holds this in a Formatted memo field. On the form I use a DBRichEdit to bring up a report where they can edit and bold this and that, change fonts and eventually save the updated look back into the reports table.

There is something strange going on with the Paradox blob. Prolly Paradox blob interprets it differently to real RichEdit but if I do a copy and paste into a Word document, it works fine. Paste it to a general RichEdit etc just gives me plain text even though all is correctly set...

Strange!! Ye, I don't want to inflate my program that much more as this is one intensive product with Export / Statisitical functions etc and the report takes about a 1000 lines to correctly give what we need!

Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top