我想显示word.docx转换为pdf并在docx文档保存后显示在我的浏览器中。但是找不到任何好的源代码,所以决定转换为HTML更简单但是当我将这个HTML代码发送到View时,我可以看到HTML代码。该视图不会使HTML显示代码的结果。
VIEW = ConvertHTML.cshtml
@model string
CONTROLLER
public string ConvertHTML(string strDoc)
{
var htmlCode = ParseDOCX(new FileInfo(strDoc));
return h;
}
我试过这个
public IActionResult ConvertHTML(string strDoc)
{
var htmlCode = ParseDOCX(new FileInfo(strDoc));
return View(h);
}
错误:
处理请求时发生未处理的异常。 InvalidOperationException:视图'xmlns =“http://www.w3.org/1999/xhtml”> ..........
我也试过了
@model string
@Html.Raw(Model)
到目前为止没有任何工作
将您的代码更改为:
public IActionResult ConvertHTML(string strDoc)
{
var htmlCode = ParseDOCX(new FileInfo(strDoc));
return Content(htmlCode, "text/html");
}