i try to generate a document word it's working with latin font. But i need to use hebrew and Arabic if you test the page here
http://www.independza.com/client/exp/generateDOC/generate.aspx
you could see in the document that it's not working with Hebrew
public void HtmlExportToWord(Object obj, EventArgs e){
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer =true;
HttpContext.Current.Response.ContentType="application/msword";
HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename=test.doc");
HttpContext.Current.Response.Charset = "iso-8859-8 "; //UTF8
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1255"); //windows-1250
HttpContext.Current.Response.Write( FreeTextBox1.Text);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
User-722164976 posted
Setting the Charset and ContentEncoding to the Response object does not give Word any indicator of what encoding the page needs to be displayed in. Word uses the charset in the meta tag to decide which encoding to display the document in.
Your document is being written out in UTF-8 by default, so you'll need to write out the charset like this:
HttpContext.Current.Response.Write("<head><meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\"/></head>");
Next, the ContentEncoding is set to the local codepage, and unless you've specifically saved the content in that codepage, the data won't be interpreted correctly. You'll either need to change it to UTF-8, like this:
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
or it can be removed altogether and your solution should still work correctly.