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

'tableAutoSize' with '%' not working #222

Closed ikbal-nayem closed 1 month ago

ikbal-nayem commented 1 month ago

My HTML code is given bellow,

<table style="border-color: rgb(77, 230, 77); border-width: 2px; width: 83.1%;">
   <colgroup>
      <col style="width:46.65%;">
      <col style="width:41.01%;">
      <col style="width:12.34%;">
   </colgroup>
   <tbody>
      <tr>
         <td style="border-color:hsl(0, 75%, 60%);">sdfsd</td>
         <td style="border-color:hsl(0, 75%, 60%);">sds</td>
         <td style="border-color:hsl(0, 75%, 60%);">zcx</td>
      </tr>
      <tr>
         <td style="border-color:hsl(0, 75%, 60%);">zc</td>
         <td style="border-color:hsl(0, 75%, 60%);">dcsd</td>
         <td style="border-color:hsl(0, 75%, 60%);">cc</td>
      </tr>
   </tbody>
</table>

When I try to convert the HTML to pdfMake JSON with the help of htmlToPdfMake it provides me the following output,

{
  "content": [
    {
      "nodeName": "TABLE",
      "marginBottom": 5,
      "borderColor": "rgb(77, 230, 77)",
      "borderWidth": 2,
      "width": "83.1%",
      "style": [
        "html-table",
        "ck-table-resized"
      ],
      "table": {
        "body": [
          [
            {
              "text": "sdfsd",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            },
            {
              "text": "sds",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            },
            {
              "text": "zcx",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            }
          ],
          [
            {
              "text": "zc",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            },
            {
              "text": "dcsd",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            },
            {
              "text": "cc",
              "nodeName": "TD",
              "borderColor": "hsl(0, 75%, 60%)",
              "borderWidth": 2,
              "style": [
                "html-td",
                "html-tr",
                "html-tbody",
                "html-table",
                "ck-table-resized"
              ]
            }
          ]
        ],
        "widths": [
          "0.9329999999999999%",
          "0.8201999999999999%",
          "0.2468%"
        ],
        "heights": [
          "auto",
          "auto"
        ]
      }
    }
  ],
  "styles": {
    "green": {
      "color": "green"
    }
  }
}

And the PDF output is, image

Aymkdn commented 1 month ago

The width issue should be fixed with v2.5.13