Image_EncodedInBase64_Within_RTFContent_Notworking.zip (247.8 KB)
Library versions being used within our application:
Aspose library: 188.8.131.52;
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)
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())
// Read the HTML from the stream as plain text.
String myHtml = Encoding.UTF8.GetString(htmlStream.ToArray());
Attached files for your reference:
- 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)
- 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.