M2Doc adding multiples carriage returns at the export

Hi guys,

I’m strugling with this problem for days now and i definitely need help with this.

I’m on capella 1.4.0 with M2DOC 3.0.0.

Apparently, the HTML of elements description can’t be export correctly.

When I use the fromHTMLBodyString() property on my element description, it appears to add unwanted carriage returns into my description.

This behaviour is basically deterioring as I’m going through my loop. The more elements I have in my loop the more carriage returns i get.

Example:

Item1:


My first description is good.
I can have as many lines as I want.
It’s working

Item2:


I get a first carriage return before the beginning of the description.
\n
And if I have more lines
\n
\n
It starting to be really insane.
\n
\n
\n


I made the test with classic description {m:element.description}, this export the text with all HTML tag without any unwanted carraige return which is basically normal.

I tried to use another template, I got the same behaviour.

Have you any ideas of the problem ?

Thanks for your help

This can be a bug in the fromHTMLBodyString() service. Can you provide the HTML you are passing to the fromHTMLBodyString() service so I can have a look at this issue ?

Hi Yvan,

That was my conclusion too but I have no idea how I can counter it.

For the content it’s just regular text and list without any style.

I tried to re import the whole M2DOC package, now my doc is generated with more than 400 pages instead of 80 (with description only).

After investigating, the service is not the problem. When paragraph generated by the service are inserted, a new line or an empty paragraph is added. I opened the following bug:


I also added a test case to reproduce the issue.
1 Like

I face the same problem, that’s great you are on it ! :+1:

I found a pseudo workaround.

When generated, you can make an advance search for special characters ^| which is “manual carriage return” and replace it with nothing.

It works pretty well but its not optimal

Yes you are 100% right, it was a workaround I just found also, I only make a replacement of ^l^l by ^l

Doing this several times, I reduce the multi ^l in the docx file but in the end I will always have a ^l to still have a separation between lines.

The bug has been corrected in version 3.1.1 of m2doc.
I have managed to install m2doc 3.1.1 with capella 1.4.1 and the description fields are correctly inserted in the generated word document.

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.