Free Support Forum - aspose.com

Extra Margins added while Converting RTF to HTML


#1

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

Each time RTF to HTML function is called, it is adding extra margins to HTML, thereby In UI, it is rendering extra space.
Example: First-time Margin would be 3.6 pt, next time it would be changed to 7.2 pt and so on.

Please refer attached zip for details.

Below code is used to Convert RTF to HTML

public static string RtfToHtml(string rtf)
{Query to Aspose_.zip (383.9 KB)

        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.Encoding = Encoding.Unicode;
        saveOptions.ExportImagesAsBase64 = true;
        saveOptions.ExportHeadersFootersMode = Aspose.Words.Saving.ExportHeadersFootersMode.None;
        // 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;

        }
    }

#2

@surajsirvarkar

Thanks for your inquiry. Please ZIP and attach your input HTML and problematic output documents here for testing. We will investigate the issue on our side and provide you more information.