Converting RTF with Superscript Two Character Adds Junk Character to PDF


#1

I have an RTF file that looks like this (simplified from the original):

{\rtf1\ansi\ansicpg1252 1234567890²}

Just in case the forum messes up the characters, the last character before the closing curly brace is the “Superscript Two” characters, U+00B2 in Unicode. It’s the literal superscript two character, not a regular two formatted as superscript.

I use Aspose.Words to convert the RTF to PDF. It gives me a PDF that looks like this:

1234567890²

Note character in between the zero and the superscript two. It’s U+00C2, Latin Capital Letter A With Circumflex.

Here is the C# code I use:

string rtf = “{\rtf1\ansi\ansicpg1252 1234567890²}”;

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

using(var inStream = new MemoryStream(rtfBytes))
{
var loadOptions = new Aspose.Words.LoadOptions();

loadOptions.LoadFormat = LoadFormat.Rtf;

var document = new Aspose.Words.Document(inStream, loadOptions);

var saveOptions = (Aspose.Words.Saving.PdfSaveOptions)Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Pdf);

using(var outStream = new MemoryStream())
{
document.Save(outStream, saveOptions);

byte[] result = outStream.ToArray();

return result;
}
}


#2

Hi Tom,

Thanks for your inquiry. Unfortunately, I am unable to download your RTF file. Could you please reattach your Sample.rtf here for our reference?

I have tested the scenario using the shared code and have managed
to reproduce the same issue at my side. For the sake of correction, I
have logged this problem in our issue tracking system as WORDSNET-10855.
I have linked this forum thread to the same issue and you will be
notified via this forum thread once this issue is resolved. We apologize
for your inconvenience.


#3

Thanks for replying!

The RTF attachment was the same was what I posted in the text: {\rtf1\ansi\ansicpg1252 1234567890²}. I cannot attached the original RTF having the problem since it has patient sensitive information in it. I’ve attached the sample again in a ZIP file.

Thanks for creating the support issue!

-Tom


#4

Hi Tom,

Thanks for sharing the detail. I have logged this information in our issue tracking system. Our development team will check this issue and we will update you via this forum thread once this issue is resolved.

Please let us know if you have any more queries.


#5

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.