Page 1 of 1

RTF Formatting question

Posted: Mon Jan 07, 2008 9:40 pm
by toolwiz
I'm looking at the PDF demo, and I notice this in the block to read an RTF file:

Code: Select all

             srve.RichViewEdit.Clear;
             srve.RichViewEdit.DeleteUnusedStyles(True, True, True);
             srve.RichViewEdit.LeftMargin := 132;
             srve.RichViewEdit.RightMargin := 57;
             srve.RichViewEdit.TopMargin := 94;
             srve.RichViewEdit.BottomMargin := 94;
             srve.RichViewEdit.LoadRTF(OpenDialog1.FileName);
             srve.RichViewEdit.Format;
The latest version of RV/RVE has DocParameters to get the margins and such from the RTF file. So my question is, are these now loaded automatically? Or can they be set after the call to LoadRTF? Specifically, which of these is most appropriate:

Code: Select all

             srve.RichViewEdit.Clear;
             srve.RichViewEdit.DeleteUnusedStyles(True, True, True);
             srve.RichViewEdit.LoadRTF(OpenDialog1.FileName);
             srve.RichViewEdit.Format;
or

Code: Select all

             srve.RichViewEdit.Clear;
             srve.RichViewEdit.DeleteUnusedStyles(True, True, True);
             srve.RichViewEdit.LoadRTF(OpenDialog1.FileName);
             srve.RichViewEdit.LeftMargin := Floor(srve.RichViewEdit.DocParameters.LeftMargin);
             srve.RichViewEdit.RightMargin := Floor(srve.RichViewEdit.DocParameters.RightMargin);
             srve.RichViewEdit.TopMargin := Floor(srve.RichViewEdit.DocParameters.TopMargin);
             srve.RichViewEdit.BottomMargin := Floor(srve.RichViewEdit.DocParameters.BottomMargin);
             srve.RichViewEdit.Format;
Thanks
-David

Posted: Mon Jan 07, 2008 10:36 pm
by toolwiz
I tried this both ways, and they seem to be equivalent, leading me to believe the library already accounts for DocParameters.

(The code I gave needs to have the numbers converted from the input units to pixels, and I did that.)

I noticed, however, that while the Top, Bottom, and Left margins look ok, the Right margin is not respected.

-David

Posted: Tue Jan 15, 2008 4:06 pm
by Sergey Tkachenko
TRichView itself never reads LeftMargin and other margin properties from RTF. It can read DocParameters property if RTFReadProperties.ReadDocParameters = True.
As for ScaleRichView specifics, I'll ask Ilya.

Posted: Tue Jan 15, 2008 7:40 pm
by proxy3d
Thanks, I have corrected a bug. ScaleRichView incorrectly read out values of Margins and incorrectly save them in DocParameters for RTF files. In the nearest updating it will be fixed.

Posted: Wed Jan 16, 2008 7:02 am
by toolwiz
So what is the recommended approach after the fix is released?

-David

Posted: Wed Jan 16, 2008 7:24 am
by proxy3d
Sorry :( , recommendations are not present. Updating will be this week.