Converting to own format

General TRichView support forum. Please post your questions here
Post Reply
hodgsoni
Posts: 1
Joined: Sun Sep 05, 2010 11:35 am

Converting to own format

Post by hodgsoni »

Hi,

I have an application that uses a TRichEdit to load an rtf (or paste text from Word etc) and convert this to a format another of our applications uses to set letter texts.

The program basically scans each character of the rtf and needs to know for each character what the character is, the font name, size and style, the indentation of the paragraph, and whether there is a bullet style and that's about it.

The problem I have is that a lot of the time the RichEdit component is not displaying the rtf as Word would and therefore my application cannot re-create the document correctly in the other application's format.

I have downloaded the trial version of TRichView and this can display the rtf correctly so providing I can work out how to do the parsing I have authorisation to purchase the product.

For future versions it would be nice if I could handle Unicode and tables but at the moment I am just dealing with fairly straightforward letter texts with multiple fonts, bullets and indentations.
My question therefore is how would I acheive this with TRichView please.

Thanks

Ian
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The only application that can display RTF like MS Word is MS Word.
TRichView supports a subset (quite large subset, but not the full set) of RTF features.
However, as I understand, you do not need too advanced features, so you can try using our components.

There are two ways for converting RTF to another format.

1) Load RTF in TRichView. Create a procedure for saving TRichView to another format. All TRichView contents can be accessed using methods a properties, and it is completely documented.
2) You can try using TRichView RTF parser, see http://www.trichview.com/forums/viewtopic.php?t=2702. While reading RTF, the parser generates events like OnNewText. The read text is in parameters, its attributes is in the parser properties.
For example:
- font size is in parser.RTFState.CharProps.FontSize,
- font style (bold, italic, etc.) is in parser.RTFState.CharProps.Style,
- font name is in parser.FontTable[parser.RTFState.CharProps.FontIndex].Name;
- paragraph alignment is in parser.RTFState.ParaProps.Alignment.
Unfortunately, RTF parser is mostly used internally, and it is undocumented.
Post Reply