Page 1 of 2
RTF Code Optimization
Posted: Thu Sep 28, 2006 12:50 pm
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.
Posted: Thu Sep 28, 2006 1:02 pm
by Sergey Tkachenko
Do you mean application exe file size, or size of saved RTF file?
Posted: Sun Oct 01, 2006 8:02 am
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.
Posted: Tue Oct 03, 2006 10:53 am
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
Posted: Sat Oct 07, 2006 10:01 am
by Aida
Thanks alot Sergey for your answer.
But when using "DeleteUnusedStyles",I get an error msg which is "can not modify empty undo list"
Do you have any idea why this happens?
Posted: Tue Oct 10, 2006 9:54 pm
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.
Posted: Tue Oct 31, 2006 2:15 pm
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 '.
Posted: Tue Oct 31, 2006 8:40 pm
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.
Posted: Tue Oct 31, 2006 10:44 pm
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.
Posted: Wed Nov 01, 2006 7:10 am
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.
Posted: Wed Nov 08, 2006 3:13 pm
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...
Posted: Thu Nov 09, 2006 12:48 pm
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.
Posted: Thu Nov 09, 2006 9:05 pm
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?
Posted: Fri Nov 10, 2006 10:37 pm
by Sergey Tkachenko
Did you mention other problems, except for the ending \par?
Posted: Sat Nov 11, 2006 9:10 am
by Aida
Not till now, this is the main problem we have at the present time .
Thanks.