Free Support Forum - aspose.com

Loading and saving simple Bidi RTF changes font sizes and more!

When loading RTF into Aspose.Words.Document and then saving it (for the sake of example),
if the RTF does not contain ‘\afs’ attribute and only ‘\fs’ attribute, the resulting RTF font size is wrong.

Take a look at this sample code:

string resultRtf;
string rtfToLoad =
    @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}" +
    @"{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red34\green54\blue107;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf2 \cf2\ql\sl15\slmult0" +
    @"{\f2 \rtlpar{\lang1037\b\rtlch \u1488?}{\lang1037\fs16\rtlch \u1489?}\li0\ri0\sa0\sb0\fi0\qr\sl15\slmult0\par}}}";
 
Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions { LoadFormat = Aspose.Words.LoadFormat.Rtf };
Aspose.Words.Document doc = new Aspose.Words.Document(new MemoryStream(System.Text.Encoding.ASCII.GetBytes(rtfToLoad)),loadOptions);
using (MemoryStream rtfOutput = new MemoryStream())
{
    doc.Save(rtfOutput, Aspose.Words.SaveFormat.Rtf);
    rtfOutput.Flush();
    rtfOutput.Position = 0;
 
    using (StreamReader reader = new StreamReader(rtfOutput)) resultRtf = reader.ReadToEnd();
}

The result RTF code contains many more attributes (which is OK) but when displaying the result RTF the font size is incorrect.

@nir-1

We have logged this problem in our issue tracking system as WORDSNET-21240. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.