Skip to content

Commit 1325e61

Browse files
Enable strict mode for entire library
1 parent 8047853 commit 1325e61

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ function bundle(paths) {
6565
]
6666
}).then(function (bundle) {
6767
var code = bundle.generate({format: 'umd'}).code;
68-
code = code.replace(/'use strict';/, '');
6968
code = code.replace(/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./, 'Licensed under the MIT License');
7069
code = code.replace(/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./g, '');
7170
fs.writeFileSync(paths.debug, renew(code));

plugins/acroform.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
* http://opensource.org/licenses/mit-license
77
*/
88

9-
(AcroForm = function (jsPDFAPI) {
9+
(window.AcroForm = function (jsPDFAPI) {
1010
'use strict';
11+
12+
var AcroForm = window.AcroForm;
1113

1214
AcroForm.scale = function (x) {
1315
return (x * (acroformPlugin.internal.scaleFactor / 1));// 1 = (96 / 72)
@@ -217,10 +219,10 @@
217219
var key = i;
218220
var form = fieldArray[i];
219221
// Start Writing the Object
220-
this.internal.newObjectDeferredBegin(form.objId);
222+
this.internal.newObjectDeferredBegin(form && form.objId);
221223

222224
var content = "";
223-
content += (form.getString());
225+
content += form ? form.getString() : '';
224226
this.internal.out(content);
225227

226228
delete fieldArray[key];
@@ -402,6 +404,8 @@
402404
};
403405
})(jsPDF.API);
404406

407+
var AcroForm = window.AcroForm;
408+
405409
AcroForm.internal = {};
406410

407411
AcroForm.createFormXObject = function (formObject) {
@@ -757,10 +761,10 @@ AcroForm.internal.toPdfString = function (string) {
757761
string = string || "";
758762

759763
// put Bracket at the Beginning of the String
760-
if (String.indexOf('(', 0) !== 0) {
764+
if (string.indexOf('(') !== 0) {
761765
string = '(' + string;
762766
}
763-
767+
764768
if (string.substring(string.length - 1) != ')') {
765769
string += '(';
766770
}
@@ -1043,7 +1047,8 @@ AcroForm.Field = function () {
10431047

10441048
Object.defineProperty(this, 'hasAppearanceStream', {
10451049
enumerable: false,
1046-
configurable: true
1050+
configurable: true,
1051+
writable: true
10471052
});
10481053
};
10491054
AcroForm.Field.FieldNum = 0;
@@ -1088,9 +1093,11 @@ AcroForm.ChoiceField = function () {
10881093
configurable: false
10891094
});
10901095
this.hasAppearanceStream = true;
1091-
this.V.get = function () {
1092-
AcroForm.internal.toPdfString();
1093-
};
1096+
Object.defineProperty(this, 'V', {
1097+
get: function() {
1098+
AcroForm.internal.toPdfString();
1099+
}
1100+
});
10941101
};
10951102
AcroForm.internal.inherit(AcroForm.ChoiceField, AcroForm.Field);
10961103
window["ChoiceField"] = AcroForm.ChoiceField;

plugins/from_html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
DrillForContent,
3434
FontNameDB,
3535
FontStyleMap,
36+
TextAlignMap,
3637
FontWeightMap,
3738
FloatMap,
3839
ClearMap,
@@ -943,7 +944,7 @@
943944
}
944945
//if we have to move the cursor to adapt the indent
945946
var indentMove = 0;
946-
var indentMore = 0;
947+
var wantedIndent = 0;
947948
//if a margin was added (by e.g. a text-alignment), move the cursor
948949
if (line[0][1]["margin-left"] !== undefined && line[0][1]["margin-left"] > 0) {
949950
wantedIndent = this.pdf.internal.getCoordinateString(line[0][1]["margin-left"]);

0 commit comments

Comments
 (0)