/// <summary> /// Convert the HTML string to a file, download the generated file in the browser /// </summary> /// <param name="htmlContent">The HTML content to export</param> /// <param name="fileName">The FileName of the downloaded file, its extension is used to fetch the exprot provider</param> /// <returns>Returns true if the operation succeeded, false if there was an exception</returns> public async Task <bool> ExportAndDownloadHtmlContent(string htmlContent, string fileName) { try { // prepare a document with the HTML content that we can use for conversion HtmlFormatProvider provider = new HtmlFormatProvider(); RadFlowDocument document = provider.Import(htmlContent); // get the provider to export and then download the file string mimeType; IFormatProvider <RadFlowDocument> exportProvider = GetExportFormatProvider(fileName, out mimeType); byte[] exportFileBytes = null; using (MemoryStream ms = new MemoryStream()) { exportProvider.Export(document, ms); exportFileBytes = ms.ToArray(); } // download the file in the browser await FileDownloader.Save(_js, exportFileBytes, mimeType, fileName); } catch (Exception ex) { return(false); } return(true); }