We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Control words not recognised when inserting RTF

I have been running some tests to check the insertion of RTF in an Aspose.Words document and have discovered that it does not seem to recognise the following RTF control words:

  1. double strikethrough: \striked1
  2. underline color: \ul\ulc1 with a suitable color table set up
  3. scaling: \charscalex200
  4. font border settings eg. \chbrdr\brdrs\brdrw40\brdrcf1\brsp0
  5. font shading settings eg. \chshdng2000\chcbpat1\chcfpat2

The test RTF code I am inserting is:
{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica; \f1\froman Tms Rmn; }{\colortbl;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;}\f0\pard
012345{[***CODE***] 67}89\par
}
where [***CODE***] is replaced with one of the elements listed above.

With the exception of the underline color test, I get a single run inserted instead of the expected three separate runs with different settings.
In the case of the underline color test, I do get three runs, with the middle one underlined, but the underline color is not set up correctly.

I have checked that the RTF is valid by saving it to file and opening it in Word/WordPad.

Hi

Thanks for your request. But unfortunately, I cannot reproduce the problems with these tags. Here is code I used for testing:

string testRtf = @"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica; \f1\froman Tms Rmn; }{\colortbl;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;}\f0\pard 012345{[***CODE***] 67}89\par}";

string[] tags = { @"\striked1", @"\ul\ulc1", @"\charscalex200", @"\chbrdr\brdrs\brdrw40\brdrcf1\brsp0", @"\chshdng2000\chcbpat1\chcfpat2" };

for (int tagIndex = 0; tagIndex < tags.Length; tagIndex++)

{

// Replace the placeholder with the appropriate tag from the collection.

string rtfString = testRtf.Replace("[***CODE***]", tags[tagIndex]);

// Save the rtf string to file (for testing).

using (FileStream rtfFile = File.Create(string.Format(@"Test001\test_{0}.rtf", tagIndex)))

{

using (StreamWriter rtfWriter = new StreamWriter(rtfFile))

{

rtfWriter.Write(rtfString);

}

}

// Now load the RTF string into Aspose.Words.Document object and save the document as DOC.

byte[] rtfBytes = Encoding.UTF8.GetBytes(rtfString);

using (MemoryStream rtfStream = new MemoryStream(rtfBytes))

{

Document doc = new Document(rtfStream);

doc.Save(string.Format(@"Test001\test_{0}.doc", tagIndex));

}

}

As you can see RTF documents and DOC documents generated by Aspose.Words from RTF strings are identical.

Best regards,