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

Free Support Forum - aspose.com

Aspose RTF to HTML is not Converting all the RTF content to HTML

We have started using Aspose Words to convert RTF stream to HTML.

However, all the contents of RTF are not converted into HTML.
Details are mentioned below. Please let us know what needs to be done?

SAMPLE RTF is given below: ( also I have Attached sample RTF )

{\rtf1\ansi\ansicpg1252\uc0\stshfdbch1\stshfloch1\stshfhich1\stshfbi1\deff1\adeff0{\fonttbl{\f0\fnil\fcharset0 Verdana;}{\f1\fnil\fcharset0 Times New Roman;}}{\colortbl;}{\stylesheet{\s0\snext0\styrsid8412110\sqformat\spriority0\aspalpha\aspnum\adjustright\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\af0\afs18\ltrch\fs18\loch\af0\dbch\af0\hich\f0 Normal;}{\s1\sbasedon0\snext0\styrsid15694742\sqformat\spriority0
\keepn\sb240\sa60\aspalpha\aspnum\adjustright\outlinelevel0\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab\af1\afs48\ltrch\b\i0\fs48\f1\kerning36 heading 1;}{\s2\sbasedon0\snext0\styrsid15694742\sqformat\spriority0\keepn\sb240\sa60
\aspalpha\aspnum\adjustright\outlinelevel1\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab\ai\af1\afs36\ltrch\b\i0\fs36\f1 heading 2;}{\s3\sbasedon0\snext0\styrsid15694742\sqformat\spriority0\keepn\sb240\sa60\aspalpha\aspnum\adjustright\outlinelevel2SampleRTF.zip (1.4 KB)

\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab\af1\afs28\ltrch\b\i0\fs28\f1 heading 3;}{\s4\sbasedon0\snext0\styrsid15694742\sqformat\spriority0\keepn\sb240\sa60\aspalpha\aspnum\adjustright\outlinelevel3\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0
\ql\faauto\rtlch\ab\af1\afs24\ltrch\b\i0\fs24\f1 heading 4;}{\s5\sbasedon0\snext0\styrsid15694742\sqformat\spriority0\sb240\sa60\aspalpha\aspnum\adjustright\outlinelevel4\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab\ai\af1\afs20
\ltrch\b\i0\fs20\f1 heading 5;}{\s6\sbasedon0\snext0\styrsid15694742\sqformat\spriority0\sb240\sa60\aspalpha\aspnum\adjustright\outlinelevel5\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab\af1\afs17\ltrch\b\i0\fs17\f1 heading 6;}{*\cs10
\additive\ssemihidden\spriority0 Default Paragraph Font;}{\s15\sbasedon0\snext15\spriority0\aspalpha\aspnum\adjustright\brdrt\brdrl\brdrb\brdrr\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\af0\afs18\ltrch\fs18\loch\af0\dbch\af0\hich\f0 p;}{*\cs16\additive\sbasedon10\spriority0 span;
}}{*\generator Aspose.Words for .NET 17.12;}{\info\version0\edmins0\nofpages0\nofwords0\nofchars0\nofcharsws0}{\mmathPr\mbrkBin0\mbrkBinSub0\mdefJc1\mdispDef1\minterSp0\mintLim0\mintraSp0\mlMargin0\mmathFont0\mnaryLim1\mpostSp0\mpreSp0\mrMargin0\msmallFrac0\mwrapIndent1440\mwrapRight0}
\deflang1033\deflangfe2052\adeflang1025\jexpand\showxmlerrors1\validatexml1\viewscale100\fet0\widowctrl\nocxsptable\nospaceforul\nolnhtadjtbl\alntblind\lyttblrtgr\nogrowautofit\dntblnsbdb\noxlattoyen\wrppunct\nobrkwrptbl\expshrtn\snaptogridincell\asianbrkrule
\htmautsp\noultrlspc\useltbaln\splytwnine\ftnlytwnine\lytcalctblwd\allowfieldendsel\newtblstyruls\lnbrkrule\nouicompat\nofeaturethrottle1\spltpgpar\krnprsnet\noindnmbrts\formshade\nojkernpunct\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1
\dgmargin\pgbrdrhead\pgbrdrfoot\rsidroot0\sectd\ltrsect\pard\plain\itap0\s0\sb0\aspalpha\aspnum\adjustright\brdrt\brdrl\brdrb\brdrr\ltrpar\li72\lin72\ri72\rin72\ql\faauto\rtlch\af0\afs18\ltrch\fs18\loch\af0\dbch\af0\hich\f0{\rtlch\af0\alang1024\afs18\ltrch\fs18\lang1024\langnp1024\langfe1024\langfenp1024
\loch\af0\dbch\af0\hich\f0 \u-257 }{\rtlch\af0\afs18\ltrch\fs18\loch\af0\dbch\af0\hich\f0\cs10\par}\pard\plain\itap0\s15\sb0\sa0\aspalpha\aspnum\adjustright\brdrt\brdrl\brdrb\brdrr\nowidctlpar\ltrpar\li144\lin144\ri144\rin144\ql\faauto\rtlch\af0\afs18\ltrch\fs18
\loch\af0\dbch\af0\hich\f0{\rtlch\ab\af0\alang1024\afs18\ltrch\b\fs18\lang1024\langnp1024\langfe1024\langfenp1024\loch\af0\dbch\af0\hich\f0\cs16 \u-257 RTF TEXT ADDED}{\rtlch\af0\alang1024\afs18\ltrch\fs18\lang1024\langnp1024\langfe1024\langfenp1024\loch\af0
\dbch\af0\hich\f0\cs10\par}{*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef1\lsdunhideuseddef1\lsdqformatdef0\lsdprioritydef99{\pard\plain\f0\fs20\cf0\par Electronically signed by:Provider Allscripts M.D. May 2 2018 6:04AM EST Acknowledgement \par }}}

Output HTML:

**RTF TEXT ADDED**

Actual result - Observe signature part ( Electronically signed by:Provider Allscripts M.D. May 2 2018 6:04AM EST Acknowledgement) present in above RTF is not showing in the Output HTML . Only “RTF TEXT ADDED” is converted.

Expected Result - Along with text “RTF TEXT ADDED” even the Signature part needs to be converted and displayed in HTML

Code used to Convert RTF to HTML

public static string RtfToHtml(string rtf)
{
Aspose.Words.Document doc;

        using (Stream s = GenerateStreamFromString(rtf))
        {
            doc = new Aspose.Words.Document(s);
        }
        
        Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
        saveOptions.SaveFormat = Aspose.Words.SaveFormat.Html;
        saveOptions.Encoding = Encoding.UTF8;
        saveOptions.ExportImagesAsBase64 = true;

        // Save the document to stream in HTML format.
        using (MemoryStream htmlStream = new MemoryStream())
        {
            doc.Save(htmlStream, saveOptions);

            // Read the HTML from the stream as plain text.
            String myHtml = Encoding.UTF8.GetString(htmlStream.ToArray());
            
            return myHtml;

        }
    }

@surajsirvarkar,

Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem as in our issue tracking system as WORDSNET-16803. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Thank you for quick response.

Can you please let us know, When can we expect the fix for this OR
in Meantime, is it possible to give us quick fix for this , as our functionality is dependent on this.

@surajsirvarkar,

This issue is currently pending for analysis and is in the queue. Once the analysis of this issue is completed, we may then be able to share estimates or workaround. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.

The issues you have found earlier (filed as WORDSNET-16803) have been fixed in this Aspose.Words for .NET 18.6 update and this Aspose.Words for Java 18.6 update.