@syncfusion/ej2-pdf 24.1.44 → 24.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/ej2-pdf.umd.min.js +1 -10
- package/dist/ej2-pdf.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf.es2015.js +548 -167
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +582 -167
- package/dist/es6/ej2-pdf.es5.js.map +1 -1
- package/dist/global/ej2-pdf.min.js +1 -10
- package/dist/global/ej2-pdf.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/package.json +60 -60
- package/src/pdf/core/annotations/annotation.d.ts +57 -14
- package/src/pdf/core/annotations/annotation.js +129 -34
- package/src/pdf/core/form/field.d.ts +203 -5
- package/src/pdf/core/form/field.js +453 -133
|
@@ -39,6 +39,7 @@ import { PdfAnnotationCollection } from '../annotations/annotation-collection';
|
|
|
39
39
|
var PdfField = /** @class */ (function () {
|
|
40
40
|
function PdfField() {
|
|
41
41
|
this._visible = true;
|
|
42
|
+
this._isTransparentBackColor = false;
|
|
42
43
|
this._defaultFont = new PdfStandardFont(PdfFontFamily.helvetica, 8);
|
|
43
44
|
this._appearanceFont = new PdfStandardFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
|
|
44
45
|
this._defaultItemFont = new PdfStandardFont(PdfFontFamily.timesRoman, 12);
|
|
@@ -597,7 +598,7 @@ var PdfField = /** @class */ (function () {
|
|
|
597
598
|
});
|
|
598
599
|
Object.defineProperty(PdfField.prototype, "backColor", {
|
|
599
600
|
/**
|
|
600
|
-
* Gets the
|
|
601
|
+
* Gets the background color of the field.
|
|
601
602
|
*
|
|
602
603
|
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
603
604
|
* ```typescript
|
|
@@ -605,7 +606,7 @@ var PdfField = /** @class */ (function () {
|
|
|
605
606
|
* let document: PdfDocument = new PdfDocument(data, password);
|
|
606
607
|
* // Access the form field at index 0
|
|
607
608
|
* let field: PdfField = document.form.fieldAt(0);
|
|
608
|
-
* // Gets the
|
|
609
|
+
* // Gets the background color of the field.
|
|
609
610
|
* let backColor: number[] = field.backColor;
|
|
610
611
|
* // Save the document
|
|
611
612
|
* document.save('output.pdf');
|
|
@@ -614,27 +615,10 @@ var PdfField = /** @class */ (function () {
|
|
|
614
615
|
* ```
|
|
615
616
|
*/
|
|
616
617
|
get: function () {
|
|
617
|
-
|
|
618
|
-
var widget = this.itemAt(this._defaultIndex);
|
|
619
|
-
if (widget && widget.backColor) {
|
|
620
|
-
value = widget.backColor;
|
|
621
|
-
}
|
|
622
|
-
else if (this._mkDictionary) {
|
|
623
|
-
var mkDict = this._mkDictionary;
|
|
624
|
-
if (mkDict && mkDict.has('BG')) {
|
|
625
|
-
var bgArray = mkDict.getArray('BG');
|
|
626
|
-
if (bgArray) {
|
|
627
|
-
value = _parseColor(bgArray);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (typeof value === 'undefined' || value === null) {
|
|
632
|
-
value = [255, 255, 255];
|
|
633
|
-
}
|
|
634
|
-
return value;
|
|
618
|
+
return this._parseBackColor(false);
|
|
635
619
|
},
|
|
636
620
|
/**
|
|
637
|
-
* Sets the
|
|
621
|
+
* Sets the background color of the field.
|
|
638
622
|
*
|
|
639
623
|
* @param {number[]} value R, G, B color values in between 0 to 255.
|
|
640
624
|
* ```typescript
|
|
@@ -642,7 +626,7 @@ var PdfField = /** @class */ (function () {
|
|
|
642
626
|
* let document: PdfDocument = new PdfDocument(data, password);
|
|
643
627
|
* // Access the form field at index 0
|
|
644
628
|
* let field: PdfField = document.form.fieldAt(0);
|
|
645
|
-
* // Sets the
|
|
629
|
+
* // Sets the background color of the field.
|
|
646
630
|
* field.backColor = [255, 0, 0];
|
|
647
631
|
* // Save the document
|
|
648
632
|
* document.save('output.pdf');
|
|
@@ -651,27 +635,7 @@ var PdfField = /** @class */ (function () {
|
|
|
651
635
|
* ```
|
|
652
636
|
*/
|
|
653
637
|
set: function (value) {
|
|
654
|
-
|
|
655
|
-
if (widget && widget.backColor !== value) {
|
|
656
|
-
widget.backColor = value;
|
|
657
|
-
}
|
|
658
|
-
else {
|
|
659
|
-
var mkDictionary = this._mkDictionary;
|
|
660
|
-
if (typeof mkDictionary === 'undefined') {
|
|
661
|
-
var dictionary = new _PdfDictionary(this._crossReference);
|
|
662
|
-
dictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
|
|
663
|
-
Number.parseFloat((value[1] / 255).toFixed(3)),
|
|
664
|
-
Number.parseFloat((value[2] / 255).toFixed(3))]);
|
|
665
|
-
this._dictionary.update('MK', dictionary);
|
|
666
|
-
}
|
|
667
|
-
else if (!mkDictionary.has('BG') || _parseColor(mkDictionary.getArray('BG')) !== value) {
|
|
668
|
-
mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
|
|
669
|
-
Number.parseFloat((value[1] / 255).toFixed(3)),
|
|
670
|
-
Number.parseFloat((value[2] / 255).toFixed(3))]);
|
|
671
|
-
this._dictionary._updated = true;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
this._backColorSet = true;
|
|
638
|
+
this._updateBackColor(value);
|
|
675
639
|
},
|
|
676
640
|
enumerable: true,
|
|
677
641
|
configurable: true
|
|
@@ -1328,6 +1292,88 @@ var PdfField = /** @class */ (function () {
|
|
|
1328
1292
|
enumerable: true,
|
|
1329
1293
|
configurable: true
|
|
1330
1294
|
});
|
|
1295
|
+
Object.defineProperty(PdfField.prototype, "_hasBackColor", {
|
|
1296
|
+
get: function () {
|
|
1297
|
+
if (this._isLoaded) {
|
|
1298
|
+
var mkDictionary = this._mkDictionary;
|
|
1299
|
+
if (!mkDictionary) {
|
|
1300
|
+
var item = this.itemAt(this._defaultIndex);
|
|
1301
|
+
if (item && item._dictionary.has('MK')) {
|
|
1302
|
+
mkDictionary = item._dictionary.get('MK');
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
return (mkDictionary && mkDictionary.has('BG'));
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
return !this._isTransparentBackColor;
|
|
1309
|
+
}
|
|
1310
|
+
},
|
|
1311
|
+
enumerable: true,
|
|
1312
|
+
configurable: true
|
|
1313
|
+
});
|
|
1314
|
+
PdfField.prototype._parseBackColor = function (hasTransparency) {
|
|
1315
|
+
var value;
|
|
1316
|
+
if ((!hasTransparency) || ((this._isLoaded && this._hasBackColor) || (!this._isLoaded && !this._isTransparentBackColor))) {
|
|
1317
|
+
var widget = this.itemAt(this._defaultIndex);
|
|
1318
|
+
if (widget && widget.backColor) {
|
|
1319
|
+
value = widget.backColor;
|
|
1320
|
+
}
|
|
1321
|
+
else if (this._mkDictionary) {
|
|
1322
|
+
var mkDict = this._mkDictionary;
|
|
1323
|
+
if (mkDict && mkDict.has('BG')) {
|
|
1324
|
+
var bgArray = mkDict.getArray('BG');
|
|
1325
|
+
if (bgArray) {
|
|
1326
|
+
value = _parseColor(bgArray);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (typeof value === 'undefined' || value === null) {
|
|
1331
|
+
value = [255, 255, 255];
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return value;
|
|
1335
|
+
};
|
|
1336
|
+
PdfField.prototype._updateBackColor = function (value, hasTransparency) {
|
|
1337
|
+
if (hasTransparency === void 0) { hasTransparency = false; }
|
|
1338
|
+
if (hasTransparency && value.length === 4 && value[3] !== 255) {
|
|
1339
|
+
this._isTransparentBackColor = true;
|
|
1340
|
+
if (this._dictionary.has('BG')) {
|
|
1341
|
+
delete this._dictionary._map.BG;
|
|
1342
|
+
}
|
|
1343
|
+
var mkDictionary = this._mkDictionary;
|
|
1344
|
+
if (mkDictionary && mkDictionary.has('BG')) {
|
|
1345
|
+
delete mkDictionary._map.BG;
|
|
1346
|
+
this._dictionary._updated = true;
|
|
1347
|
+
}
|
|
1348
|
+
var item = this.itemAt(this._defaultIndex);
|
|
1349
|
+
if (item) {
|
|
1350
|
+
item.backColor = value;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
this._isTransparentBackColor = false;
|
|
1355
|
+
var widget = this.itemAt(this._defaultIndex);
|
|
1356
|
+
if (widget && widget.backColor !== value) {
|
|
1357
|
+
widget.backColor = value;
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
var mkDictionary = this._mkDictionary;
|
|
1361
|
+
if (typeof mkDictionary === 'undefined') {
|
|
1362
|
+
var dictionary = new _PdfDictionary(this._crossReference);
|
|
1363
|
+
dictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
|
|
1364
|
+
Number.parseFloat((value[1] / 255).toFixed(3)),
|
|
1365
|
+
Number.parseFloat((value[2] / 255).toFixed(3))]);
|
|
1366
|
+
this._dictionary.update('MK', dictionary);
|
|
1367
|
+
}
|
|
1368
|
+
else if (!mkDictionary.has('BG') || _parseColor(mkDictionary.getArray('BG')) !== value) {
|
|
1369
|
+
mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
|
|
1370
|
+
Number.parseFloat((value[1] / 255).toFixed(3)),
|
|
1371
|
+
Number.parseFloat((value[2] / 255).toFixed(3))]);
|
|
1372
|
+
this._dictionary._updated = true;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1331
1377
|
/**
|
|
1332
1378
|
* Gets the field item as `PdfWidgetAnnotation` at the specified index.
|
|
1333
1379
|
*
|
|
@@ -1755,42 +1801,44 @@ var PdfField = /** @class */ (function () {
|
|
|
1755
1801
|
var width = parameter.bounds[2] + (2 * inflateValue);
|
|
1756
1802
|
var height = parameter.bounds[3] + (2 * inflateValue);
|
|
1757
1803
|
var shadowBrush = parameter.shadowBrush;
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1804
|
+
if (shadowBrush) {
|
|
1805
|
+
var shadowColor = shadowBrush._color;
|
|
1806
|
+
var leftTop = void 0;
|
|
1807
|
+
var rightBottom = void 0;
|
|
1808
|
+
switch (parameter.borderStyle) {
|
|
1809
|
+
case PdfBorderStyle.beveled:
|
|
1810
|
+
switch (state) {
|
|
1811
|
+
case _PdfCheckFieldState.pressedChecked:
|
|
1812
|
+
case _PdfCheckFieldState.pressedUnchecked:
|
|
1813
|
+
leftTop = new PdfPen(shadowColor, borderWidth);
|
|
1814
|
+
rightBottom = new PdfPen([255, 255, 255], borderWidth);
|
|
1815
|
+
break;
|
|
1816
|
+
case _PdfCheckFieldState.checked:
|
|
1817
|
+
case _PdfCheckFieldState.unchecked:
|
|
1818
|
+
leftTop = new PdfPen([255, 255, 255], borderWidth);
|
|
1819
|
+
rightBottom = new PdfPen(shadowColor, borderWidth);
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
break;
|
|
1823
|
+
case PdfBorderStyle.inset:
|
|
1824
|
+
switch (state) {
|
|
1825
|
+
case _PdfCheckFieldState.pressedChecked:
|
|
1826
|
+
case _PdfCheckFieldState.pressedUnchecked:
|
|
1827
|
+
leftTop = new PdfPen([0, 0, 0], borderWidth);
|
|
1828
|
+
rightBottom = new PdfPen([0, 0, 0], borderWidth);
|
|
1829
|
+
break;
|
|
1830
|
+
case _PdfCheckFieldState.checked:
|
|
1831
|
+
case _PdfCheckFieldState.unchecked:
|
|
1832
|
+
leftTop = new PdfPen([128, 128, 128], borderWidth);
|
|
1833
|
+
rightBottom = new PdfPen([192, 192, 192], borderWidth);
|
|
1834
|
+
break;
|
|
1835
|
+
}
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
if (leftTop && rightBottom) {
|
|
1839
|
+
graphics.drawArc(x, y, width, height, 135, 180, leftTop);
|
|
1840
|
+
graphics.drawArc(x, y, width, height, -45, 180, rightBottom);
|
|
1841
|
+
}
|
|
1794
1842
|
}
|
|
1795
1843
|
};
|
|
1796
1844
|
PdfField.prototype._drawCheckBox = function (graphics, parameter, checkSymbol, state, font) {
|
|
@@ -2781,6 +2829,54 @@ var PdfTextBoxField = /** @class */ (function (_super) {
|
|
|
2781
2829
|
enumerable: true,
|
|
2782
2830
|
configurable: true
|
|
2783
2831
|
});
|
|
2832
|
+
Object.defineProperty(PdfTextBoxField.prototype, "backColor", {
|
|
2833
|
+
/**
|
|
2834
|
+
* Gets the background color of the field.
|
|
2835
|
+
*
|
|
2836
|
+
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
2837
|
+
* ```typescript
|
|
2838
|
+
* // Load an existing PDF document
|
|
2839
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
2840
|
+
* // Access the form field at index 0
|
|
2841
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
2842
|
+
* // Gets the background color of the field.
|
|
2843
|
+
* let backColor: number[] = field.backColor;
|
|
2844
|
+
* // Save the document
|
|
2845
|
+
* document.save('output.pdf');
|
|
2846
|
+
* // Destroy the document
|
|
2847
|
+
* document.destroy();
|
|
2848
|
+
* ```
|
|
2849
|
+
*/
|
|
2850
|
+
get: function () {
|
|
2851
|
+
return this._parseBackColor(true);
|
|
2852
|
+
},
|
|
2853
|
+
/**
|
|
2854
|
+
* Sets the background color of the field.
|
|
2855
|
+
*
|
|
2856
|
+
* @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
|
|
2857
|
+
* ```typescript
|
|
2858
|
+
* // Load an existing PDF document
|
|
2859
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
2860
|
+
* // Access the text box field at index 0
|
|
2861
|
+
* let firstName: PdfField = document.form.fieldAt(0);
|
|
2862
|
+
* // Sets the background color of the field.
|
|
2863
|
+
* firstName.backColor = [255, 0, 0];
|
|
2864
|
+
* // Access the text box field at index 1
|
|
2865
|
+
* let secondName: PdfField = document.form.fieldAt(1);
|
|
2866
|
+
* // Sets the background color of the field to transparent.
|
|
2867
|
+
* secondName.backColor = [0, 0, 0, 0];
|
|
2868
|
+
* // Save the document
|
|
2869
|
+
* document.save('output.pdf');
|
|
2870
|
+
* // Destroy the document
|
|
2871
|
+
* document.destroy();
|
|
2872
|
+
* ```
|
|
2873
|
+
*/
|
|
2874
|
+
set: function (value) {
|
|
2875
|
+
this._updateBackColor(value, true);
|
|
2876
|
+
},
|
|
2877
|
+
enumerable: true,
|
|
2878
|
+
configurable: true
|
|
2879
|
+
});
|
|
2784
2880
|
PdfTextBoxField.prototype._initialize = function (page, name, bounds) {
|
|
2785
2881
|
this._crossReference = page._crossReference;
|
|
2786
2882
|
this._page = page;
|
|
@@ -2910,7 +3006,7 @@ var PdfTextBoxField = /** @class */ (function (_super) {
|
|
|
2910
3006
|
var parameter = new _PaintParameter();
|
|
2911
3007
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
2912
3008
|
var backcolor = widget.backColor;
|
|
2913
|
-
if (isFlatten) {
|
|
3009
|
+
if (isFlatten && backcolor) {
|
|
2914
3010
|
parameter.backBrush = new PdfBrush(backcolor);
|
|
2915
3011
|
}
|
|
2916
3012
|
parameter.foreBrush = new PdfBrush(widget.color);
|
|
@@ -2918,11 +3014,13 @@ var PdfTextBoxField = /** @class */ (function (_super) {
|
|
|
2918
3014
|
parameter.borderPen = new PdfPen(widget.borderColor, border.width);
|
|
2919
3015
|
parameter.borderStyle = border.style;
|
|
2920
3016
|
parameter.borderWidth = border.width;
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
shadowColor[
|
|
2924
|
-
|
|
2925
|
-
|
|
3017
|
+
if (backcolor) {
|
|
3018
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
3019
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
3020
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
3021
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
3022
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
3023
|
+
}
|
|
2926
3024
|
parameter.rotationAngle = widget.rotate;
|
|
2927
3025
|
parameter.insertSpaces = this.insertSpaces;
|
|
2928
3026
|
var text = this.text;
|
|
@@ -3404,6 +3502,54 @@ var PdfButtonField = /** @class */ (function (_super) {
|
|
|
3404
3502
|
enumerable: true,
|
|
3405
3503
|
configurable: true
|
|
3406
3504
|
});
|
|
3505
|
+
Object.defineProperty(PdfButtonField.prototype, "backColor", {
|
|
3506
|
+
/**
|
|
3507
|
+
* Gets the background color of the field.
|
|
3508
|
+
*
|
|
3509
|
+
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
3510
|
+
* ```typescript
|
|
3511
|
+
* // Load an existing PDF document
|
|
3512
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
3513
|
+
* // Access the form field at index 0
|
|
3514
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
3515
|
+
* // Gets the background color of the field.
|
|
3516
|
+
* let backColor: number[] = field.backColor;
|
|
3517
|
+
* // Save the document
|
|
3518
|
+
* document.save('output.pdf');
|
|
3519
|
+
* // Destroy the document
|
|
3520
|
+
* document.destroy();
|
|
3521
|
+
* ```
|
|
3522
|
+
*/
|
|
3523
|
+
get: function () {
|
|
3524
|
+
return this._parseBackColor(true);
|
|
3525
|
+
},
|
|
3526
|
+
/**
|
|
3527
|
+
* Sets the background color of the field.
|
|
3528
|
+
*
|
|
3529
|
+
* @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
|
|
3530
|
+
* ```typescript
|
|
3531
|
+
* // Load an existing PDF document
|
|
3532
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
3533
|
+
* // Access the button field at index 0
|
|
3534
|
+
* let submitButton: PdfField = document.form.fieldAt(0);
|
|
3535
|
+
* // Sets the background color of the field.
|
|
3536
|
+
* submitButton.backColor = [255, 0, 0];
|
|
3537
|
+
* // Access the button field at index 1
|
|
3538
|
+
* let cancelButton: PdfField = document.form.fieldAt(1);
|
|
3539
|
+
* // Sets the background color of the field to transparent.
|
|
3540
|
+
* cancelButton.backColor = [0, 0, 0, 0];
|
|
3541
|
+
* // Save the document
|
|
3542
|
+
* document.save('output.pdf');
|
|
3543
|
+
* // Destroy the document
|
|
3544
|
+
* document.destroy();
|
|
3545
|
+
* ```
|
|
3546
|
+
*/
|
|
3547
|
+
set: function (value) {
|
|
3548
|
+
this._updateBackColor(value, true);
|
|
3549
|
+
},
|
|
3550
|
+
enumerable: true,
|
|
3551
|
+
configurable: true
|
|
3552
|
+
});
|
|
3407
3553
|
PdfButtonField.prototype._assignText = function (fieldDictionary, value) {
|
|
3408
3554
|
var dictionary;
|
|
3409
3555
|
if (fieldDictionary.has('MK')) {
|
|
@@ -3564,17 +3710,21 @@ var PdfButtonField = /** @class */ (function (_super) {
|
|
|
3564
3710
|
var parameter = new _PaintParameter();
|
|
3565
3711
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
3566
3712
|
var backcolor = widget.backColor;
|
|
3567
|
-
|
|
3713
|
+
if (backcolor) {
|
|
3714
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
3715
|
+
}
|
|
3568
3716
|
parameter.foreBrush = new PdfBrush(widget.color);
|
|
3569
3717
|
var border = widget.border;
|
|
3570
3718
|
parameter.borderPen = new PdfPen(widget.borderColor, border.width);
|
|
3571
3719
|
parameter.borderStyle = border.style;
|
|
3572
3720
|
parameter.borderWidth = border.width;
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
shadowColor[
|
|
3576
|
-
|
|
3577
|
-
|
|
3721
|
+
if (backcolor) {
|
|
3722
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
3723
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
3724
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
3725
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
3726
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
3727
|
+
}
|
|
3578
3728
|
parameter.rotationAngle = widget.rotate;
|
|
3579
3729
|
if (typeof this._font === 'undefined' || this._font === null) {
|
|
3580
3730
|
this._font = this._defaultFont;
|
|
@@ -3988,6 +4138,54 @@ var PdfCheckBoxField = /** @class */ (function (_super) {
|
|
|
3988
4138
|
enumerable: true,
|
|
3989
4139
|
configurable: true
|
|
3990
4140
|
});
|
|
4141
|
+
Object.defineProperty(PdfCheckBoxField.prototype, "backColor", {
|
|
4142
|
+
/**
|
|
4143
|
+
* Gets the background color of the field.
|
|
4144
|
+
*
|
|
4145
|
+
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
4146
|
+
* ```typescript
|
|
4147
|
+
* // Load an existing PDF document
|
|
4148
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
4149
|
+
* // Access the form field at index 0
|
|
4150
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
4151
|
+
* // Gets the background color of the field.
|
|
4152
|
+
* let backColor: number[] = field.backColor;
|
|
4153
|
+
* // Save the document
|
|
4154
|
+
* document.save('output.pdf');
|
|
4155
|
+
* // Destroy the document
|
|
4156
|
+
* document.destroy();
|
|
4157
|
+
* ```
|
|
4158
|
+
*/
|
|
4159
|
+
get: function () {
|
|
4160
|
+
return this._parseBackColor(true);
|
|
4161
|
+
},
|
|
4162
|
+
/**
|
|
4163
|
+
* Sets the background color of the field.
|
|
4164
|
+
*
|
|
4165
|
+
* @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
|
|
4166
|
+
* ```typescript
|
|
4167
|
+
* // Load an existing PDF document
|
|
4168
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
4169
|
+
* // Access the check box field at index 0
|
|
4170
|
+
* let checkBox1: PdfField = document.form.fieldAt(0);
|
|
4171
|
+
* // Sets the background color of the field.
|
|
4172
|
+
* checkBox1.backColor = [255, 0, 0];
|
|
4173
|
+
* // Access the check box field at index 1
|
|
4174
|
+
* let checkBox2: PdfField = document.form.fieldAt(1);
|
|
4175
|
+
* // Sets the background color of the field to transparent.
|
|
4176
|
+
* checkBox2.backColor = [0, 0, 0, 0];
|
|
4177
|
+
* // Save the document
|
|
4178
|
+
* document.save('output.pdf');
|
|
4179
|
+
* // Destroy the document
|
|
4180
|
+
* document.destroy();
|
|
4181
|
+
* ```
|
|
4182
|
+
*/
|
|
4183
|
+
set: function (value) {
|
|
4184
|
+
this._updateBackColor(value, true);
|
|
4185
|
+
},
|
|
4186
|
+
enumerable: true,
|
|
4187
|
+
configurable: true
|
|
4188
|
+
});
|
|
3991
4189
|
PdfCheckBoxField.prototype._initialize = function (page, name, bounds) {
|
|
3992
4190
|
this._crossReference = page._crossReference;
|
|
3993
4191
|
this._page = page;
|
|
@@ -4075,17 +4273,21 @@ var PdfCheckBoxField = /** @class */ (function (_super) {
|
|
|
4075
4273
|
var parameter = new _PaintParameter();
|
|
4076
4274
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
4077
4275
|
var backcolor = widget.backColor;
|
|
4078
|
-
|
|
4276
|
+
if (backcolor) {
|
|
4277
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
4278
|
+
}
|
|
4079
4279
|
parameter.foreBrush = new PdfBrush(widget.color);
|
|
4080
4280
|
var border = widget.border;
|
|
4081
4281
|
parameter.borderPen = new PdfPen(widget.borderColor, border.width);
|
|
4082
4282
|
parameter.borderStyle = border.style;
|
|
4083
4283
|
parameter.borderWidth = border.width;
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
shadowColor[
|
|
4087
|
-
|
|
4088
|
-
|
|
4284
|
+
if (backcolor) {
|
|
4285
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
4286
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
4287
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
4288
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
4289
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
4290
|
+
}
|
|
4089
4291
|
parameter.rotationAngle = widget.rotate;
|
|
4090
4292
|
var template = new PdfTemplate(parameter.bounds, this._crossReference);
|
|
4091
4293
|
var graphics = template.graphics;
|
|
@@ -4563,17 +4765,21 @@ var PdfRadioButtonListField = /** @class */ (function (_super) {
|
|
|
4563
4765
|
var parameter = new _PaintParameter();
|
|
4564
4766
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
4565
4767
|
var backcolor = widget.backColor;
|
|
4566
|
-
|
|
4768
|
+
if (backcolor) {
|
|
4769
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
4770
|
+
}
|
|
4567
4771
|
parameter.foreBrush = new PdfBrush(widget.color);
|
|
4568
4772
|
var border = widget.border;
|
|
4569
4773
|
parameter.borderPen = new PdfPen(widget.borderColor, border.width);
|
|
4570
4774
|
parameter.borderStyle = border.style;
|
|
4571
4775
|
parameter.borderWidth = border.width;
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
shadowColor[
|
|
4575
|
-
|
|
4576
|
-
|
|
4776
|
+
if (backcolor) {
|
|
4777
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
4778
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
4779
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
4780
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
4781
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
4782
|
+
}
|
|
4577
4783
|
parameter.rotationAngle = widget.rotate;
|
|
4578
4784
|
var template = new PdfTemplate(parameter.bounds, this._crossReference);
|
|
4579
4785
|
var graphics = template.graphics;
|
|
@@ -5297,6 +5503,54 @@ var PdfListField = /** @class */ (function (_super) {
|
|
|
5297
5503
|
enumerable: true,
|
|
5298
5504
|
configurable: true
|
|
5299
5505
|
});
|
|
5506
|
+
Object.defineProperty(PdfListField.prototype, "backColor", {
|
|
5507
|
+
/**
|
|
5508
|
+
* Gets the background color of the field.
|
|
5509
|
+
*
|
|
5510
|
+
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
5511
|
+
* ```typescript
|
|
5512
|
+
* // Load an existing PDF document
|
|
5513
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
5514
|
+
* // Access the form field at index 0
|
|
5515
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
5516
|
+
* // Gets the background color of the field.
|
|
5517
|
+
* let backColor: number[] = field.backColor;
|
|
5518
|
+
* // Save the document
|
|
5519
|
+
* document.save('output.pdf');
|
|
5520
|
+
* // Destroy the document
|
|
5521
|
+
* document.destroy();
|
|
5522
|
+
* ```
|
|
5523
|
+
*/
|
|
5524
|
+
get: function () {
|
|
5525
|
+
return this._parseBackColor(true);
|
|
5526
|
+
},
|
|
5527
|
+
/**
|
|
5528
|
+
* Sets the background color of the field.
|
|
5529
|
+
*
|
|
5530
|
+
* @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
|
|
5531
|
+
* ```typescript
|
|
5532
|
+
* // Load an existing PDF document
|
|
5533
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
5534
|
+
* // Access the list field at index 0
|
|
5535
|
+
* let list1: PdfField = document.form.fieldAt(0);
|
|
5536
|
+
* // Sets the background color of the field.
|
|
5537
|
+
* list1.backColor = [255, 0, 0];
|
|
5538
|
+
* // Access the list field at index 1
|
|
5539
|
+
* let list2: PdfField = document.form.fieldAt(1);
|
|
5540
|
+
* // Sets the background color of the field to transparent.
|
|
5541
|
+
* list2.backColor = [0, 0, 0, 0];
|
|
5542
|
+
* // Save the document
|
|
5543
|
+
* document.save('output.pdf');
|
|
5544
|
+
* // Destroy the document
|
|
5545
|
+
* document.destroy();
|
|
5546
|
+
* ```
|
|
5547
|
+
*/
|
|
5548
|
+
set: function (value) {
|
|
5549
|
+
this._updateBackColor(value, true);
|
|
5550
|
+
},
|
|
5551
|
+
enumerable: true,
|
|
5552
|
+
configurable: true
|
|
5553
|
+
});
|
|
5300
5554
|
Object.defineProperty(PdfListField.prototype, "_options", {
|
|
5301
5555
|
get: function () {
|
|
5302
5556
|
if (!this._optionArray) {
|
|
@@ -5928,17 +6182,21 @@ var PdfComboBoxField = /** @class */ (function (_super) {
|
|
|
5928
6182
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
5929
6183
|
}
|
|
5930
6184
|
var backcolor = item.backColor;
|
|
5931
|
-
|
|
6185
|
+
if (backcolor) {
|
|
6186
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
6187
|
+
}
|
|
5932
6188
|
parameter.foreBrush = new PdfBrush(item.color);
|
|
5933
6189
|
var border = item.border;
|
|
5934
6190
|
parameter.borderPen = new PdfPen(item.borderColor, border.width);
|
|
5935
6191
|
parameter.borderStyle = border.style;
|
|
5936
6192
|
parameter.borderWidth = border.width;
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
shadowColor[
|
|
5940
|
-
|
|
5941
|
-
|
|
6193
|
+
if (backcolor) {
|
|
6194
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
6195
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
6196
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
6197
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
6198
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
6199
|
+
}
|
|
5942
6200
|
parameter.rotationAngle = item.rotate;
|
|
5943
6201
|
var alignment = typeof item.textAlignment !== 'undefined' ? item.textAlignment : PdfTextAlignment.left;
|
|
5944
6202
|
var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
|
|
@@ -5958,17 +6216,21 @@ var PdfComboBoxField = /** @class */ (function (_super) {
|
|
|
5958
6216
|
}
|
|
5959
6217
|
}
|
|
5960
6218
|
var backcolor = this.backColor;
|
|
5961
|
-
|
|
6219
|
+
if (backcolor) {
|
|
6220
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
6221
|
+
}
|
|
5962
6222
|
parameter.foreBrush = new PdfBrush(this.color);
|
|
5963
6223
|
var border = this.border;
|
|
5964
6224
|
parameter.borderPen = new PdfPen(this.borderColor, border.width);
|
|
5965
6225
|
parameter.borderStyle = border.style;
|
|
5966
6226
|
parameter.borderWidth = border.width;
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
shadowColor[
|
|
5970
|
-
|
|
5971
|
-
|
|
6227
|
+
if (backcolor) {
|
|
6228
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
6229
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
6230
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
6231
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
6232
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
6233
|
+
}
|
|
5972
6234
|
parameter.rotationAngle = this.rotationAngle;
|
|
5973
6235
|
var alignment = typeof this.textAlignment !== 'undefined' ? this.textAlignment : PdfTextAlignment.left;
|
|
5974
6236
|
var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
|
|
@@ -6307,17 +6569,21 @@ var PdfListBoxField = /** @class */ (function (_super) {
|
|
|
6307
6569
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
6308
6570
|
}
|
|
6309
6571
|
var backcolor = item.backColor;
|
|
6310
|
-
|
|
6572
|
+
if (backcolor) {
|
|
6573
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
6574
|
+
}
|
|
6311
6575
|
parameter.foreBrush = new PdfBrush(item.color);
|
|
6312
6576
|
var border = item.border;
|
|
6313
6577
|
parameter.borderPen = new PdfPen(item.borderColor, border.width);
|
|
6314
6578
|
parameter.borderStyle = border.style;
|
|
6315
6579
|
parameter.borderWidth = border.width;
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
shadowColor[
|
|
6319
|
-
|
|
6320
|
-
|
|
6580
|
+
if (backcolor) {
|
|
6581
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
6582
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
6583
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
6584
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
6585
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
6586
|
+
}
|
|
6321
6587
|
parameter.rotationAngle = item.rotate;
|
|
6322
6588
|
var alignment = typeof item.textAlignment !== 'undefined' ? item.textAlignment : PdfTextAlignment.left;
|
|
6323
6589
|
var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
|
|
@@ -6335,17 +6601,21 @@ var PdfListBoxField = /** @class */ (function (_super) {
|
|
|
6335
6601
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
6336
6602
|
}
|
|
6337
6603
|
var backcolor = this.backColor;
|
|
6338
|
-
|
|
6604
|
+
if (backcolor) {
|
|
6605
|
+
parameter.backBrush = new PdfBrush(backcolor);
|
|
6606
|
+
}
|
|
6339
6607
|
parameter.foreBrush = new PdfBrush(this.color);
|
|
6340
6608
|
var border = this.border;
|
|
6341
6609
|
parameter.borderPen = new PdfPen(this.borderColor, border.width);
|
|
6342
6610
|
parameter.borderStyle = border.style;
|
|
6343
6611
|
parameter.borderWidth = border.width;
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
shadowColor[
|
|
6347
|
-
|
|
6348
|
-
|
|
6612
|
+
if (backcolor) {
|
|
6613
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
6614
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
6615
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
6616
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
6617
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
6618
|
+
}
|
|
6349
6619
|
parameter.rotationAngle = this.rotationAngle;
|
|
6350
6620
|
var alignment = typeof this.textAlignment !== 'undefined' ? this.textAlignment : PdfTextAlignment.left;
|
|
6351
6621
|
var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
|
|
@@ -6559,6 +6829,54 @@ var PdfSignatureField = /** @class */ (function (_super) {
|
|
|
6559
6829
|
enumerable: true,
|
|
6560
6830
|
configurable: true
|
|
6561
6831
|
});
|
|
6832
|
+
Object.defineProperty(PdfSignatureField.prototype, "backColor", {
|
|
6833
|
+
/**
|
|
6834
|
+
* Gets the background color of the field.
|
|
6835
|
+
*
|
|
6836
|
+
* @returns {number[]} R, G, B color values in between 0 to 255.
|
|
6837
|
+
* ```typescript
|
|
6838
|
+
* // Load an existing PDF document
|
|
6839
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
6840
|
+
* // Access the form field at index 0
|
|
6841
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
6842
|
+
* // Gets the background color of the field.
|
|
6843
|
+
* let backColor: number[] = field.backColor;
|
|
6844
|
+
* // Save the document
|
|
6845
|
+
* document.save('output.pdf');
|
|
6846
|
+
* // Destroy the document
|
|
6847
|
+
* document.destroy();
|
|
6848
|
+
* ```
|
|
6849
|
+
*/
|
|
6850
|
+
get: function () {
|
|
6851
|
+
return this._parseBackColor(true);
|
|
6852
|
+
},
|
|
6853
|
+
/**
|
|
6854
|
+
* Sets the background color of the field.
|
|
6855
|
+
*
|
|
6856
|
+
* @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
|
|
6857
|
+
* ```typescript
|
|
6858
|
+
* // Load an existing PDF document
|
|
6859
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
6860
|
+
* // Access the signature field at index 0
|
|
6861
|
+
* let field1: PdfField = document.form.fieldAt(0);
|
|
6862
|
+
* // Sets the background color of the field.
|
|
6863
|
+
* field1.backColor = [255, 0, 0];
|
|
6864
|
+
* // Access the signature field at index 1
|
|
6865
|
+
* let field2: PdfField = document.form.fieldAt(1);
|
|
6866
|
+
* // Sets the background color of the field to transparent.
|
|
6867
|
+
* field2.backColor = [0, 0, 0, 0];
|
|
6868
|
+
* // Save the document
|
|
6869
|
+
* document.save('output.pdf');
|
|
6870
|
+
* // Destroy the document
|
|
6871
|
+
* document.destroy();
|
|
6872
|
+
* ```
|
|
6873
|
+
*/
|
|
6874
|
+
set: function (value) {
|
|
6875
|
+
this._updateBackColor(value, true);
|
|
6876
|
+
},
|
|
6877
|
+
enumerable: true,
|
|
6878
|
+
configurable: true
|
|
6879
|
+
});
|
|
6562
6880
|
PdfSignatureField._load = function (form, dictionary, crossReference, reference) {
|
|
6563
6881
|
var field = new PdfSignatureField();
|
|
6564
6882
|
field._isLoaded = true;
|
|
@@ -6642,7 +6960,7 @@ var PdfSignatureField = /** @class */ (function (_super) {
|
|
|
6642
6960
|
var parameter = new _PaintParameter();
|
|
6643
6961
|
parameter.bounds = [0, 0, bounds.width, bounds.height];
|
|
6644
6962
|
var backcolor = widget.backColor;
|
|
6645
|
-
if (isFlatten) {
|
|
6963
|
+
if (isFlatten && backcolor) {
|
|
6646
6964
|
parameter.backBrush = new PdfBrush(backcolor);
|
|
6647
6965
|
}
|
|
6648
6966
|
parameter.foreBrush = new PdfBrush(widget.color);
|
|
@@ -6650,11 +6968,13 @@ var PdfSignatureField = /** @class */ (function (_super) {
|
|
|
6650
6968
|
parameter.borderPen = new PdfPen(widget.borderColor, border.width);
|
|
6651
6969
|
parameter.borderStyle = border.style;
|
|
6652
6970
|
parameter.borderWidth = border.width;
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
shadowColor[
|
|
6656
|
-
|
|
6657
|
-
|
|
6971
|
+
if (backcolor) {
|
|
6972
|
+
var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
|
|
6973
|
+
var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
|
|
6974
|
+
shadowColor[1] >= 0 ? shadowColor[1] : 0,
|
|
6975
|
+
shadowColor[2] >= 0 ? shadowColor[2] : 0];
|
|
6976
|
+
parameter.shadowBrush = new PdfBrush(color);
|
|
6977
|
+
}
|
|
6658
6978
|
parameter.rotationAngle = widget.rotate;
|
|
6659
6979
|
graphics.save();
|
|
6660
6980
|
graphics._initializeCoordinates();
|