Mail Merge Word Document in Salesforce Showing Chinese characters as Boxes

Our Chinese clients started seeing an issue last week with merged document showing Chinese characters as boxes. The first time the document is merged, we see boxes. Sometimes f we merge the document again, the characters are displayed correctly. Can you help us resolve this issue?

EXAMPLE:
Merged document looks like this:
□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□

  1. □□□□□ 2022-12-30 □□□□□□□□□□□□□□□□□□□□□
    ACC □□□ SD00110565
    □□□□□ test
    □□□□□ □ □□ □ □□□□□□/□□ □ □□□ □ □□□□□□□□□□
    □ □□□□□ □ □□□□□□□□
  2. □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
    CNY 2000.88 □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
  3. □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□ 20 □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
  4. □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□/□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□
  5. □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
    □□□□□□□□□□□□□□□□□□□□□□□□□□□□□
  6. □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□

Expected document to look like this:
讲 者 服 务 协 议
甲方: 北京诺华制药有限公司 乙方: 武焱旻
身份证号码: 3203**********2022
医院及科室: 呼吸科-徐州市中心医院
根据已经签署的《讲者服务总协议》,双方就此次服务达成如下约定:

  1. 乙方同意在 2022-12-30 在测试举行的如下会议中为甲方提供讲者服务:
    ACC 编号:SD00110565
    活动名称: test
    服务类型: □ 主席 □ 小组讨论成员/评委 □ 演讲者 □ 培训人员(内部培训)
    □ 病例分享者 □ 患者教育活动讲者
  2. 作为乙方服务的对价,甲方将向乙方支付服务费用并履行个人所得税预扣预缴义务。乙方服务完成并经甲方审
    核通过后,甲方将按照乙方提供的银行账户信息汇付服务费用被扣除预扣预缴个人所得税后的余额人民币
    CNY 2000.88 元。乙方将依法自行至主管税务机关办理个人所得税年度汇算清缴,并自负损益。
  3. 乙方提供的信息和服务应当真实并符合《讲者服务总协议》及本协议的约定。乙方理解,甲方聘请乙方提供讲
    者服务的目的是开展医学教育和学术交流,若甲方发现乙方提供的服务不符合上述目的或存在违反协议约定的
    其他情形,包括但不限于讲课时长少于 20 分钟、参会人员或人数不符合甲方合规要求等,甲方有权拒绝支付
    本协议约定的服务费用。
  4. 乙方为甲方提供服务,应符合乙方所在单位的相关规定并且得到必要的许可。本协议未附加任何影响公平竞争
    的条件,也未与任何商品/服务的购销挂钩。乙方确认其未因任何有违道德标准的行为而受到任何政府部门、
    行业协会或有关组织的惩戒。
  5. 乙方同意,其向甲方提供的个人信息可能在甲方境内外多个信息系统中保存和使用,并用于讲者和活动管理、
    沟通和联系、费用和税款支付、合同管理、审计和合规、讲者服务相关事宜以及执行法律法规或行政机关的要
    求。甲方将采取商业上合理的安全措施保护相关个人信息的安全。
  6. 若乙方获知不良事件,须按照中国有效的相关法律法规的要求,向相关的药品监督管理部门或药品上市许可

@centris.aspose

We will appreciate it if you please share your sample template/data and output document along with the code. We will look into the issue and guide you.

Thanks so much for your response. I don’t know how I can share our code. We have an application that runs off of Salesforce.

This is the template that we are merging:
cp-334001v2 OCE - RYBREVANT Product Theater Invitation Template - Print_IQVIA (1).docx (1.2 MB)

This is the merged document with incorrect characters
Merged with incorrect characters.PDF (28.3 KB)

I merge the same document again exactly the ame way and the characters are correct
same contract merged again and characters are correct.PDF (169.8 KB)

I appreciate any help you can provide.

Thank you

tilal.ahmad:
I am having a similar issue with a Non-Chinese client. The font for merged information is supposed to be Roboto. When I merge for the first time, the font is not right
EXAMPLE:
Invitation Template -Merged with Incorrect Font.PDF (2.5 MB)

If I merge the document a second time, the correct font is included
Invitation Template - Merged second time Font is correct.PDF (2.5 MB)

The template in the case looks like this
cp-334001v2 OCE - RYBREVANT Product Theater Invitation Template - Print_IQVIA (1).docx (1.2 MB)

I think this may be related to the initial issue?

@centris.aspose

It seems you are using some old release, as the output PDF file is showing PDF producer Aspose.Words for .NET 19.3. Can you please confirm you are using Aspose.Words for.NET (on premise API) or Aspose.Words Cloud? You may share the method code where you are calling the Aspose.Words API. It will help us to investigate the issue.

We use Aspose API
the url is [https://api.aspose.com/v1.1

Aspose settings.PNG (4.5 KB)

Salesforce Remote Site Settings for Aspose.PNG (21.3 KB)

Does this help? I am working with Developers to see if I can share the actual code

@centris.aspose

You are using the obsolete API version. The URL is changed to https://api.aspose.cloud since long and please check the latest API Version 4.0. And you can use your custom fonts in the document conversion in the latest API. You just need to upload your fonts to your cloud storage and pass the cloud storage fonts folder path in fontsFolder parameter. It will resolve the issue.

@tilal.ahmad
Thanks so much for the info. We are reviewing the document you provided and the APIs we are using and trying to determine best approach. Can you provide more information about what changed between ver. 1 and 4? This issue just started recently for us and you mentioned that ver 1 was replaced a long time ago. Would it be possible to have a call with our Technical team and someone from Aspose to help guide us through what needs to be done? Also - will you stop supporting 1.1 in the near future?

Thanks very much for your help.

Kathy

@centris.aspose

As stated in the shared blog, V4.0 uses JSON Web Tokens (JWT) for request authentication and has its own API method for storage operations. Please check the following thread to mail merge a Word document with v4.0 in Salesforce. Hopefully, it will help you accomplish the task.

I am afraid we use forums for technical issues. I have shared some details above. However, please feel free to ask any questions in the forum.

We do not support v1.1 anymore, it is obsolete. We are not making any changes or upgrades to it. However, with reference to the above font issue, I am coordinating with our platform team and will share the details.

We are still trouble shooting this issue and still see it happening intermittently. I was able to capture the details in the api usage logs when it happened. The Details in the log show :slight_smile:

'Success: Populate document template with data… name ‘ContractNewa0h0l000003DTFBAA4’,folder ‘’,filename ‘’,cleanup ‘ContainingFields,EmptyParagraphs,UnusedFields,UnusedRegions,RemoveTitleRow,RemoveTitleRowInInnerTables’,useWholeParagraphAsRegion ‘True’,withRegions ‘True’,destFileName ‘’

Request query parameters cleanup
ContainingFields,EmptyParagraphs,UnusedFields,UnusedRegions,RemoveTitleRow,RemoveTitleRowInInnerTables

Can you tell me what this means? Does it help explain what might me causing the fonts to show as blocks in the document?

Request Trace Id
1-6448fb65-45ba20b451b1277b536e3e55
Request Start Date
2023-04-26 6:22:29 AM
Request End Date
2023-04-26 6:22:29 AM

Thanks for your help

@centris.aspose

We are sorry for the inconvenience. I am afraid, as I stated above, that now we are only maintaining V4.0 of Aspose.Words Cloud. So we are not making any changes or fixes to older versions. Please migrate to V4.0; it will resolve the issue.

Can you please share any documentation on How to generate JWT Token for Version 4.0 which is integrated with Salesforce.

@centris.aspose
Please find the Apex code to generate a JWT token for Aspose Cloud Request authentication.

public static string GetJWT(){
    String grant_type = 'client_credentials';
    String client_id= 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx';
    String client_secret= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';	
    HttpRequest request = new HttpRequest();
    
    request.setEndpoint('https://api.aspose.cloud/connect/token');
    request.setMethod('GET');                
    request.setHeader('Content-Type', 'application/x-www-form-urlencoded');              
    request.setHeader('Accept', 'application/json');
    
    String body = 'grant_type=' + grant_type + '&client_id=' + client_id + '&client_secret='+ client_secret ;
    request.setBody(body);
    
    Http http = new Http();
    HttpResponse res = http.send(request);
    String jsonInput = res.getBody();
    Map<String, Object> a =(Map<String, Object>)JSON.deserializeUntyped(jsonInput);
    system.debug('JWT Token is: '+a.get('access_token'));
    
    return a.get('access_token').ToString();
}

Thanks for the sample code snippet.
When I login to the account and click Files on the left menu, I get the below error ‘Cannot get files for the selected storage’ along with a error on the top right section which I am not able to capture a screenshot. But the message said ‘Error while …’

Could this be causing the issue we are seeing now or could it be any kind of storage issue we are running into causing merge issues. We have now close to 5 clients complaining that the Merge does not happen the first time but does work after 4-5 tries.

@centris.aspose

No, the formatting issue is related to the above storage error in the aspose.cloud dashboard. Please re login to aspose.cloud, this issue will be resolved.

Thanks for the feedback. So how can we cleanup the storage so that our users who are actually doing the merge do not have to re-login.

@centris.aspose

I am sorry for any confusion. I meant to re-login to view files in the dashboard UI. Otherwise, you do not need to login/re-login to the dashboard to process files in API calls.

Got it thanks.
Is there a way we can do a mass cleanup if needed?

We are seeing this error when trying to open a folder. Is there any way to clean up the folder?
Storage error Aspose.PNG (102.5 KB)

@centris.aspose

We are investigating the issue and and will share an update with you as soon as possible.