This is a migrated thread and some comments may be shown as answers.

RTF bullet

7 Answers 340 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Fadi
Top achievements
Rank 1
Fadi asked on 31 Mar 2016, 03:22 PM

Dear Sir,

I tried to put a text with bullet in the RadEditor  of a web application and save into database (see attached WebInput.png).

when read the RTF from another windows application and put it into the RichtextBox control of the visual studio i get another character. (see attached WindowsApp.png).

When trying to read the rtf again from the web application i get it with intent negative (see attached Web.png).

Is there any suggestions? Why the RadEditor is not consistent?

 

example: 

RTF= {\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Times New Roman;}{\f1 Verdana;}{\f2 Symbol;}}{\colortbl\red0\green0\blue0 ;\red255\green0\blue0 ;}{\*\defchp\ltrch\fs22\i0\b0\strike0\ulnone}{\*\defpap\sl240\slmult1}{\stylesheet{\s0\sqformat\spriority0\ltrch\fs24\i0\b0\strike0\ulnone\sl240\slmult1 Normal;}{\*\ts1\tsrowd\spriority59\tscbandsh0\tscbandsv0\trgaph0\trpaddfl3\trpaddl108\trpaddfr3\trpaddr108\trpaddft3\trpaddt0\trpaddfb3\trpaddb0\tsvertalt\clpadft3\clpadt115\clpadfr3\clpadr115\clpadfl3\clpadl0\clpadfb3\clpadb0\ltrch\fs22\i0\b0\strike0\ulnone\sl240\slmult1 Table Normal;}{\s2\sbasedon0\spriority99\ltrch\fs24\i0\b0\strike0\ulnone\sl240\slmult1\sb100\sbauto1\sa100\saauto1 Normal (Web);}}{\*\listtable{\list\listtemplateid-1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0{\leveltext\'01\u-3913?;}{\levelnumbers;}\ltrch\f2\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li720\lin720}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'01.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li1080\lin1080}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'02.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li1440\lin1440}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'03.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li1800\lin1800}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'04.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li2160\lin2160}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'05.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li2520\lin2520}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'06.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li2880\lin2880}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'07.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li3240\lin3240}{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0{\leveltext\'02\'08.;}{\levelnumbers\'01;}\ltrch\fs24\i0\b0\strike0\ulnone\levelfollow0\levelstartat1\sl240\slmult1\fi-360\li3600\lin3600}{\listname ;}\listid0}}{\*\listoverridetable{\listoverride\listid0\listoverridecount0\ls0}}\nouicompat\viewkind1\deftab720\sectd\pgwsxn12240\pghsxn15840\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\vertalt\headery720\footery720\pard\ltrpar\sl240\slmult1{\ltrch\fs24\i0\b0\strike0\cf1\ulnone This document was generated by a trial version of Telerik RadWordsProcessing.}{\ltrch\f1\fs20\i0\b0\strike0\ulnone\par}\pard\s2\ltrpar\ls0\ilvl0{\listtext \u-3913?}\fi-360\li720\lin720\sl240\slmult1\sb100\sbauto1\sa100\saauto1\ilvl0{\ltrch\fs24\i0\b0\strike0\ulnone Hello Telerik}{\ltrch\f1\fs20\i0\b0\strike0\ulnone\par}}

7 Answers, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 05 Apr 2016, 08:06 AM
Hello Fadi,

I've managed to reproduce the described behavior. The problem is that words processing is setting the indentation from the list as local properties to the paragraph when importing from RTF format. This results in additional indentation when exporting to HTML. This issue has been logged as bug report item in our feedback portal. Here is a link if you would like to subscribe to the item for status updates: List indentation is imported as local paragraph properties from RTF format provider.

There is one possible workaround, to set the indentation to the default value when importing from RTF. Here is code example of how this could be done:
RtfFormatProvider provider = new RtfFormatProvider();
RadFlowDocument document = provider.Import(stream);
 
foreach (Paragraph paragraph in document.EnumerateChildrenOfType<Paragraph>())
{
    List list = this.document.Lists.GetList(paragraph.ListId);
    if (paragraph.Indentation.HangingIndent == list.Levels[0].ParagraphProperties.HangingIndent.LocalValue)
    {
        paragraph.Indentation.HangingIndent = Paragraph.HangingIndentPropertyDefinition.DefaultValue.Value;
    }
 
    if (paragraph.Indentation.FirstLineIndent == list.Levels[0].ParagraphProperties.FirstLineIndent.LocalValue)
    {
        paragraph.Indentation.FirstLineIndent = Paragraph.FirstLineIndentPropertyDefinition.DefaultValue.Value;
    }
}

I hope this information is helpful for you.

Regards,
Mihail
Telerik
0
Fadi
Top achievements
Rank 1
answered on 09 Apr 2016, 04:13 PM

The issue is that the same text is not displayed correctly. See the following scenario:

if you put RTF text of visual studio RichTextBox in the Telerik RadEditor or RadRichtextBoxEditor, you will not get the same result.

 

  • RTF of the RichTextBox:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}} \viewkind4\uc1\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\lang1024\f0\fs24 Bullet1\par {\pntext\f1\'B7\tab}Bullet2\par } 

 

  • RTF of the Telerik RadEditor or RadRichTextBoxEditor:

{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Times New Roman;}}{\colortbl\red0\green0\blue0 ;}{\*\defchp\ltrch\f0\fs24\i0\b0\strike0\cf0\ulc0\ulnone}{\*\defpap\sl276\slmult1\sa180}{\stylesheet{\s0\sqformat\spriority0\ltrch\f0\fs24\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1 Normal;}{\*\ts2\tsrowd\spriority59\trbrdrt\brdrnone\trbrdrb\brdrnone\trbrdrl\brdrnone\trbrdrr\brdrnone\trbrdrh\brdrnone\trbrdrv\brdrnone\trgaph0\clpadft3\clpadt0\clpadfr3\clpadr0\clpadfl3\clpadl0\clpadfb3\clpadb0\tsvertalt\ltrch\f0\fs24\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1 Table Normal;}}\nouicompat\viewkind4\paperw12240\paperh15840\margl1425\margr1425\margt1425\margb1425\deftab720\sectd\pgwsxn12240\pghsxn15840\marglsxn1425\margrsxn1425\margtsxn1425\margbsxn1425\headery720\footery720\pard\s0\ltrpar\sl240\slmult1{\ltrch\f0\fs24\i0\b0\strike0\cf0\ulc0\ulnone  }{\ltrch\f1\fs24\i0\b0\strike0\cf0\ulc0\ulnone Bullet1}{\ltrch\f1\fs24\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\s0\ltrpar\sl240\slmult1{\ltrch\f1\fs24\i0\b0\strike0\cf0\ulc0\ulnone Bullet2}{\ltrch\f1\fs24\i0\b0\strike0\cf0\ulc0\ulnone\par}}

 

Code:

  Dim rtf As String = RichTextBox1.rtf
  RadRichTextEditor1.Document = getDocument(rtf)

-------------------------------

 

  Function getDocument(rtf As String) As RadDocument
        Dim document As RadDocument = Nothing
        Dim provider As IDocumentFormatProvider = New RtfFormatProvider()

        Dim strAsBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(rtf)
        Using ms As New System.IO.MemoryStream(strAsBytes)
            ms.Position = 0

            document = provider.Import(ms)

        End Using
        Return document

    End Function

 

 

  • Please what is the RTF-HTML and HTML-RTF converter that TELERIK used?
0
Todor
Telerik team
answered on 13 Apr 2016, 09:30 AM
Hi Fadi,

The first Rtf string, you've shown has the '\pntext' tag as marker for an bullet item and '\pnlvlblt' control word which exists for backward compatibility with older versions of RTF (1.3, 1.4) in order the lists to be represented. These markers are not supported by the RtfFormatProvider. Thus, the text after the paragraph numbering text control word (the '\pntext' tag) is imported as a plain text. Currently, we don't plan to improve the format provider in this direction, as this standard is rather old - circa 1995.

About conversion of the HTML to RTF format and vice versa, the corresponding format providers are used.

If you have further questions or any feedback, please get back to us again.

Regards,
Todor
Telerik
0
Fadi
Top achievements
Rank 1
answered on 13 Apr 2016, 06:52 PM

The following RTF is the one that we get from Richtextbox of visual studio, i think it is RTF 1.6:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}} \viewkind4\uc1\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\lang1024\f0\fs24 Bullet1\par {\pntext\f1\'B7\tab}Bullet2\par } 

If we are planning to use the Telerik RadEditor for our web page with the RadRichTextbox for our windows applications, what do you suggest to migrate our old RTF data to the new RTF format? 

0
Todor
Telerik team
answered on 14 Apr 2016, 09:39 AM
Hi Fadi,

The RadWordsProcessing and RadRichTextBox Rtf format providers are implemented against the latest Rtf specification - version 1.9.1. Since the RadEditor control uses the RadWordsProcessing internally, the Rtf documents are processed against that version. This means that if your documents have obsoleted and not supported Rtf tags, the result might be different of what you are expecting.

I'll be glad to assist you if you have further questions.

Regards,
Todor
Telerik
0
Fadi
Top achievements
Rank 1
answered on 14 Apr 2016, 10:45 AM

Currently if you save the following RTF into rtf document and you open it into word, it will display correctly:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}} \viewkind4\uc1\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\lang1024\f0\fs24 Bullet1\par {\pntext\f1\'B7\tab}Bullet2\par } 

Why Telerik don't have a backward compatibility with old RTF version?

Do you mean that we cannot use the telerik components in our future products if we need to migrate the old data?

0
Petya
Telerik team
answered on 18 Apr 2016, 02:48 PM
Hello Fadi,

The 1.9 version of the Rich Text Format specification was published in 2007 and the most commonly used 
software that is capable of producing such documents uses it. For example, while MS Word has compatibility for older versions, the document it creates ever since MS Word 2007 comply with this specification.

I understand your point but we have not received other requests for such compatibility and we're trying to implement our components so they fulfill the needs of the majority of our customers. That said, implementing compatibility for RTF versions older than 1.9 is not something we're planning right now.

As to your question - if you use the Telerik controls in your application with those documents, there might be some undesired formatting changes. The only thing I can think of is to make a one-time migration of your database to the latest version of RTF documents, but I cannot point you to a Telerik tool that is capable of doing this and I didn't find any third-party tools designed for the scenario. What comes to mind is that you could try using the Microsoft COM Interop automation for such migration.

I hope this provides more context to the faced issue. I'm sorry I couldn't be of more help.

Regards,
Petya
Telerik
Tags
WordsProcessing
Asked by
Fadi
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Fadi
Top achievements
Rank 1
Todor
Telerik team
Petya
Telerik team
Share this question
or