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

Free Support Forum - aspose.com

HTML string overrides the merge tag placement

Using plain text string the data aligns with the merge tag just fine.

Converting the plain text string into HTML string using the class below seems to over-write the formatting and placement

private class HandleMergeFieldInsertHtml : IFieldMergingCallback

Template before merge

Template after the merge

Hi James,

Thanks for your inquiry. Please note that you can not merge the formatting of an HTML fragment with formatting of a destination document directly by using the InsertHtml method. The method InsertHtml does not work this way; it uses only formatting of the HTML fragment and does not take destination formatting into account. The HTML fragment that is being inserted into a document should be formatted either before the insertion (by applying CSS styles to HTML elements) or after it (by setting DOM node properties). For example, you should specify margin-left property inside style attribute of

tag. I hope, this helps.

Best regards,

Is there a way to read the position of the merge tag in the word template?

I might be able to adjust the left margin by knowing the position during the merge process.

Hi James,

Thanks for your inquiry. Sure, you can get the parent Paragraph of the MERGEFIELD and determine the left indent for the paragraph by using the ParagraphFormat.LeftIndent property.

Best regards,