Our web application receives files in rtf format and use rft.js to convert rtf to html. Then we save the html version to OS clipboard with text/html format (using web clipboard API). So user could then paste the content to other OS native rich text editor (MS Word for example). We found all empty lines are lost during this process. Here is an example:
Converting rtf to html:
rtf:
{\rtf1 \ansi\ansicpg1252
{
\plain \f5 \fs24 \cf0 test line1
\par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \plain \f5 \fs24 \cf0 test line4
}
rtf.js generated html:
<div><span style="font-size: 12pt"> test line1</span></div>
<div style="text-align: left"></div>
<div style="min-height: 12pt; text-align: left"></div>
<div style="min-height: 12pt; text-align: left"></div>
<div style="min-height: 12pt; text-align: left">
<span style="font-size: 12pt">test line4</span>
</div>
The HTML looks good in the browser but when copy the html from web browser and paste it to a rich text editor (like MS Word), the three empty lines in between are missing.
Can we just add <br /> tag in empty divs like below, so all empty lines are preserved when pasting back to OS native rich text editor.
<div><span style="font-size: 12pt"> test line1</span></div>
<div style="text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left">
<span style="font-size: 12pt">test line4</span>
</div>
Our web application receives files in rtf format and use
rft.jsto convert rtf to html. Then we save the html version to OS clipboard with text/html format (using web clipboard API). So user could then paste the content to other OS native rich text editor (MS Word for example). We found all empty lines are lost during this process. Here is an example:Converting rtf to html:
rtf:
rtf.js generated html:
The HTML looks good in the browser but when copy the html from web browser and paste it to a rich text editor (like MS Word), the three empty lines in between are missing.
Can we just add
<br />tag in empty divs like below, so all empty lines are preserved when pasting back to OS native rich text editor.