Word utility is providing below functionality
1. Convert Word to HTML
Using here the OpenXML library for converting the word to HTML string
2. Convert Normal Json String to Key Pair JSON
This will help for sample JSON to key pair JSON for replacing the string
e.g.
{
'CompanyName':'ABC Pvt. Ltd.'
}
Convert To Key Pair
[{'Name':'CompanyName','Value':'ABC Pvt. Ltd.'}
3. Search Text and replace plain text + HTML string
Create word template and place the parameter values from your database.
{{CompanyName}}
{{StreetAddress}}
{{Phone}}
{{Email}}
{{WebSite}}
Case Number :{{CaseNumber}}
{{RecipientName}}
{{StreetAddress1}}
Dear Recipient,
Write the body of your letter here. To update any of the information in this letter, simply click and start typing!
Want to customize your color palette? Just go to the Design ribbon, and select Colors from the list. If you choose a color palette that you like, the colors of the header images will update, as will the text colors. Make the document yours!
Want to change the fonts that are used? That is just as easy to update. Just go to the Design ribbon and choose Fronts from the menu options. You can use a built-in font combination or choose one of your own.
Warm regards,
{{UserName}}
{{Title}}
Refer the below JSON for replacing text values
[{'Name':'CompanyName','Value':'ABC Pvt. Ltd.'},
{'Name':'StreetAddress','Value':'Head Office, Santacruz East.'},
{'Name':'Phone','Value':'9067001347'},
{'Name':'Email','Value':'shahaji.nangare@gmail.com'},
{'Name':'WebSite','Value':'www.google.com'},
{'Name':'CaseNumber','Value':'28923'},
{'Name':'RecipientName','Value':'test'},
{'Name':'StreetAddress1','Value':'n/a'},
{'Name':'UserName','Value':'Shahaji'},
{'Name':'Title','Value':'<b>Mr.</b>'}
]
Refer to w3schools’ tag list to see their meaning
Javascript (<script>), CSS <style>, <meta> and other not supported tags does not generate an error but are ignored.
The parsing of the Html is done using a custom Regex-based enumerator. These are supported: