Aymkdn / html-to-pdfmake

This module permits to convert HTML to the PDFMake format
https://aymkdn.github.io/html-to-pdfmake/index.html
MIT License
545 stars 88 forks source link

<td> rowspan break the pdfMake #189

Closed IvanKYW closed 1 year ago

IvanKYW commented 1 year ago

Hi, when <td> in second row use rowspan like this will break the pdfMake:

<table style="border-collapse: collapse; width: 100%; height: 48px;" border="1">
   <tbody>
      <tr style="height: 24px;">
         <td >&nbsp;</td>
         <td >&nbsp;</td>
         <td >&nbsp;</td>
      </tr>
      <tr style="height: 24px;">
         <td rowspan="2">&nbsp;</td>
         <td rowspan="2">&nbsp;</td>
         <td rowspan="2">&nbsp;</td>
      </tr>
      <tr></tr>
   </tbody>
</table>

The html is generate by TinyMCE editor by create a three rows table and rowspan last two, it can also be reproduce in demo page.

Thank you for building this library!

Aymkdn commented 1 year ago

I don't see the point of creating this kind of code… It might be HTML valid, but the visual result is pointless, no?

It might be tricky to fix… I'll check now if I can find a solution.

Aymkdn commented 1 year ago

I've just published v2.4.23 that shoud work with this example.

IvanKYW commented 1 year ago

Totally agree it's pointless code, I feel confused too when receiving the issue.

Thanks a lot for the quick help!

IvanKYW commented 1 year ago

Sorry, I found that multiple empty tr will break the fix

<table>
   <tbody>
      <tr>
         <td>A</td>
         <td>B</td>
         <td>C</td>
      </tr>
      <tr>
         <td rowspan="3">AA</td>
         <td rowspan="3">BB</td>
         <td rowspan="3">CC</td>
      </tr>
      <tr></tr>
      <tr></tr>
   </tbody>
</table>

Some of our client use rowspan instead of delete when there's more rows than needed in the end leads to the pointless code.

I understand it's weird so if you feel the fix is too ugly please just ignore it, thanks.

Aymkdn commented 1 year ago

I've just published v2.4.24 that should support multiple TR like that.

BTW, if you use this library as a commercial product, it would be nice to make a small donation (no obligation of course) 😍

IvanKYW commented 1 year ago

Thank you for the quick help again!

We are non-profit organization developing system for internal usage, this library indeed helps us a lot! I've make a little donation to support.

Aymkdn commented 1 year ago

Thank you very much 🙏