<code>
@{ List<String> toolsList = new List<string>() { "importExport" };
List<String> importExport = new List<string>() { "import", "wordExport", "pdfExport" };
}
<ej-rte id="rteExport" tools-list="toolsList" width="100%" is-responsive="true" min-width="20px">
<e-tools import-export="importExport" >
</e-tools>
<e-import-settings url="//Internaldemo.syncfusion.com:800/RTE_Export_and_Import_API/RTEimportexport/RTEimportexport/api/RTE/Import" />
<e-export-to-word-settings url="//Internaldemo.syncfusion.com:800/RTE_Export_and_Import_API/RTEimportexport/RTEimportexport/api/RTE/ExportToWord" fileName="WordExport" />
<e-export-to-pdf-settings url="//Internaldemo.syncfusion.com:800/RTE_Export_and_Import_API/RTEimportexport/RTEimportexport/api/RTE/ExportToPDF" fileName="PdfExport" />
</ej-rte>
</code> |
<div class="modal fade" tabindex="-1" id="vModal" data-keyboard="false" data-backdrop="static"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Display Document</h4> </div> <div class="modal-body"> <form> @{ List<String> toolsList = new List<string>() { "style", "lists", "doAction", "links", "images" }; List<String> style = new List<string>() { "bold", "italic", "underline", "strikethrough" }; List<String> lists = new List<string>() { "unorderedList", "orderedList" }; List<String> doAction = new List<string>() { "undo", "redo" }; List<String> links = new List<string>() { "createLink", "removeLink" }; List<String> images = new List<string>() { "image" }; } @{Html.EJ().RTE("rteSample").Width("100%").Height("100%").EnableResize(true) .IsResponsive(true).AllowEditing(false) .ToolsList(toolsList).Tools(tool => tool.Styles(style).Lists(lists) .DoAction(doAction).Links(links).Images(images)).Render();} </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> </div> </div> </div> </div> |
<td> <a type="submit" class="btn btn-default" data-toggle="modal" rel='nofollow' href="#vModal"><i class="fa fa-file-word-o"></i></a> </td> |
<code>
<script>
$(function () {
$("#upload").ejUploadbox({
multipleFilesSelection: false, autoUpload: true, extensionsAllow: ".docx,.doc", showBrowseButton: false, buttonText: { browse: "rteSample" }, showFileDetails: false, saveUrl: "import?rteid=rteSample",
success: function (args) {
var diaobj = $("#Dialog1").data("ejDialog");
diaobj.open();
var rteID = args.model.buttonText.browse, rteObj = $("#rteSample").data("ejRTE"), htmlText = args.responseText, iframe = $(rteObj._getDocument().body);
htmlText = htmlText.replace('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">', '').replace('</string>', '').replace(/"/gi, '');
iframe.children().remove();
iframe.append($.parseHTML(htmlText));
}
});
});
</script>
</code> |
<code>
[HttpPost]
public string Import()
{
string HtmlString = string.Empty;
if (HttpContext.Request.Files.AllKeys.Any())
{
var httpPostedFile = HttpContext.Request.Files["upload"];
if (httpPostedFile != null)
{
using (var mStream = new MemoryStream())
{
new WordDocument(httpPostedFile.InputStream).Save(mStream, FormatType.Html);
mStream.Position = 0;
HtmlString = new StreamReader(mStream).ReadToEnd();
};
HtmlString = ExtractBodyContent(HtmlString);
foreach (var item in DecodeKeys())
{
HtmlString = HtmlString.Replace(item.Key, item.Value);
}
}
else HttpContext.Response.Write("Select any file to upload.");
}
return HtmlString;
}
</code> |