Skip to content

Commit caf5159

Browse files
authored
Prepare 2.5.2 (#3769)
2.5.2
1 parent c87016c commit caf5159

File tree

105 files changed

+597
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+597
-398
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ yarn add jspdf
2929
Alternatively, load it from a CDN:
3030

3131
```html
32-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
32+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.2/jspdf.umd.min.js"></script>
3333
```
3434

3535
Or always get latest version via [unpkg](https://unpkg.com/browse/jspdf/)
@@ -178,7 +178,7 @@ Alternatively, you can load the prebundled polyfill file. This is not recommende
178178
loading polyfills multiple times. Might still be nifty for small applications or quick POCs.
179179

180180
```html
181-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/polyfills.umd.js"></script>
181+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.2/polyfills.umd.js"></script>
182182
```
183183

184184
## Use of Unicode Characters / UTF-8:

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf",
3-
"version": "2.5.1",
3+
"version": "2.5.2",
44
"homepage": "https://github.com/mrrio/jspdf",
55
"description": "PDF Document creation from JavaScript",
66
"main": [

dist/jspdf.es.js

+40-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 2.5.1 Built on 2022-01-28T15:37:57.791Z
4+
* Version 2.5.2 Built on 2024-09-17T13:29:57.859Z
55
* CommitID 00000000
66
*
77
* Copyright (c) 2010-2021 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
@@ -4554,19 +4554,21 @@ function jsPDF(options) {
45544554
}, options.flags);
45554555
var wordSpacingPerLine = [];
45564556

4557+
var findWidth = function findWidth(v) {
4558+
return scope.getStringUnitWidth(v, {
4559+
font: activeFont,
4560+
charSpace: charSpace,
4561+
fontSize: activeFontSize,
4562+
doKerning: false
4563+
}) * activeFontSize / scaleFactor;
4564+
};
4565+
45574566
if (Object.prototype.toString.call(text) === "[object Array]") {
45584567
da = transformTextToSpecialArray(text);
45594568
var newY;
45604569

45614570
if (align !== "left") {
4562-
lineWidths = da.map(function (v) {
4563-
return scope.getStringUnitWidth(v, {
4564-
font: activeFont,
4565-
charSpace: charSpace,
4566-
fontSize: activeFontSize,
4567-
doKerning: false
4568-
}) * activeFontSize / scaleFactor;
4569-
});
4571+
lineWidths = da.map(findWidth);
45704572
} //The first line uses the "main" Td setting,
45714573
//and the subsequent lines are offset by the
45724574
//previous line's x coordinate.
@@ -4620,6 +4622,34 @@ function jsPDF(options) {
46204622
for (var h = 0; h < len; h++) {
46214623
text.push(da[h]);
46224624
}
4625+
} else if (align === "justify" && activeFont.encoding === "Identity-H") {
4626+
// when using unicode fonts, wordSpacePerLine does not apply
4627+
text = [];
4628+
len = da.length;
4629+
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;
4630+
var backToStartX = 0;
4631+
4632+
for (var l = 0; l < len; l++) {
4633+
newY = l === 0 ? getVerticalCoordinate(y) : -leading;
4634+
newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX;
4635+
4636+
if (l < len - 1) {
4637+
var spacing = scale((maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1));
4638+
var words = da[l].split(" ");
4639+
text.push([words[0] + " ", newX, newY]);
4640+
backToStartX = 0; // distance to reset back to the left
4641+
4642+
for (var _i = 1; _i < words.length; _i++) {
4643+
var shiftAmount = (findWidth(words[_i - 1] + " " + words[_i]) - findWidth(words[_i])) * scaleFactor + spacing;
4644+
if (_i == words.length - 1) text.push([words[_i], shiftAmount, 0]);else text.push([words[_i] + " ", shiftAmount, 0]);
4645+
backToStartX -= shiftAmount;
4646+
}
4647+
} else {
4648+
text.push([da[l], newX, newY]);
4649+
}
4650+
}
4651+
4652+
text.push(["", backToStartX, 0]);
46234653
} else if (align === "justify") {
46244654
text = [];
46254655
len = da.length;
@@ -6649,7 +6679,7 @@ jsPDF.API = {
66496679
* @memberof jsPDF#
66506680
*/
66516681

6652-
jsPDF.version = "2.5.1";
6682+
jsPDF.version = "2.5.2";
66536683

66546684
var jsPDFAPI = jsPDF.API;
66556685
var scaleFactor = 1;

dist/jspdf.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.es.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.es.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.js

+46-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 2.5.1 Built on 2022-01-28T15:37:57.791Z
4+
* Version 2.5.2 Built on 2024-09-17T13:29:57.860Z
55
* CommitID 00000000
66
*
77
* Copyright (c) 2010-2021 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
@@ -4617,23 +4617,23 @@ function jsPDF(options) {
46174617
flags = Object.assign({ autoencode: true, noBOM: true }, options.flags);
46184618

46194619
var wordSpacingPerLine = [];
4620-
4620+
var findWidth = function(v) {
4621+
return (
4622+
(scope.getStringUnitWidth(v, {
4623+
font: activeFont,
4624+
charSpace: charSpace,
4625+
fontSize: activeFontSize,
4626+
doKerning: false
4627+
}) *
4628+
activeFontSize) /
4629+
scaleFactor
4630+
);
4631+
};
46214632
if (Object.prototype.toString.call(text) === "[object Array]") {
46224633
da = transformTextToSpecialArray(text);
46234634
var newY;
46244635
if (align !== "left") {
4625-
lineWidths = da.map(function(v) {
4626-
return (
4627-
(scope.getStringUnitWidth(v, {
4628-
font: activeFont,
4629-
charSpace: charSpace,
4630-
fontSize: activeFontSize,
4631-
doKerning: false
4632-
}) *
4633-
activeFontSize) /
4634-
scaleFactor
4635-
);
4636-
});
4636+
lineWidths = da.map(findWidth);
46374637
}
46384638
//The first line uses the "main" Td setting,
46394639
//and the subsequent lines are offset by the
@@ -4680,11 +4680,41 @@ function jsPDF(options) {
46804680
for (var h = 0; h < len; h++) {
46814681
text.push(da[h]);
46824682
}
4683+
} else if (align === "justify" && activeFont.encoding === "Identity-H") {
4684+
// when using unicode fonts, wordSpacePerLine does not apply
4685+
text = [];
4686+
len = da.length;
4687+
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;
4688+
let backToStartX = 0;
4689+
for (var l = 0; l < len; l++) {
4690+
newY = l === 0 ? getVerticalCoordinate(y) : -leading;
4691+
newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX;
4692+
if (l < len - 1) {
4693+
let spacing = scale(
4694+
(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)
4695+
);
4696+
let words = da[l].split(" ");
4697+
text.push([words[0] + " ", newX, newY]);
4698+
backToStartX = 0; // distance to reset back to the left
4699+
for (let i = 1; i < words.length; i++) {
4700+
let shiftAmount =
4701+
(findWidth(words[i - 1] + " " + words[i]) -
4702+
findWidth(words[i])) *
4703+
scaleFactor +
4704+
spacing;
4705+
if (i == words.length - 1) text.push([words[i], shiftAmount, 0]);
4706+
else text.push([words[i] + " ", shiftAmount, 0]);
4707+
backToStartX -= shiftAmount;
4708+
}
4709+
} else {
4710+
text.push([da[l], newX, newY]);
4711+
}
4712+
}
4713+
text.push(["", backToStartX, 0]);
46834714
} else if (align === "justify") {
46844715
text = [];
46854716
len = da.length;
46864717
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;
4687-
46884718
for (var l = 0; l < len; l++) {
46894719
newY = l === 0 ? getVerticalCoordinate(y) : -leading;
46904720
newX = l === 0 ? getHorizontalCoordinate(x) : 0;
@@ -6861,7 +6891,7 @@ jsPDF.API = {
68616891
* @type {string}
68626892
* @memberof jsPDF#
68636893
*/
6864-
jsPDF.version = "2.5.1";
6894+
jsPDF.version = "2.5.2";
68656895

68666896
/* global jsPDF */
68676897

dist/jspdf.node.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)