Mail merge with utf-8 traditional / simplified Chinese

I have an mail merge web application which will take user input value from the web and data from oracle to perform a mail merge. However, I have never made the Chinese character merged correctly. I know aspose word supports Chinese merging. But I cannot find any code sample about it.

Hi

Thanks for your request. Please see the following link to learn how to insert Chinese text into the document:
https://reference.aspose.com/words/net/aspose.words/font/localeidfareast/
In addition, could you please attach your template for testing and provide me sample code that will allow me to reproduce the problem?
Best regards.

How can I use that class on mail merge ? Attached is the war file that I have been using.

Hi

Thank you for additional information. I use the following code for testing and it seems all works fine on my side, Chinese text is shown correctly in the output document.

Document doc = new Document("C:\\Temp\\issue.doc");
String[] names = { "eng_date"
, "ch_date"
, "en_event_name"
, "cn_event_name"
, "time"
, "free"
, "en_desc_header"
, "en_desc_body"
, "cn_desc_header"
, "cn_desc_body"};
Object[] values = { new Date()
, new Date()
, "en_event_name"
, "你好世界"
, new Date()
, "1000"
, "en_desc_header"
, "en_desc_body"
, "你好世界"
, "你好世界"};
doc.getMailMerge().execute(names, values);
doc.save("C:\\Temp\\out.doc");

best regards,

Hi, I finially fixed the db issue. But now I have another question:
I have 2 fields on index.jsp. 1. English Date 2.Chinese Date. I want to merge the chinese date filed by using the mail merge function. I couldn’t get the correct encording display on merged word file. I did set the default encoding to UTF-8 on the JSP. What’s else do i need to do ?

Hi

Thanks for your request. Maybe you should change something in your document. Try specifying the “SimSun” font name of the merge field where Chinese text should be inserted. Also you can try to set language of merge field.
If this does not help, please attach your template here for testing.
Best regards.

I’ve changed the merge field to use SimSun but it still doesn’t work. Attached is my template.

Hi

Thank you for additional information. I used the following code for testing and it seems the output document looks correct:

Document doc = new Document("C:\\Temp\\issue.doc");
String[] names = { "eng_date", "ch_date" };
Object[] values = { "may 12th", "5月12日"};
doc.getMailMerge().execute(names, values);
doc.save("C:\\Temp\\out.doc");

Best regards.

The method you tested was directly input the chinese from the code. What if “5月12日” is retrived from a text field from a JSP ? I did encode the JSP page as UTf-8 and the “5月12日” was merge to my template without converting to correctly.

Hi

Thank you for additional information. Maybe you should use the same technique as described here to handle Chinese text:
http://forums.sun.com/thread.jspa?threadID=459456&start=15
Best regards.

Problem solved, thanks.