Page 1 of 1

Superfluous \par directives in RTF ????

Posted: Wed Sep 05, 2012 10:11 pm
by jfleming
Using TRichView V13.5 with Delphi XE2, all service packs.

My program has the TRichView editor from one of your demo programs integrated and called by double-clicking on the field of a grid.

When, in the editor, I type a single line of text: "just a test", and save it, the generated RTF code is as follows:

{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl{\f0\fnil\fcharset0 tahoma;}{\f1\fnil\fcharset0 Tahoma;}}
\viewkind4\uc1\pard\lang0\f0\fs16 Just a test\par
\pard\lang3082\f1\par
}

This would appear to have some extra superfluous \par or \pard directives, if I am not mistaken ???

The problem becomes visible if you try to print this RTF using FastReport V4.11.17. The single-line band on the report, which is tall enough to show the text with no problems, actually stretches the band, adding white space below the text, because of the extra \par or \pard directive(s).

Is there a way to solve this problem ?

With a multi-line text: Line A
Line B
Line C
the generated RTF text is:

{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl{\f0\fnil\fcharset0 tahoma;}{\f1\fnil\fcharset0 Tahoma;}}
\viewkind4\uc1\pard\lang0\f0\fs16 Line A\par
Line B\par
Line C\par
\pard\lang3082\f1\par
}

All suggestions welcome.

Thanks

Jim Fleming

Posted: Thu Sep 06, 2012 6:54 am
by Sergey Tkachenko
\pard simple resets paragraph attributes to defaults, it does not affect page breaks.
\par is a paragraph break. If the ending \par is not included, MS Word ignores attributes of the last paragraph

Posted: Thu Sep 06, 2012 8:36 am
by jfleming
Thanks, Sergey.

> If the ending \par is not included, MS Word ignores attributes of the last paragraph

So, if I could strip away the \par just before that last \pard all should work OK ??

The RichText is coming from a database field and so cannot be accessed by Word. The only external representation will ever be a pdf file of the report produced by FastReport, never the RTF code itself directly.

JF

Posted: Thu Sep 06, 2012 11:38 am
by Sergey Tkachenko
Probably not only Word, but any editor (including RichEdit) that uses end-of-paragraph marks.
As for TRichView, this par is not necessary for it.