0

I am using Nreco in mvc dotnet to export Html to Odt(Open office) file. But after getting exported image is not getting loaded in odt File. I have tried for Html to Pdf, which is working perfectly fine, but not in Html to Odt. Please look into the below code lines.

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

Controller code:

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 > plane cshtml text with above div Image.

Please help me out with this Issue troubling me since long

Puneet_2696717
  • 221
  • 6
  • 14
  • I guess you use inappropriate component, as NReco PdfGenerator (wkhtmltopdf wrapper) can perform only HTML-to-PDF conversion only. I'm not sure that HTML-to-ODT is possible without OpenOffice itself. BTW, OpenOffice can open HTML directly. – Vitaliy Fedorchenko Jan 10 '18 at 08:21
  • Okay I agree that it's not an appropriate way for solving, but may I know if I have the same scenario what approach can we use for Html to odt export? – Puneet_2696717 Jan 10 '18 at 08:46

0 Answers0