Free Support Forum - aspose.com

Insert Html with Image Not working if File name have Unicode chars - Example Swedish Chars

Dear Support,
InsertHtml Method Image not showing if File name have Unicode chars - Example Swedish Chars (teståäö).

Use Base Href while InsertHtml

+ Sample Content with Image.

Working.jpg (8.2 KB)
Not_Working - åäö.png (9.9 KB)

Please give me a work around.
Thanks
Patrick

@patrickjjs,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 18.5 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 18.5.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertHtml("<img src='c:\\temp\\Not_Working - åäö.png' />");

doc.Save(MyDir + "DocumentBuilder.InsertHtml Out.doc");

Hi Tahir,
Please try the following code to reproduce the issue. I tried with Latest Version of Aspose.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

    string workinghtmlinsert = "<base href='" + Server.MapPath(".") + "'/>" + "<table width='650px'><tbody><tr><td> Test </td><td valign='top'><span style='font-family: Verdana; font-size: 8pt'><b>Name </b></span><br><br><span style='font-family: Verdana; font-size:8pt'><b>Date</b></span>&nbsp;</td><td valign='top'><span text='pageno'>&nbsp; </span>&nbsp; <br><br><span style='font-family: Verdana; font-size: 8pt'><b> name &nbsp;  </b></span><br><span style='font-family: Verdana; font-size: 8pt'><b> Number </b></span>&nbsp;</td></tr></tbody></table><div style='width:650px;'><br><br></div>tsdf<br>asd<br>as<br>df<br><br><br><img src='/Images/Working.png' style='' alt=''>";

    string notworkinghtmlinsert = "<base href='" + Server.MapPath(".") + "'/>" + "<table width='650px'><tbody><tr><td> Test </td><td valign='top'><span style='font-family: Verdana; font-size: 8pt'><b>Name </b></span><br><br><span style='font-family: Verdana; font-size:8pt'><b>Date</b></span>&nbsp;</td><td valign='top'><span text='pageno'>&nbsp; </span>&nbsp; <br><br><span style='font-family: Verdana; font-size: 8pt'><b> name &nbsp;  </b></span><br><span style='font-family: Verdana; font-size: 8pt'><b> Number </b></span>&nbsp;</td></tr></tbody></table><div style='width:650px;'><br><br></div>tsdf<br>asd<br>as<br>df<br><br><br><img src='/Images/Not_Working - åäö' style='' alt=''>";

    //builder.InsertHtml(workinghtmlinsert);
    builder.InsertHtml(notworkinghtmlinsert);

    Response.Charset = "iso-8859-1";
    string savefilename = "output.doc";
    Aspose.Words.Saving.SaveOptions saveoptionsformat = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc);

    doc.Save(Response, savefilename, ContentDisposition.Attachment, saveoptionsformat);

Thanks

@patrickjjs,

Thanks for your inquiry. The .png is missing in the HTML string. Please check the attached image. html.png (6.9 KB)

Hi Tahir,
Finally I found the issue.
URL encoding not working in Aspose Word.
for example if file name comes with “Name%20%C3%A5_%C3%A4_%C3%B6_or_%C3%85_%C3%84_%C3%96.png”. Its not decoded correctly.
The Actual file name : "Name å_ä_ö_or_Å_Ä_Ö.png "
But space %20 decoded correctly.

If i add like this, it works fine.
html = html.Replace("%C3%A5", “å”).Replace("%C3%A4", “ä”).Replace("%C3%B6", “ö”).Replace("%C3%85", “Å”).Replace("%C3%84", “Ä”).Replace("%C3%96", “Ö”);

hope you understand the issue. Is it possible to fix globally in Aspose words dll.

Thanks
Patrick

@patrickjjs,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 18.5 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 18.5. We have attached the output DOCX with this post for your kind reference. 18.5.zip (15.5 KB)

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

string notworkinghtmlinsert = "<base href='" + MyDir + "'/>" + "<table width='650px'><tbody><tr><td> Test </td><td valign='top'><span style='font-family: Verdana; font-size: 8pt'><b>Name </b></span><br><br><span style='font-family: Verdana; font-size:8pt'><b>Date</b></span>&nbsp;</td><td valign='top'><span text='pageno'>&nbsp; </span>&nbsp; <br><br><span style='font-family: Verdana; font-size: 8pt'><b> name &nbsp;  </b></span><br><span style='font-family: Verdana; font-size: 8pt'><b> Number </b></span>&nbsp;</td></tr></tbody></table><div style='width:650px;'><br><br></div>tsdf<br>asd<br>as<br>df<br><br><br><img src='Name å_ä_ö_or_Å_Ä_Ö.png' style='' alt=''>";
builder.InsertHtml(notworkinghtmlinsert);

doc.Save(MyDir + "18.5.docx");