Rtf->(x)html without external files

Hi, I’m looking for a way to convert rtf to html with embedded images / fonts / css etc. My rtf files are rather simplistic, text and tables type of things, where we use their (x)html representation in federated web services exchanges. It’s rather impractical to manage external file references across service & security boundaries… Tried options in your API, but external files seem to be written no matter what I do. Can you help? Regards, Gino

Hi Gino,

Thanks for your inquiry. The HtmlSaveOptions can be used to specify additional options when saving a document into the Html, Mhtml or Epub format.

In your case, please use HtmlSaveOptions.CssStyleSheetType and HtmlSaveOptions.ExportImagesAsBase64 properties as shown in following code example to achieve your requirements.

Document doc = new Document(MyDir + "in.rtf");
// Set an option to export form fields as plain text, not as HTML input elements.
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
options.CssStyleSheetType = CssStyleSheetType.Embedded;
options.ExportImagesAsBase64 = true;
doc.Save(MyDir + " Out.html", options);

Yes, that did the trick. Thanks so much.

Hi Gino,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.