oziresrds / html-to-rtf

Convert html to rtf format in the server
38 stars 43 forks source link

Formatting is lost after conversion to rtf #17

Closed antoniolucasnobar closed 2 years ago

antoniolucasnobar commented 4 years ago

Hello,

I am trying to convert the following html fragment to rtf:

<h2 style="font-family:'Courier New', Courier, monospace;">Título 1</h2>
<h3 style="font-family:'Courier New', Courier, monospace;">Título 2</h3>
<h4 style="font-family:'Courier New', Courier, monospace;">Título 3</h4>
<p class="corpo" style="font-family:'Courier New', Courier, monospace;font-size:12pt;line-height:18pt;text-align:justify;text-indent:4.5cm;">CORPO</p>
<p class="corpo" style="font-family:'Courier New', Courier, monospace;font-size:12pt;line-height:18pt;text-align:justify;text-indent:4.5cm;">Nobis iste harum provident architecto quasi aut. Non aut et culpa quo provident. Eaque facilis voluptatum ut adipisci. Adipisci mollitia accusamus voluptas hic et perspiciatis accusamus.</p>
<p class="ementa" style="font-family:'Courier New', Courier, monospace;font-size:12pt;margin-left:8cm;text-align:justify;">EMENTA</p>
<p class="ementa" style="font-family:'Courier New', Courier, monospace;font-size:12pt;margin-left:8cm;text-align:justify;">Vitae architecto unde officia dolor. Consequuntur aspernatur exercitationem facilis tempora dolorem est illum molestiae. Iusto pariatur rerum quaerat. Dolorem nesciunt numquam autem cum adipisci impedit. Error vero animi omnis aspernatur repellat voluptatem et fuga. Exercitationem consectetur voluptatum nobis natus deserunt iste dolorem.</p>
<p class="transcricao1" style="font-family:'Times New Roman', Times, serif;font-size:12pt;margin-left:4.5cm;text-align:justify;text-indent:1cm;">Transcricao 1</p>
<p class="transcricao1" style="font-family:'Times New Roman', Times, serif;font-size:12pt;margin-left:4.5cm;text-align:justify;text-indent:1cm;">Quisquam quo dolores expedita. Quod vel et distinctio aut quos minima optio qui. Fugit aliquid pariatur sunt nihil mollitia sit quod omnis. Et magnam consequatur atque id qui earum. Aspernatur ex vitae consequatur et velit non.</p>
<p class="transcricao2" style="font-family:'Times New Roman', Times, serif;font-size:12pt;margin-left:6.5cm;text-align:justify;text-indent:1cm;">Transcricao 2</p>
<p class="transcricao2" style="font-family:'Times New Roman', Times, serif;font-size:12pt;margin-left:6.5cm;text-align:justify;text-indent:1cm;">Quas iure impedit unde eligendi corporis. Eligendi harum nostrum labore sed ut minima qui. Totam eius officia et necessitatibus dicta est unde.</p>
<p class="transcricao3" style="border-bottom:0;border-left:0;border-right:0;border-top:0;font-family:'Times New Roman', Times, serif;font-size:10pt;margin-left:7.5cm;padding:0;text-align:justify;text-indent:1cm;">Transcricao 3</p>
<p class="transcricao3" style="border-bottom:0;border-left:0;border-right:0;border-top:0;font-family:'Times New Roman', Times, serif;font-size:10pt;margin-left:7.5cm;padding:0;text-align:justify;text-indent:1cm;">Sint omnis mollitia voluptas suscipit consequatur. Eius minima dolores recusandae earum. Qui rerum corporis ut et adipisci vel qui.</p>
<footer class="rodape" style="font-family:'Times New Roman', Times, serif;font-size:10pt;">RODAPE</footer>
<footer class="rodape" style="font-family:'Times New Roman', Times, serif;font-size:10pt;">Quisquam quo dolores expedita. Quod vel et distinctio aut quos minima optio qui. Fugit aliquid pariatur sunt nihil mollitia sit quod omnis. Et magnam consequatur atque id qui earum. Aspernatur ex vitae consequatur et velit non.</footer>

the class attribute is just syntatic sugar (the classes are empty). The styling I want to keep is all in the style attribute. After generate, I get a RTF without the chosen font neither margin elements (just the text with Calibri font). This is what it show in the browser: image

I am using this lib in the browser, as described in other issue.

but all is lost in the RTF file. Is there some configuration I should use to keep the formatting?

oziresrds commented 2 years ago

Hello @antoniolucasnobar,

The current version does not maintain the font set in the html, it use an default rtf font.