Skip to content

Commit

Permalink
v2.5.5
Browse files Browse the repository at this point in the history
Fixed issue introduced in v2.5.3
  • Loading branch information
Aymkdn committed Mar 12, 2024
1 parent 9b1e22f commit 212e42f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion browser.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/browser-2.5.4.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/browser-2.5.5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1>HTML to PDFMake convertor</h1>
<div id="pdf_ie" style="display:none;padding:3em">The PDF file is sent to you for download. Use a modern browser (like Chrome or Firefox) to display the PDF in this page.</div>
</div>
</div>
<script src="browser-2.5.4.js"></script>
<script src="browser-2.5.5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.js"></script>
<script>
Expand Down
Binary file modified example.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function htmlToPdfMake(htmlText, options) {
if ( tableHaveWidth ) {
// if table have defined widths we need to make a
// rule of three to get cell's proportional width
var cellPercentage = cellWidth === 'auto' ? tableWidth / cellsWidths.length : ( cellWidth.replace( '%', "" ) * tableWidth ) / 100;
var cellPercentage = cellWidth === 'auto' ? tableWidth / row.length : ( cellWidth.replace( '%', "" ) * tableWidth ) / 100;
cellWidth = String(cellPercentage) + "%";
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-to-pdfmake",
"version": "2.5.4",
"version": "2.5.5",
"description": "Convert HTML code to PDFMake",
"main": "index.js",
"scripts": {
Expand Down
27 changes: 27 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,5 +1083,32 @@ test("unit tests", function(t) {
t.finish();
})

t.test("table (dynamic widths) 2",function(t) {
var html = `<table class="table table-condensed" style="width: 100%;"><thead><tr><th>ABC</th><th>DEF</th><th>GHI</th><th>KLM</th><th>NOP</th></tr></thead><tbody><tr><td>ABC1</td><td>DEF1</td><td>GHI1</td><td>50,00</td><td style="text-align: right;">17:45</td></tr><tr><td>ABC2</td><td>DEF2</td><td>GHI2</td><td>50,00</td><td style="text-align: right;">4:00</td></tr><tr><td colspan="4">Total</td><td style="text-align: right;">21:45</td></tr></tbody></table>`;
var ret = htmlToPdfMake(html, {
window:window,
tableAutoSize: true
});
if (debug) console.log(JSON.stringify(ret));
t.check(Array.isArray(ret) && ret.length===1, "return is OK");
ret = ret[0];

t.check(
ret.table &&
Array.isArray(ret.table.body) &&
ret.table.body.length === 4 &&
ret.table.body[0][0].text === "ABC" &&
ret.table.body[3][1].text === "" &&
ret.table.widths.length === 5 &&
ret.table.widths[0] === "20%" &&
ret.table.widths[1] === "20%" &&
ret.table.widths[2] === "20%" &&
ret.table.widths[3] === "20%" &&
ret.table.widths[4] === "20%",
"<table> (dynamic widths) 2");

t.finish();
})

t.finish();
})

0 comments on commit 212e42f

Please sign in to comment.