0

我在 mvc dotnet 中使用 Nreco 将 Html 导出到 Odt(Open office) 文件。但是在得到导出的图像后没有加载到 odt 文件中。我已经尝试将 Html 转换为 Pdf,它工作得非常好,但在 Html 到 Odt 中却没有。请查看以下代码行。

<div style="float:right; width:49%; text-align:right"><img
src="@(Url.Content("~/Content/img/logo.jpg"))" width="225"
height="44" alt="Logo" /></div>

控制器代码:

HtmlToPdfConverter htmltoPdfObj = new HtmlToPdfConverter();
            htmltoPdfObj.Orientation = PageOrientation.Default;
            htmltoPdfObj.CustomWkHtmlArgs = "--margin-top 22 --header-spacing 10 --margin-bottom 20";
            byte[] pdfContents = htmltoPdfObj.GeneratePdf(this.GetPDFScript() + htmlContractData + "</body></html>");
            Response.Clear();
            Response.Charset = "";
            Response.ContentType = "application/vnd.oasis.opendocument.text";
            string strFileName = "GenerateDocument" + ".odt";
            Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
            Response.Write(htmlContractData);
            Response.End();

htmlContractData > 平面 cshtml 文本与上面的 div 图像。

请帮我解决这个困扰我很久的问题

4

0 回答 0