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

Free Support Forum - aspose.com

InsertHtml in MergeField-Event

Hi together,

I got a problem with new line after a mergefield is filled with html-textblock. The Mergefield is on the same line with following words in my word-document . For Example in word as a template (A):

«Textblock1» WORD WORD WORD WORD WORD WORD
NEW LINE WORD WORD WORD

I use the code from your Example in https://reference.aspose.com/words/net/aspose.words.fields/fieldmergefield/. The textblock-template (B) is saved with a lot of lines as a word-document, too. Example of template B:

--------------- BEGIN OF TEMPLATE B ----
Hello world!

Nice to see you there. Now, I’m going back.

Good bye cruel world.
-------------- END OF TEMPLATE B ------

After this doc-template (A) is invoked by InsertHtml-method, it works great to fill a textblock from template B (which is saved in html-format in a memorystream). But the problem is, that after filled the textblock it makes a new line for the following words in template A. The result I get is:

-------------------------------------------
Hello world!

Nice to see you there. Now, I’m going back.

Good bye cruel world. (<- the following words have to begin here on the same line, but it doesn’t)
WORD WORD WORD WORD WORD WORD

NEW LINE WORD WORD WORD
-------------------------------------------

How can I solve it? Got no ideas…

Please, reply quickly

regards chimp

Hi
Thanks for your inquiry. Most probably there is tags in your HTML that is rendered as paragraph break. For example
etc.
You can try using the following code for testing.

Document doc = new Document(@"Test052\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml("<b>test bold</b>");
doc.Save(@"Test052\out.doc");

This will not insert break.
Best regards.