Words.NET InsertHTML Font

Hi,

I am trying to insert some formatted HTML into an existing docx file using builder's insertHTML method. I understand that insertHTML does not inherit font properties from the node it is being inserted into; and I read your post about using nodechanging callback for setting the font size to some default (or containing node's font size).

However, assume a scenario such as inserting the following:

aaaaaabbbbbb

into a node which has size 14. (please ignore synthax for font size above; assume is pseudo code)

Now, if I force set all inserted nodes' sizes to 14 (which is the container node's size); it is NOT correct. If I do not set any of the insert nodes' size; again it is not correct (output contains text with size 12, which is the default).

What exactly we need is to be able to check if the size (or maybe other properties such as name, color etc.) of the node being inserted is coming from DEFAULT values (which are set by your library I guess) and which are coming from SIZE attributes in HTML.

This way, we could override the default values, but leave the parts with specific size attribute untouched. The outcome should show the below:

aaaaaaabbbbbbb : where aaaaaa part has font size 14 (default size 12 is overridden by container node font size) and bbbbb part has font size 16 (container node font size 14 is overridden by the font size coming from the html itself)

Please advise on how to achieve this.

Thanks.

Any responses on this issue please?

Hi there,


Thanks for your inquiry.

I think the code example InsertHtmlWithBuilderFormatting found attached to this forum thread is exactly what you need. Please give it a try and let us know how you go.

Thanks,