We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fonts are changed after merge

Hello,

We’re using Aspose 10.4.0. (java) on a windows 2008 server.

When a document is merged some of the merged fields do not have the original font anymore. In the example documents the template has TheSans Basic as font. After the merge the result.doc (see attachment) has text from which the font is changed to Times New Roman.

The template (see attachment) document has fields (eg Client_Geslacht) with a function to do some processing. The merge fields AFTER this particular field have their fonts changed. I’m not sure if it has anything to do with it, but it could be a start to find the problem.

Thank you in advance,

Ischa

P.S. I’m aware that the function is not necessary since we’re using Aspose, but this is part of a migration where the template documents are not to be changed.

Hi

Thanks for your request. I cannot reproduce the problem on my side using the latest version and the following code for testing:

Document doc = new Document("C:\\Temp\\template.doc");

String[] fields = { "Client_Geslacht", "Client_Voorletter", "Client_Voorvoegsel", "Client_Achternaam", "Client_Woonadres_Straat", "Client_Woonadres_Huisnummer" };

String[] values = { "value1", "value2", "value3", "value4", "value5", "value6" };

doc.getMailMerge().execute(fields, values);

doc.save("C:\\Temp\\out.doc");

I have sent the document produced on my side to your e-mail.

Best regards,

Hi Andrey,

Thank you for your effort and your email. Do you think the cause of the problem could be the installed fonts or lack of fonts on the system?

Ischa

Hi

Thank you for additional information. This problem cannot be related to fonts. It seems there is something wrong in your code. Have you tried running my code on your side?

Best regards,

Hi Andrey,

I just tried with your code and checked my own code. I found the difference and the cause of the problem. We use a IFieldMergingCallback implementation to do some HTML stuff. We always insert the merge values as HTML (DocumentBuilder.insertHtml()) regardless of the value does actually contain HTML. But if the value does not contain any HTML it is treated as plain text (I think) and loses its original format. Which is valid in my opinion. So the problem is in our code. Thank you for your time.

Ischa

Hi

It is perfect, that you already fond the reason of the problem. Please let me know in case of any issues, I will be glad to help you.

Best regards,