Aspose Words Cloud Python Self Host - Process html(may contain image) in Merge fields

We are trying to migrate from Aspose cloud rest API in rails to a self-hosted Aspose Words Python server since Its not available in Ruby.

In the documentation, there is only basic information regarding merge fields like inserting a string.

Currently We are doing something like in Ruby

@words_api =
mail_merge_request = load_file(@record), data: fields_data)
output_doc = @words_api.execute_mail_merge_online(mail_merge_request)
convert_request =, format: 'pdf')

where field data can be something like

  "format": "html",
  "htmlText":  "<html>
          <img src='#{img_path}'>
          <div style='text-align: center; width: 90%; margin-top: -5px'>#{caption}</div>

How to write the similar thing for Aspose.Words-for-Python-via-.NET self hosted instance

@nikhilgoyal2205 The question is answered here: