-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
105 changed files
with
597 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** @license | ||
* | ||
* jsPDF - PDF Document creation from JavaScript | ||
* Version 2.5.1 Built on 2022-01-28T15:37:57.791Z | ||
* Version 2.5.2 Built on 2024-09-17T13:29:57.859Z | ||
* CommitID 00000000 | ||
* | ||
* Copyright (c) 2010-2021 James Hall <[email protected]>, https://github.com/MrRio/jsPDF | ||
|
@@ -4554,19 +4554,21 @@ function jsPDF(options) { | |
}, options.flags); | ||
var wordSpacingPerLine = []; | ||
|
||
var findWidth = function findWidth(v) { | ||
return scope.getStringUnitWidth(v, { | ||
font: activeFont, | ||
charSpace: charSpace, | ||
fontSize: activeFontSize, | ||
doKerning: false | ||
}) * activeFontSize / scaleFactor; | ||
}; | ||
|
||
if (Object.prototype.toString.call(text) === "[object Array]") { | ||
da = transformTextToSpecialArray(text); | ||
var newY; | ||
|
||
if (align !== "left") { | ||
lineWidths = da.map(function (v) { | ||
return scope.getStringUnitWidth(v, { | ||
font: activeFont, | ||
charSpace: charSpace, | ||
fontSize: activeFontSize, | ||
doKerning: false | ||
}) * activeFontSize / scaleFactor; | ||
}); | ||
lineWidths = da.map(findWidth); | ||
} //The first line uses the "main" Td setting, | ||
//and the subsequent lines are offset by the | ||
//previous line's x coordinate. | ||
|
@@ -4620,6 +4622,34 @@ function jsPDF(options) { | |
for (var h = 0; h < len; h++) { | ||
text.push(da[h]); | ||
} | ||
} else if (align === "justify" && activeFont.encoding === "Identity-H") { | ||
// when using unicode fonts, wordSpacePerLine does not apply | ||
text = []; | ||
len = da.length; | ||
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth; | ||
var backToStartX = 0; | ||
|
||
for (var l = 0; l < len; l++) { | ||
newY = l === 0 ? getVerticalCoordinate(y) : -leading; | ||
newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX; | ||
|
||
if (l < len - 1) { | ||
var spacing = scale((maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)); | ||
var words = da[l].split(" "); | ||
text.push([words[0] + " ", newX, newY]); | ||
backToStartX = 0; // distance to reset back to the left | ||
|
||
for (var _i = 1; _i < words.length; _i++) { | ||
var shiftAmount = (findWidth(words[_i - 1] + " " + words[_i]) - findWidth(words[_i])) * scaleFactor + spacing; | ||
if (_i == words.length - 1) text.push([words[_i], shiftAmount, 0]);else text.push([words[_i] + " ", shiftAmount, 0]); | ||
backToStartX -= shiftAmount; | ||
} | ||
} else { | ||
text.push([da[l], newX, newY]); | ||
} | ||
} | ||
|
||
text.push(["", backToStartX, 0]); | ||
} else if (align === "justify") { | ||
text = []; | ||
len = da.length; | ||
|
@@ -6649,7 +6679,7 @@ jsPDF.API = { | |
* @memberof jsPDF# | ||
*/ | ||
|
||
jsPDF.version = "2.5.1"; | ||
jsPDF.version = "2.5.2"; | ||
|
||
var jsPDFAPI = jsPDF.API; | ||
var scaleFactor = 1; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** @license | ||
* | ||
* jsPDF - PDF Document creation from JavaScript | ||
* Version 2.5.1 Built on 2022-01-28T15:37:57.791Z | ||
* Version 2.5.2 Built on 2024-09-17T13:29:57.860Z | ||
* CommitID 00000000 | ||
* | ||
* Copyright (c) 2010-2021 James Hall <[email protected]>, https://github.com/MrRio/jsPDF | ||
|
@@ -4617,23 +4617,23 @@ function jsPDF(options) { | |
flags = Object.assign({ autoencode: true, noBOM: true }, options.flags); | ||
|
||
var wordSpacingPerLine = []; | ||
|
||
var findWidth = function(v) { | ||
return ( | ||
(scope.getStringUnitWidth(v, { | ||
font: activeFont, | ||
charSpace: charSpace, | ||
fontSize: activeFontSize, | ||
doKerning: false | ||
}) * | ||
activeFontSize) / | ||
scaleFactor | ||
); | ||
}; | ||
if (Object.prototype.toString.call(text) === "[object Array]") { | ||
da = transformTextToSpecialArray(text); | ||
var newY; | ||
if (align !== "left") { | ||
lineWidths = da.map(function(v) { | ||
return ( | ||
(scope.getStringUnitWidth(v, { | ||
font: activeFont, | ||
charSpace: charSpace, | ||
fontSize: activeFontSize, | ||
doKerning: false | ||
}) * | ||
activeFontSize) / | ||
scaleFactor | ||
); | ||
}); | ||
lineWidths = da.map(findWidth); | ||
} | ||
//The first line uses the "main" Td setting, | ||
//and the subsequent lines are offset by the | ||
|
@@ -4680,11 +4680,41 @@ function jsPDF(options) { | |
for (var h = 0; h < len; h++) { | ||
text.push(da[h]); | ||
} | ||
} else if (align === "justify" && activeFont.encoding === "Identity-H") { | ||
// when using unicode fonts, wordSpacePerLine does not apply | ||
text = []; | ||
len = da.length; | ||
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth; | ||
let backToStartX = 0; | ||
for (var l = 0; l < len; l++) { | ||
newY = l === 0 ? getVerticalCoordinate(y) : -leading; | ||
newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX; | ||
if (l < len - 1) { | ||
let spacing = scale( | ||
(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1) | ||
); | ||
let words = da[l].split(" "); | ||
text.push([words[0] + " ", newX, newY]); | ||
backToStartX = 0; // distance to reset back to the left | ||
for (let i = 1; i < words.length; i++) { | ||
let shiftAmount = | ||
(findWidth(words[i - 1] + " " + words[i]) - | ||
findWidth(words[i])) * | ||
scaleFactor + | ||
spacing; | ||
if (i == words.length - 1) text.push([words[i], shiftAmount, 0]); | ||
else text.push([words[i] + " ", shiftAmount, 0]); | ||
backToStartX -= shiftAmount; | ||
} | ||
} else { | ||
text.push([da[l], newX, newY]); | ||
} | ||
} | ||
text.push(["", backToStartX, 0]); | ||
} else if (align === "justify") { | ||
text = []; | ||
len = da.length; | ||
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth; | ||
|
||
for (var l = 0; l < len; l++) { | ||
newY = l === 0 ? getVerticalCoordinate(y) : -leading; | ||
newX = l === 0 ? getHorizontalCoordinate(x) : 0; | ||
|
@@ -6861,7 +6891,7 @@ jsPDF.API = { | |
* @type {string} | ||
* @memberof jsPDF# | ||
*/ | ||
jsPDF.version = "2.5.1"; | ||
jsPDF.version = "2.5.2"; | ||
|
||
/* global jsPDF */ | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.