Skip to content

Commit 5028b8b

Browse files
committed
v2.5.24
Added support for '-.' notation in units
1 parent dc66be5 commit 5028b8b

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

browser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/browser-2.5.23.js renamed to docs/browser-2.5.24.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ <h1>HTML to PDFMake convertor</h1>
116116
<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>
117117
</div>
118118
</div>
119-
<script src="browser-2.5.23.js"></script>
119+
<script src="browser-2.5.24.js"></script>
120120
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js"></script>
121121
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.js"></script>
122122
<script>

example.pdf

0 Bytes
Binary file not shown.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ function htmlToPdfMake(htmlText, options) {
10861086
this.convertToUnit = function(val) {
10871087
// if it's just a number, then return it
10881088
if (!isNaN(parseFloat(val)) && isFinite(val)) return val*1;
1089-
var mtch = (val+"").trim().match(/^(\d*(\.\d+)?)(pt|px|r?em|cm|in)$/);
1089+
var mtch = (val + "").trim().match(/^(-?\d*(\.\d+)?)(pt|px|r?em|cm|in)$/);
10901090
// if we don't have a number with supported units, then return false
10911091
if (!mtch) return false;
10921092
val = mtch[1];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-to-pdfmake",
3-
"version": "2.5.23",
3+
"version": "2.5.24",
44
"description": "Convert HTML code to PDFMake",
55
"main": "index.js",
66
"scripts": {

test/unit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ test("unit tests", function(t) {
920920
})
921921

922922
t.test("convertUnit and stack", function(t) {
923-
var html = `<div><div style="font-size:16px;margin-left:12pt">points</div><div style="margin-left:1rem">points</div></div>`;
923+
var html = `<div><div style="font-size:16px;margin-left:12pt">points</div><div style="margin-left:1rem;margin-right:-.25in">points</div></div>`;
924924
var ret = htmlToPdfMake(html, {window:window});
925925
if (debug) console.log(JSON.stringify(ret));
926926
t.check(Array.isArray(ret) && ret.length===1, "return is OK");
@@ -929,7 +929,8 @@ test("unit tests", function(t) {
929929
t.check(
930930
ret.stack[0].marginLeft===12 &&
931931
ret.stack[0].fontSize===12 &&
932-
ret.stack[1].marginLeft===12
932+
ret.stack[1].marginLeft === 12 &&
933+
ret.stack[1].marginRight === -18
933934
, "convertUnit");
934935
t.finish();
935936
})

0 commit comments

Comments
 (0)