RTF Code Optimization

General TRichView support forum. Please post your questions here
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

RTF Code Optimization

Post by Aida »

Hi,

How can I optimize the RTF code as possible, I found the size of the generated code is huge.


Note :
I do not want more than
Pictures.
Text Formating 'color B,I,U Alignments Bullets FontFace FontSize indents'
undo,redo

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you mean application exe file size, or size of saved RTF file?
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

Sorry For being late,

In Fact, I mean the resultant RTF Code,which is so huge.

Would you please tell me Also if there is away foe the EXE Size optimization.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Make sure that the following options are excluded from RTFOptions property: [rvrtfSaveStyleSheet, rvrtfDuplicateUnicode], and the following option is included: [rvrtfSaveJpegAsJpeg].

Two possible reasons for huge RTF files:
1) Pictures, especially bitmaps. Pictures in RTF have double size (comparing with saving them in files). Bitmaps may be huge.
To solve this problem, convert all images to PNG and call RV_RegisterPngGraphic (see http://www.trichview.com/forums/viewtopic.php?t=89)

2) Large number of unnecessary styles. Make sure that you call DeleteUnusedStyles.

As for exe file size, see comments in RV_Defs.inc
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

Thanks alot Sergey for your answer. :oops: :wink:

But when using "DeleteUnusedStyles",I get an error msg which is "can not modify empty undo list" :shock:

Do you have any idea why this happens? :roll:
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Probably you call it in improper place. May be you have mismatched calls of SetUndoGroupMode.

The best way to call DeleteUnusedStyles is just before loading, or when creating a new document (in both cases - just after calling Clear).
You can also call it before saving, but it clears all undo and redo history.
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

When I used this method it minimized the code,but it is not the optimal.
Check this please:
if I wrote:
try this one.
Aida.

then the code generated through richviewedit is:
{\rtf1\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0{\fonttbl{\f0\fnil\fcharset1 Arial Narrow;}{\f1\fnil\fcharset1 Arial;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\*\listtable{\list\listtemplateid1849087502\listsimple1
{\listlevel\levelnfc23\leveljc1\li0\fi0\jclisttab\tx150{\leveltext\'01\'b7;}{\levelnumbers;}\f1\fs16}
\listid435039309}
{\list\listtemplateid586093958\listsimple1
{\listlevel\levelnfc0\leveljc0\li300\fi0\jclisttab\tx600\levelstartat1{\leveltext\'04\'00. ;}{\levelnumbers\'01;}\f1\fs24}
\listid1442366880}
}
{\*\listoverridetable
{\listoverride\listid435039309\listoverridecount0\ls1}
{\listoverride\listid1442366880\listoverridecount0\ls2}
}

\uc0
\pard\li300\fi0\jclisttab\tx600\qc\ri0\sb0\sa0\itap0 {\listtext\pard\plain\f1\fs24 1. \tab}\ls2\ilvl0 \plain \f0\b\fs44\cf2 Test This}



Another important problem :

there is a missed \par at the end of the code, are there any property can put it, I mean when using any other rtf editor I find it, while when using RichViewEdit I do not '.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The only thing that can be optimized in this code is reducing color table ({\colortbl ... }) Like MS Word, TRichView always adds standard VGA colors to the beginning of this table.
I do not plan to change it. If you want you can change CRVData.pas, from

Code: Select all

const ArrDefColorTable: array [0..16] of TColor =
         (
         clWindowText, clBlack, clBlue, clAqua,
         clLime, clFuchsia, clRed, clYellow,
         clWhite, clNavy, clTeal, clGreen,
         clPurple, clMaroon, clOlive,
         clGray, clSilver
         );
to

Code: Select all

const ArrDefColorTable: array [0..0] of TColor =
         (
         clWindowText
         );
Lists (bullets&numbering) cannot be optimized. Standard RichEdit saves simplified version of lists, but it is obsolete.

As for \par, it will be fixed.
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

If I changed this, does it optimize the code without any other bad effects.

for \par : Must I Reinstall RichView Package in order to see a good result, if yes where is the new packge.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1. Not tested, but I think there must be no bad effects, because after adding default colors, TRichView adds colors that are necessary for the given document (if they are not included in previously added colors).
The main reason why default color table is added - some editors use the first colors of this table for text highlighting.

2. The ending \par problem is not fixed yet. I'll provide fix later this week.
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

hi

I want to know if my problem is solved in v1.9.24(missing \par from the end of the RTF Code)....

if yes, I tested this package;
'compiled an old project which used old RichViewEdit after installing the new pachage but the problem appered again it is not solved'..

Would you please solve it for me as soon as you can or tell me what I have to do to solve it now.

What is the best version I can use which does not have this problem...
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, '\par' is fixed only in v1.9.27.2 (this is alpha version available for registered users).
By the way, why this ending \par is so important? The most if RTF readers do not require it.
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

We want to buy this package if all of our problems are fixed .

How can I get sure that this work before buying the component?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Did you mention other problems, except for the ending \par?
Aida
Posts: 16
Joined: Mon Sep 04, 2006 6:52 am

Post by Aida »

Not till now, this is the main problem we have at the present time .

Thanks.
Post Reply