Export contenteditable div data to Word causes blank line

Viewed 97

I have a contenteditable div the user enter data. When they enter line break, each browser stores the data differently. When I export this data to Word using HtmlToOpenXml it adds a blank line for the content and I want to avoid that so the html page and word doc look the same.

One option for me is to replace the tags <br>, <div>, <p> with blank and then replace the </div> and </p> with <br/> in the C# code using RegEx. But I do not know what all formatting is used for contenteditable div by different browsers and this implementation may not help.

I would like to know what is the best way to address this or is there any open source tool/dll that helps me with this issue?

e.g. ContentEditable div actual data in browsers looks like below

Chrome -

line1<div>line2</div><div>line3</div>

IE Edge-

 <div>line1</div><div>line22</div><div>line3<br></div>

FireFox - I read it uses <p> </p> instead of <div> </div>

Safari - ????

1 Answers
Related