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

Free Support Forum - aspose.com

Aspose.Word displays the image which encoded into base64 string within the full RTF content as "Text" instead of an "Image" in HTML output

Image_EncodedInBase64_Within_RTFContent_Notworking.zip (247.8 KB)

Library versions being used within our application:
Aspose library: 21.8.0.0;
C# version: 4.7.2
Browser: Chrome latest version

Request: We would like to know from the C# code side of how to render image encoded in Base64string embedded within a RTF content to render the Base64 string as an image when converted to HTML using aspose.word library. Any API’s or properties we need to use to achieve this functionality. Sample code snippet from your side would help us proceed further.

Problem statement: Within the RTF content there is an image embedded in Base64 string. When we use aspose.word library to convert rtf text to html, the Base64 string is rendering as text instead of Image in the HTML output. Here is the code snippet used in our application

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.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;
	}
}

Attached files for your reference:

  1. Image_EncodedInBase64_Within_RTFContent_Notworking.txt (raw full rtf file with content & embedded Base64 string [string starting as /9j/4AAImage_EncodedInBase64_Within_RTFContent_Notworking.pdf (255.0 KB)
    QSkZJRgABAQEAYABgAAD/)
  2. Image_EncodedInBase64_Within_RTFContent_Notworking.pdf (Output of the Aspose.Words when printed on a SaveToPDF using the windows print dialog)

Please let me know if you need more information. Thank you.
Image_EncodedInBase64_Within_RTFContent_Notworking.pdf (255 KB)
Image_EncodedInBase64_Within_RTFContent_Notworking.zip (248 KB)

@Gururaj_Kuruba You have encountered an expected behavior in this case. As I can see base64 data is inserted into your RTF document as simple text. If you open it in MS Word you will see the same.