Comparing version
# Changelog | ||
## 0.2.20 - 2025-05-09 | ||
- Fixed text overflow with some non-wrappable texts | ||
## 0.2.19 - 2025-04-26 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "pdfmake", | ||
"version": "0.2.19", | ||
"version": "0.2.20", | ||
"description": "Client/server side PDF printing in pure JavaScript", | ||
@@ -14,10 +14,10 @@ "main": "src/printer.js", | ||
"iconv-lite": "^0.6.3", | ||
"xmldoc": "^2.0.0" | ||
"xmldoc": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.27.0", | ||
"@babel/core": "^7.26.10", | ||
"@babel/plugin-transform-modules-commonjs": "^7.26.3", | ||
"@babel/preset-env": "^7.26.9", | ||
"@eslint/js": "^9.25.1", | ||
"@babel/cli": "^7.27.2", | ||
"@babel/core": "^7.27.1", | ||
"@babel/plugin-transform-modules-commonjs": "^7.27.1", | ||
"@babel/preset-env": "^7.27.2", | ||
"@eslint/js": "^9.26.0", | ||
"assert": "^2.1.0", | ||
@@ -29,8 +29,8 @@ "babel-loader": "^10.0.0", | ||
"core-js": "3.19.0", | ||
"eslint": "^9.25.1", | ||
"eslint": "^9.26.0", | ||
"eslint-plugin-jsdoc": "^50.6.11", | ||
"expose-loader": "^5.0.1", | ||
"file-saver": "^2.0.5", | ||
"globals": "^16.0.0", | ||
"mocha": "^11.1.0", | ||
"globals": "^16.1.0", | ||
"mocha": "^11.2.2", | ||
"npm-run-all": "^4.1.5", | ||
@@ -48,3 +48,3 @@ "process": "^0.11.10", | ||
"util": "^0.12.5", | ||
"webpack": "^5.99.7", | ||
"webpack": "^5.99.8", | ||
"webpack-cli": "^6.0.1" | ||
@@ -51,0 +51,0 @@ }, |
@@ -1046,2 +1046,23 @@ 'use strict'; | ||
function findMaxFitLength(text, maxWidth, measureFn) { | ||
let low = 1; | ||
let high = text.length; | ||
let bestFit = 1; | ||
while (low <= high) { | ||
const mid = Math.floor((low + high) / 2); | ||
const part = text.substring(0, mid); | ||
const width = measureFn(part); | ||
if (width <= maxWidth) { | ||
bestFit = mid; | ||
low = mid + 1; | ||
} else { | ||
high = mid - 1; | ||
} | ||
} | ||
return bestFit; | ||
} | ||
if (!textNode._inlines || textNode._inlines.length === 0) { | ||
@@ -1062,7 +1083,5 @@ return null; | ||
if (!inline.noWrap && inline.text.length > 1 && inline.width > line.getAvailableWidth()) { | ||
var widthPerChar = inline.width / inline.text.length; | ||
var maxChars = Math.floor(line.getAvailableWidth() / widthPerChar); | ||
if (maxChars < 1) { | ||
maxChars = 1; | ||
} | ||
var maxChars = findMaxFitLength(inline.text, line.getAvailableWidth(), function (txt) { | ||
return textTools.widthOfString(txt, inline.font, inline.fontSize, inline.characterSpacing, inline.fontFeatures) | ||
}); | ||
if (maxChars < inline.text.length) { | ||
@@ -1069,0 +1088,0 @@ var newInline = cloneInline(inline); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
13557796
0.02%86145
0.03%Updated