Superfluous \par directives in RTF ????

General TRichView support forum. Please post your questions here
Post Reply
jfleming
Posts: 19
Joined: Tue May 25, 2010 4:58 pm

Superfluous \par directives in RTF ????

Post 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
Sergey Tkachenko
Site Admin
Posts: 17291
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
jfleming
Posts: 19
Joined: Tue May 25, 2010 4:58 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17291
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply