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

Free Support Forum - aspose.cloud

How to insert HTML in Mail Merge MS Word

Hi,

I am trying to understand the insert HTML and insert image thing with the ruby aspose cloud API
I have a simple template Standard method fields.docx (12.6 KB)
with 3 fields -

  1. field1 - for simple text (let say Apple)
  2. field2 - for Html data (let say <i>this is italic</i>)
  3. field3 - for image (use This image url for example )

I have looked at the documentation but I am not able to construct the JSON data to populate the template appropriately.
I also looked at this topic but the files are private.
Can anybody tell me the json data format needed to be sent in a request using the data given above?

@nikhilgoyal2205

Please find the sample template and data. Hopefully, it will help you to accomplish the task.

HtmlImageTemplate.zip (11.8 KB)

@tilal.ahmad
Thanks for the prompt response. So, this is with XML format. Generally, we don’t deal with XML in our code. Can you give the same in JSON format? I tried converting the XML data into JSON using different converters but the API is giving an internal server error.
Any help would be greatly appreciated. Thanks!

@nikhilgoyal2205

Please find the JSON data for your reference. Hopefully, it will help you to accomplish the task.

{
   "Item": {
       "field1": "This is the first caption !!!",
      "field2": {
         "format": "html",
         "htmlText": "<html><head><style \ntype=\"text/css\">h2{color:green} .color_red{color:red} .color_green{color:green} .color_magenta{color:magenta} \n.color_olive{color:olive} .color_teal{color:teal}<\/style><\/head><body><h2>Table<\/h2><table \nborder=\"2\" cellspacing=\"0\" cellpadding=\"4\"><tr><th class=\"color_red\">Column \n1<\/th><th class=\"color_green\">Column 2<\/th><\/tr><tr><td \nclass=\"color_magenta\">Value 1.1<\/td><td class=\"color_olive\">Value \n1.2<\/td><\/tr><tr><td class=\"color_teal\">Value \n2.1<\/td><\/tr><\/table><h2>Div<\/h2><div class=\"color_olive\">Outer text<div \nclass=\"color_magenta\">Inner text<\/div>Outer text<\/div><h2>Image<\/h2><br/><img \nsrc=\"data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAADUUlEQVR42lWTWUwTURSGaUtIKY\n5QweISTUzceDGu0Rj1xURjTNQE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vlqeCYUvL/ANIZ7+ohXSdWAAAAAElFTkSuQmCC\"><\/body><\/html>"
      },
      "field3": "https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
   }
}

@tilal.ahmad
Thanks for the reply and help. Works for my current scenarios. If anything complicated pops up, I will reach out.

Thanks again!

1 Like