Free Support Forum - aspose.com

Aspose Words breaks paragraph into multiple runs even when there is no change in format

Aspose Words breaks paragraph into multiple runs even when there is no change in format.


I have a word document doing basic field replacement as you would do in a mail merge. And when I search the runs for the field to replace, I see it is spanning multiple runs even though there is no change in format.

For example, the document has a line as follows

$$FirstName$$ $$LastName$$

It has 2 fields on a single line. That line has the same font, font size, weight, etc… When I go through the runs in the paragraph, I get inconsistent results. They appear as follows.

Run(0) = $$
Run(1) = FirstName
Run(2) = $$
Run(3) =
Run(4) = $$LastName$$

The Aspose Words documentation says that each run contains text with like formatting. And the only reason to have more than 1 run is if there is a change in formatting.

Am I doing something wrong? Am I interpreting the “Runs” functionality wrong?

Any help is appreciated

Hi Mitch,

Thanks for your inquiry. Yes, it is possible that following text may have multiple Run nodes which have same formatting.

$$FirstName$$ $$LastName$$

Please use Document.JoinRunsWithSameFormatting method joins runs with same formatting in all paragraphs of the document. Hope this helps you.



That solved it.


Thanks!

Hi Mitch,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.