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

Tables with style "width: 100%" now break the pdfmake export as of v.2.4.19 #181

Closed samc36 closed 1 year ago

samc36 commented 1 year ago

Bonjour Aymeric, love the library, but there looks to be a bug that was introduced in v.2.4.19.

Previously, as per the resolution of this issue: https://github.com/Aymkdn/html-to-pdfmake/issues/143 you could add style="width: 100%" to a table to cause the table widths to be set to '*' instead of 'auto'.

Once on 2.4.19 this no longer happens, and instead of being set to '*' the widths are being set to false.

v2.4.18:

[{"nodeName":"TABLE","marginBottom":5,"width":"100%","style":["html-table"],"table":{"body":[[{"text":"Cell
A1","nodeName":"TD","style":["html-td","html-tr","html-tbody","html-table"]},{"text":"Cell
A1","nodeName":"TD","style":["html-td","html-tr","html-tbody","html-table"]}]],"widths":["*","*"],"heights":["auto"]}},{"text":"
"}]

v2.4.19:

[{"nodeName":"TABLE","marginBottom":5,"width":false,"style":["html-table"],"table":{"body":[[{"text":"Cell
A1","nodeName":"TD","width":false,"style":["html-td","html-tr","html-tbody","html-table"]},{"text":"Cell
A1","nodeName":"TD","width":false,"style":["html-td","html-tr","html-tbody","html-table"]}]],"widths":[false,false],"heights":["auto"]}},{"text":"
"}]

This then causes pdfmake to throw this error: Screenshot 2023-04-25 at 09 58 56

You can currently replicate the error on your demo page (https://aymkdn.github.io/html-to-pdfmake/index.html), just use a simple table and set the width to 100%.

Here's the table code:

<table style="width: 100%;">
    <tr>
      <td>Cell A1</td>
      <td>Cell A1</td>
    </tr>
 </table>

I think it may be to do with this change, but not 100% sure: https://github.com/Aymkdn/html-to-pdfmake/commit/2bfd39d7047c24fae8b14e191b2594b3a85dccdc#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R742

Aymkdn commented 1 year ago

Thanks for letting me know. It was actually introduced by this pull request https://github.com/Aymkdn/html-to-pdfmake/pull/180

I've just published v2.4.20 that should solve it.