@syncfusion/ej2-pdf 24.1.47 → 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.
@@ -7231,6 +7231,7 @@ var __extends$3 = (undefined && undefined.__extends) || (function () {
7231
7231
  var PdfField = /** @__PURE__ @class */ (function () {
7232
7232
  function PdfField() {
7233
7233
  this._visible = true;
7234
+ this._isTransparentBackColor = false;
7234
7235
  this._defaultFont = new PdfStandardFont(PdfFontFamily.helvetica, 8);
7235
7236
  this._appearanceFont = new PdfStandardFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
7236
7237
  this._defaultItemFont = new PdfStandardFont(PdfFontFamily.timesRoman, 12);
@@ -7789,7 +7790,7 @@ var PdfField = /** @__PURE__ @class */ (function () {
7789
7790
  });
7790
7791
  Object.defineProperty(PdfField.prototype, "backColor", {
7791
7792
  /**
7792
- * Gets the back color of the field.
7793
+ * Gets the background color of the field.
7793
7794
  *
7794
7795
  * @returns {number[]} R, G, B color values in between 0 to 255.
7795
7796
  * ```typescript
@@ -7797,7 +7798,7 @@ var PdfField = /** @__PURE__ @class */ (function () {
7797
7798
  * let document: PdfDocument = new PdfDocument(data, password);
7798
7799
  * // Access the form field at index 0
7799
7800
  * let field: PdfField = document.form.fieldAt(0);
7800
- * // Gets the back color of the field.
7801
+ * // Gets the background color of the field.
7801
7802
  * let backColor: number[] = field.backColor;
7802
7803
  * // Save the document
7803
7804
  * document.save('output.pdf');
@@ -7806,27 +7807,10 @@ var PdfField = /** @__PURE__ @class */ (function () {
7806
7807
  * ```
7807
7808
  */
7808
7809
  get: function () {
7809
- var value;
7810
- var widget = this.itemAt(this._defaultIndex);
7811
- if (widget && widget.backColor) {
7812
- value = widget.backColor;
7813
- }
7814
- else if (this._mkDictionary) {
7815
- var mkDict = this._mkDictionary;
7816
- if (mkDict && mkDict.has('BG')) {
7817
- var bgArray = mkDict.getArray('BG');
7818
- if (bgArray) {
7819
- value = _parseColor(bgArray);
7820
- }
7821
- }
7822
- }
7823
- if (typeof value === 'undefined' || value === null) {
7824
- value = [255, 255, 255];
7825
- }
7826
- return value;
7810
+ return this._parseBackColor(false);
7827
7811
  },
7828
7812
  /**
7829
- * Sets the back color of the field.
7813
+ * Sets the background color of the field.
7830
7814
  *
7831
7815
  * @param {number[]} value R, G, B color values in between 0 to 255.
7832
7816
  * ```typescript
@@ -7834,7 +7818,7 @@ var PdfField = /** @__PURE__ @class */ (function () {
7834
7818
  * let document: PdfDocument = new PdfDocument(data, password);
7835
7819
  * // Access the form field at index 0
7836
7820
  * let field: PdfField = document.form.fieldAt(0);
7837
- * // Sets the back color of the field.
7821
+ * // Sets the background color of the field.
7838
7822
  * field.backColor = [255, 0, 0];
7839
7823
  * // Save the document
7840
7824
  * document.save('output.pdf');
@@ -7843,27 +7827,7 @@ var PdfField = /** @__PURE__ @class */ (function () {
7843
7827
  * ```
7844
7828
  */
7845
7829
  set: function (value) {
7846
- var widget = this.itemAt(this._defaultIndex);
7847
- if (widget && widget.backColor !== value) {
7848
- widget.backColor = value;
7849
- }
7850
- else {
7851
- var mkDictionary = this._mkDictionary;
7852
- if (typeof mkDictionary === 'undefined') {
7853
- var dictionary = new _PdfDictionary(this._crossReference);
7854
- dictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
7855
- Number.parseFloat((value[1] / 255).toFixed(3)),
7856
- Number.parseFloat((value[2] / 255).toFixed(3))]);
7857
- this._dictionary.update('MK', dictionary);
7858
- }
7859
- else if (!mkDictionary.has('BG') || _parseColor(mkDictionary.getArray('BG')) !== value) {
7860
- mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
7861
- Number.parseFloat((value[1] / 255).toFixed(3)),
7862
- Number.parseFloat((value[2] / 255).toFixed(3))]);
7863
- this._dictionary._updated = true;
7864
- }
7865
- }
7866
- this._backColorSet = true;
7830
+ this._updateBackColor(value);
7867
7831
  },
7868
7832
  enumerable: true,
7869
7833
  configurable: true
@@ -8520,6 +8484,88 @@ var PdfField = /** @__PURE__ @class */ (function () {
8520
8484
  enumerable: true,
8521
8485
  configurable: true
8522
8486
  });
8487
+ Object.defineProperty(PdfField.prototype, "_hasBackColor", {
8488
+ get: function () {
8489
+ if (this._isLoaded) {
8490
+ var mkDictionary = this._mkDictionary;
8491
+ if (!mkDictionary) {
8492
+ var item = this.itemAt(this._defaultIndex);
8493
+ if (item && item._dictionary.has('MK')) {
8494
+ mkDictionary = item._dictionary.get('MK');
8495
+ }
8496
+ }
8497
+ return (mkDictionary && mkDictionary.has('BG'));
8498
+ }
8499
+ else {
8500
+ return !this._isTransparentBackColor;
8501
+ }
8502
+ },
8503
+ enumerable: true,
8504
+ configurable: true
8505
+ });
8506
+ PdfField.prototype._parseBackColor = function (hasTransparency) {
8507
+ var value;
8508
+ if ((!hasTransparency) || ((this._isLoaded && this._hasBackColor) || (!this._isLoaded && !this._isTransparentBackColor))) {
8509
+ var widget = this.itemAt(this._defaultIndex);
8510
+ if (widget && widget.backColor) {
8511
+ value = widget.backColor;
8512
+ }
8513
+ else if (this._mkDictionary) {
8514
+ var mkDict = this._mkDictionary;
8515
+ if (mkDict && mkDict.has('BG')) {
8516
+ var bgArray = mkDict.getArray('BG');
8517
+ if (bgArray) {
8518
+ value = _parseColor(bgArray);
8519
+ }
8520
+ }
8521
+ }
8522
+ if (typeof value === 'undefined' || value === null) {
8523
+ value = [255, 255, 255];
8524
+ }
8525
+ }
8526
+ return value;
8527
+ };
8528
+ PdfField.prototype._updateBackColor = function (value, hasTransparency) {
8529
+ if (hasTransparency === void 0) { hasTransparency = false; }
8530
+ if (hasTransparency && value.length === 4 && value[3] !== 255) {
8531
+ this._isTransparentBackColor = true;
8532
+ if (this._dictionary.has('BG')) {
8533
+ delete this._dictionary._map.BG;
8534
+ }
8535
+ var mkDictionary = this._mkDictionary;
8536
+ if (mkDictionary && mkDictionary.has('BG')) {
8537
+ delete mkDictionary._map.BG;
8538
+ this._dictionary._updated = true;
8539
+ }
8540
+ var item = this.itemAt(this._defaultIndex);
8541
+ if (item) {
8542
+ item.backColor = value;
8543
+ }
8544
+ }
8545
+ else {
8546
+ this._isTransparentBackColor = false;
8547
+ var widget = this.itemAt(this._defaultIndex);
8548
+ if (widget && widget.backColor !== value) {
8549
+ widget.backColor = value;
8550
+ }
8551
+ else {
8552
+ var mkDictionary = this._mkDictionary;
8553
+ if (typeof mkDictionary === 'undefined') {
8554
+ var dictionary = new _PdfDictionary(this._crossReference);
8555
+ dictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
8556
+ Number.parseFloat((value[1] / 255).toFixed(3)),
8557
+ Number.parseFloat((value[2] / 255).toFixed(3))]);
8558
+ this._dictionary.update('MK', dictionary);
8559
+ }
8560
+ else if (!mkDictionary.has('BG') || _parseColor(mkDictionary.getArray('BG')) !== value) {
8561
+ mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
8562
+ Number.parseFloat((value[1] / 255).toFixed(3)),
8563
+ Number.parseFloat((value[2] / 255).toFixed(3))]);
8564
+ this._dictionary._updated = true;
8565
+ }
8566
+ }
8567
+ }
8568
+ };
8523
8569
  /**
8524
8570
  * Gets the field item as `PdfWidgetAnnotation` at the specified index.
8525
8571
  *
@@ -8947,42 +8993,44 @@ var PdfField = /** @__PURE__ @class */ (function () {
8947
8993
  var width = parameter.bounds[2] + (2 * inflateValue);
8948
8994
  var height = parameter.bounds[3] + (2 * inflateValue);
8949
8995
  var shadowBrush = parameter.shadowBrush;
8950
- var shadowColor = shadowBrush._color;
8951
- var leftTop;
8952
- var rightBottom;
8953
- switch (parameter.borderStyle) {
8954
- case PdfBorderStyle.beveled:
8955
- switch (state) {
8956
- case _PdfCheckFieldState.pressedChecked:
8957
- case _PdfCheckFieldState.pressedUnchecked:
8958
- leftTop = new PdfPen(shadowColor, borderWidth);
8959
- rightBottom = new PdfPen([255, 255, 255], borderWidth);
8960
- break;
8961
- case _PdfCheckFieldState.checked:
8962
- case _PdfCheckFieldState.unchecked:
8963
- leftTop = new PdfPen([255, 255, 255], borderWidth);
8964
- rightBottom = new PdfPen(shadowColor, borderWidth);
8965
- break;
8966
- }
8967
- break;
8968
- case PdfBorderStyle.inset:
8969
- switch (state) {
8970
- case _PdfCheckFieldState.pressedChecked:
8971
- case _PdfCheckFieldState.pressedUnchecked:
8972
- leftTop = new PdfPen([0, 0, 0], borderWidth);
8973
- rightBottom = new PdfPen([0, 0, 0], borderWidth);
8974
- break;
8975
- case _PdfCheckFieldState.checked:
8976
- case _PdfCheckFieldState.unchecked:
8977
- leftTop = new PdfPen([128, 128, 128], borderWidth);
8978
- rightBottom = new PdfPen([192, 192, 192], borderWidth);
8979
- break;
8980
- }
8981
- break;
8982
- }
8983
- if (leftTop && rightBottom) {
8984
- graphics.drawArc(x, y, width, height, 135, 180, leftTop);
8985
- graphics.drawArc(x, y, width, height, -45, 180, rightBottom);
8996
+ if (shadowBrush) {
8997
+ var shadowColor = shadowBrush._color;
8998
+ var leftTop = void 0;
8999
+ var rightBottom = void 0;
9000
+ switch (parameter.borderStyle) {
9001
+ case PdfBorderStyle.beveled:
9002
+ switch (state) {
9003
+ case _PdfCheckFieldState.pressedChecked:
9004
+ case _PdfCheckFieldState.pressedUnchecked:
9005
+ leftTop = new PdfPen(shadowColor, borderWidth);
9006
+ rightBottom = new PdfPen([255, 255, 255], borderWidth);
9007
+ break;
9008
+ case _PdfCheckFieldState.checked:
9009
+ case _PdfCheckFieldState.unchecked:
9010
+ leftTop = new PdfPen([255, 255, 255], borderWidth);
9011
+ rightBottom = new PdfPen(shadowColor, borderWidth);
9012
+ break;
9013
+ }
9014
+ break;
9015
+ case PdfBorderStyle.inset:
9016
+ switch (state) {
9017
+ case _PdfCheckFieldState.pressedChecked:
9018
+ case _PdfCheckFieldState.pressedUnchecked:
9019
+ leftTop = new PdfPen([0, 0, 0], borderWidth);
9020
+ rightBottom = new PdfPen([0, 0, 0], borderWidth);
9021
+ break;
9022
+ case _PdfCheckFieldState.checked:
9023
+ case _PdfCheckFieldState.unchecked:
9024
+ leftTop = new PdfPen([128, 128, 128], borderWidth);
9025
+ rightBottom = new PdfPen([192, 192, 192], borderWidth);
9026
+ break;
9027
+ }
9028
+ break;
9029
+ }
9030
+ if (leftTop && rightBottom) {
9031
+ graphics.drawArc(x, y, width, height, 135, 180, leftTop);
9032
+ graphics.drawArc(x, y, width, height, -45, 180, rightBottom);
9033
+ }
8986
9034
  }
8987
9035
  };
8988
9036
  PdfField.prototype._drawCheckBox = function (graphics, parameter, checkSymbol, state, font) {
@@ -9972,6 +10020,54 @@ var PdfTextBoxField = /** @__PURE__ @class */ (function (_super) {
9972
10020
  enumerable: true,
9973
10021
  configurable: true
9974
10022
  });
10023
+ Object.defineProperty(PdfTextBoxField.prototype, "backColor", {
10024
+ /**
10025
+ * Gets the background color of the field.
10026
+ *
10027
+ * @returns {number[]} R, G, B color values in between 0 to 255.
10028
+ * ```typescript
10029
+ * // Load an existing PDF document
10030
+ * let document: PdfDocument = new PdfDocument(data, password);
10031
+ * // Access the form field at index 0
10032
+ * let field: PdfField = document.form.fieldAt(0);
10033
+ * // Gets the background color of the field.
10034
+ * let backColor: number[] = field.backColor;
10035
+ * // Save the document
10036
+ * document.save('output.pdf');
10037
+ * // Destroy the document
10038
+ * document.destroy();
10039
+ * ```
10040
+ */
10041
+ get: function () {
10042
+ return this._parseBackColor(true);
10043
+ },
10044
+ /**
10045
+ * Sets the background color of the field.
10046
+ *
10047
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
10048
+ * ```typescript
10049
+ * // Load an existing PDF document
10050
+ * let document: PdfDocument = new PdfDocument(data, password);
10051
+ * // Access the text box field at index 0
10052
+ * let firstName: PdfField = document.form.fieldAt(0);
10053
+ * // Sets the background color of the field.
10054
+ * firstName.backColor = [255, 0, 0];
10055
+ * // Access the text box field at index 1
10056
+ * let secondName: PdfField = document.form.fieldAt(1);
10057
+ * // Sets the background color of the field to transparent.
10058
+ * secondName.backColor = [0, 0, 0, 0];
10059
+ * // Save the document
10060
+ * document.save('output.pdf');
10061
+ * // Destroy the document
10062
+ * document.destroy();
10063
+ * ```
10064
+ */
10065
+ set: function (value) {
10066
+ this._updateBackColor(value, true);
10067
+ },
10068
+ enumerable: true,
10069
+ configurable: true
10070
+ });
9975
10071
  PdfTextBoxField.prototype._initialize = function (page, name, bounds) {
9976
10072
  this._crossReference = page._crossReference;
9977
10073
  this._page = page;
@@ -10101,7 +10197,7 @@ var PdfTextBoxField = /** @__PURE__ @class */ (function (_super) {
10101
10197
  var parameter = new _PaintParameter();
10102
10198
  parameter.bounds = [0, 0, bounds.width, bounds.height];
10103
10199
  var backcolor = widget.backColor;
10104
- if (isFlatten) {
10200
+ if (isFlatten && backcolor) {
10105
10201
  parameter.backBrush = new PdfBrush(backcolor);
10106
10202
  }
10107
10203
  parameter.foreBrush = new PdfBrush(widget.color);
@@ -10109,11 +10205,13 @@ var PdfTextBoxField = /** @__PURE__ @class */ (function (_super) {
10109
10205
  parameter.borderPen = new PdfPen(widget.borderColor, border.width);
10110
10206
  parameter.borderStyle = border.style;
10111
10207
  parameter.borderWidth = border.width;
10112
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
10113
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
10114
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
10115
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
10116
- parameter.shadowBrush = new PdfBrush(color);
10208
+ if (backcolor) {
10209
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
10210
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
10211
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
10212
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
10213
+ parameter.shadowBrush = new PdfBrush(color);
10214
+ }
10117
10215
  parameter.rotationAngle = widget.rotate;
10118
10216
  parameter.insertSpaces = this.insertSpaces;
10119
10217
  var text = this.text;
@@ -10594,6 +10692,54 @@ var PdfButtonField = /** @__PURE__ @class */ (function (_super) {
10594
10692
  enumerable: true,
10595
10693
  configurable: true
10596
10694
  });
10695
+ Object.defineProperty(PdfButtonField.prototype, "backColor", {
10696
+ /**
10697
+ * Gets the background color of the field.
10698
+ *
10699
+ * @returns {number[]} R, G, B color values in between 0 to 255.
10700
+ * ```typescript
10701
+ * // Load an existing PDF document
10702
+ * let document: PdfDocument = new PdfDocument(data, password);
10703
+ * // Access the form field at index 0
10704
+ * let field: PdfField = document.form.fieldAt(0);
10705
+ * // Gets the background color of the field.
10706
+ * let backColor: number[] = field.backColor;
10707
+ * // Save the document
10708
+ * document.save('output.pdf');
10709
+ * // Destroy the document
10710
+ * document.destroy();
10711
+ * ```
10712
+ */
10713
+ get: function () {
10714
+ return this._parseBackColor(true);
10715
+ },
10716
+ /**
10717
+ * Sets the background color of the field.
10718
+ *
10719
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
10720
+ * ```typescript
10721
+ * // Load an existing PDF document
10722
+ * let document: PdfDocument = new PdfDocument(data, password);
10723
+ * // Access the button field at index 0
10724
+ * let submitButton: PdfField = document.form.fieldAt(0);
10725
+ * // Sets the background color of the field.
10726
+ * submitButton.backColor = [255, 0, 0];
10727
+ * // Access the button field at index 1
10728
+ * let cancelButton: PdfField = document.form.fieldAt(1);
10729
+ * // Sets the background color of the field to transparent.
10730
+ * cancelButton.backColor = [0, 0, 0, 0];
10731
+ * // Save the document
10732
+ * document.save('output.pdf');
10733
+ * // Destroy the document
10734
+ * document.destroy();
10735
+ * ```
10736
+ */
10737
+ set: function (value) {
10738
+ this._updateBackColor(value, true);
10739
+ },
10740
+ enumerable: true,
10741
+ configurable: true
10742
+ });
10597
10743
  PdfButtonField.prototype._assignText = function (fieldDictionary, value) {
10598
10744
  var dictionary;
10599
10745
  if (fieldDictionary.has('MK')) {
@@ -10754,17 +10900,21 @@ var PdfButtonField = /** @__PURE__ @class */ (function (_super) {
10754
10900
  var parameter = new _PaintParameter();
10755
10901
  parameter.bounds = [0, 0, bounds.width, bounds.height];
10756
10902
  var backcolor = widget.backColor;
10757
- parameter.backBrush = new PdfBrush(backcolor);
10903
+ if (backcolor) {
10904
+ parameter.backBrush = new PdfBrush(backcolor);
10905
+ }
10758
10906
  parameter.foreBrush = new PdfBrush(widget.color);
10759
10907
  var border = widget.border;
10760
10908
  parameter.borderPen = new PdfPen(widget.borderColor, border.width);
10761
10909
  parameter.borderStyle = border.style;
10762
10910
  parameter.borderWidth = border.width;
10763
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
10764
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
10765
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
10766
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
10767
- parameter.shadowBrush = new PdfBrush(color);
10911
+ if (backcolor) {
10912
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
10913
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
10914
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
10915
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
10916
+ parameter.shadowBrush = new PdfBrush(color);
10917
+ }
10768
10918
  parameter.rotationAngle = widget.rotate;
10769
10919
  if (typeof this._font === 'undefined' || this._font === null) {
10770
10920
  this._font = this._defaultFont;
@@ -11177,6 +11327,54 @@ var PdfCheckBoxField = /** @__PURE__ @class */ (function (_super) {
11177
11327
  enumerable: true,
11178
11328
  configurable: true
11179
11329
  });
11330
+ Object.defineProperty(PdfCheckBoxField.prototype, "backColor", {
11331
+ /**
11332
+ * Gets the background color of the field.
11333
+ *
11334
+ * @returns {number[]} R, G, B color values in between 0 to 255.
11335
+ * ```typescript
11336
+ * // Load an existing PDF document
11337
+ * let document: PdfDocument = new PdfDocument(data, password);
11338
+ * // Access the form field at index 0
11339
+ * let field: PdfField = document.form.fieldAt(0);
11340
+ * // Gets the background color of the field.
11341
+ * let backColor: number[] = field.backColor;
11342
+ * // Save the document
11343
+ * document.save('output.pdf');
11344
+ * // Destroy the document
11345
+ * document.destroy();
11346
+ * ```
11347
+ */
11348
+ get: function () {
11349
+ return this._parseBackColor(true);
11350
+ },
11351
+ /**
11352
+ * Sets the background color of the field.
11353
+ *
11354
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
11355
+ * ```typescript
11356
+ * // Load an existing PDF document
11357
+ * let document: PdfDocument = new PdfDocument(data, password);
11358
+ * // Access the check box field at index 0
11359
+ * let checkBox1: PdfField = document.form.fieldAt(0);
11360
+ * // Sets the background color of the field.
11361
+ * checkBox1.backColor = [255, 0, 0];
11362
+ * // Access the check box field at index 1
11363
+ * let checkBox2: PdfField = document.form.fieldAt(1);
11364
+ * // Sets the background color of the field to transparent.
11365
+ * checkBox2.backColor = [0, 0, 0, 0];
11366
+ * // Save the document
11367
+ * document.save('output.pdf');
11368
+ * // Destroy the document
11369
+ * document.destroy();
11370
+ * ```
11371
+ */
11372
+ set: function (value) {
11373
+ this._updateBackColor(value, true);
11374
+ },
11375
+ enumerable: true,
11376
+ configurable: true
11377
+ });
11180
11378
  PdfCheckBoxField.prototype._initialize = function (page, name, bounds) {
11181
11379
  this._crossReference = page._crossReference;
11182
11380
  this._page = page;
@@ -11264,17 +11462,21 @@ var PdfCheckBoxField = /** @__PURE__ @class */ (function (_super) {
11264
11462
  var parameter = new _PaintParameter();
11265
11463
  parameter.bounds = [0, 0, bounds.width, bounds.height];
11266
11464
  var backcolor = widget.backColor;
11267
- parameter.backBrush = new PdfBrush(backcolor);
11465
+ if (backcolor) {
11466
+ parameter.backBrush = new PdfBrush(backcolor);
11467
+ }
11268
11468
  parameter.foreBrush = new PdfBrush(widget.color);
11269
11469
  var border = widget.border;
11270
11470
  parameter.borderPen = new PdfPen(widget.borderColor, border.width);
11271
11471
  parameter.borderStyle = border.style;
11272
11472
  parameter.borderWidth = border.width;
11273
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
11274
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
11275
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
11276
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
11277
- parameter.shadowBrush = new PdfBrush(color);
11473
+ if (backcolor) {
11474
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
11475
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
11476
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
11477
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
11478
+ parameter.shadowBrush = new PdfBrush(color);
11479
+ }
11278
11480
  parameter.rotationAngle = widget.rotate;
11279
11481
  var template = new PdfTemplate(parameter.bounds, this._crossReference);
11280
11482
  var graphics = template.graphics;
@@ -11751,17 +11953,21 @@ var PdfRadioButtonListField = /** @__PURE__ @class */ (function (_super) {
11751
11953
  var parameter = new _PaintParameter();
11752
11954
  parameter.bounds = [0, 0, bounds.width, bounds.height];
11753
11955
  var backcolor = widget.backColor;
11754
- parameter.backBrush = new PdfBrush(backcolor);
11956
+ if (backcolor) {
11957
+ parameter.backBrush = new PdfBrush(backcolor);
11958
+ }
11755
11959
  parameter.foreBrush = new PdfBrush(widget.color);
11756
11960
  var border = widget.border;
11757
11961
  parameter.borderPen = new PdfPen(widget.borderColor, border.width);
11758
11962
  parameter.borderStyle = border.style;
11759
11963
  parameter.borderWidth = border.width;
11760
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
11761
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
11762
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
11763
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
11764
- parameter.shadowBrush = new PdfBrush(color);
11964
+ if (backcolor) {
11965
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
11966
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
11967
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
11968
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
11969
+ parameter.shadowBrush = new PdfBrush(color);
11970
+ }
11765
11971
  parameter.rotationAngle = widget.rotate;
11766
11972
  var template = new PdfTemplate(parameter.bounds, this._crossReference);
11767
11973
  var graphics = template.graphics;
@@ -12484,6 +12690,54 @@ var PdfListField = /** @__PURE__ @class */ (function (_super) {
12484
12690
  enumerable: true,
12485
12691
  configurable: true
12486
12692
  });
12693
+ Object.defineProperty(PdfListField.prototype, "backColor", {
12694
+ /**
12695
+ * Gets the background color of the field.
12696
+ *
12697
+ * @returns {number[]} R, G, B color values in between 0 to 255.
12698
+ * ```typescript
12699
+ * // Load an existing PDF document
12700
+ * let document: PdfDocument = new PdfDocument(data, password);
12701
+ * // Access the form field at index 0
12702
+ * let field: PdfField = document.form.fieldAt(0);
12703
+ * // Gets the background color of the field.
12704
+ * let backColor: number[] = field.backColor;
12705
+ * // Save the document
12706
+ * document.save('output.pdf');
12707
+ * // Destroy the document
12708
+ * document.destroy();
12709
+ * ```
12710
+ */
12711
+ get: function () {
12712
+ return this._parseBackColor(true);
12713
+ },
12714
+ /**
12715
+ * Sets the background color of the field.
12716
+ *
12717
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
12718
+ * ```typescript
12719
+ * // Load an existing PDF document
12720
+ * let document: PdfDocument = new PdfDocument(data, password);
12721
+ * // Access the list field at index 0
12722
+ * let list1: PdfField = document.form.fieldAt(0);
12723
+ * // Sets the background color of the field.
12724
+ * list1.backColor = [255, 0, 0];
12725
+ * // Access the list field at index 1
12726
+ * let list2: PdfField = document.form.fieldAt(1);
12727
+ * // Sets the background color of the field to transparent.
12728
+ * list2.backColor = [0, 0, 0, 0];
12729
+ * // Save the document
12730
+ * document.save('output.pdf');
12731
+ * // Destroy the document
12732
+ * document.destroy();
12733
+ * ```
12734
+ */
12735
+ set: function (value) {
12736
+ this._updateBackColor(value, true);
12737
+ },
12738
+ enumerable: true,
12739
+ configurable: true
12740
+ });
12487
12741
  Object.defineProperty(PdfListField.prototype, "_options", {
12488
12742
  get: function () {
12489
12743
  if (!this._optionArray) {
@@ -13114,17 +13368,21 @@ var PdfComboBoxField = /** @__PURE__ @class */ (function (_super) {
13114
13368
  parameter.bounds = [0, 0, bounds.width, bounds.height];
13115
13369
  }
13116
13370
  var backcolor = item.backColor;
13117
- parameter.backBrush = new PdfBrush(backcolor);
13371
+ if (backcolor) {
13372
+ parameter.backBrush = new PdfBrush(backcolor);
13373
+ }
13118
13374
  parameter.foreBrush = new PdfBrush(item.color);
13119
13375
  var border = item.border;
13120
13376
  parameter.borderPen = new PdfPen(item.borderColor, border.width);
13121
13377
  parameter.borderStyle = border.style;
13122
13378
  parameter.borderWidth = border.width;
13123
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13124
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13125
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
13126
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
13127
- parameter.shadowBrush = new PdfBrush(color);
13379
+ if (backcolor) {
13380
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13381
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13382
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
13383
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
13384
+ parameter.shadowBrush = new PdfBrush(color);
13385
+ }
13128
13386
  parameter.rotationAngle = item.rotate;
13129
13387
  var alignment = typeof item.textAlignment !== 'undefined' ? item.textAlignment : PdfTextAlignment.left;
13130
13388
  var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
@@ -13144,17 +13402,21 @@ var PdfComboBoxField = /** @__PURE__ @class */ (function (_super) {
13144
13402
  }
13145
13403
  }
13146
13404
  var backcolor = this.backColor;
13147
- parameter.backBrush = new PdfBrush(backcolor);
13405
+ if (backcolor) {
13406
+ parameter.backBrush = new PdfBrush(backcolor);
13407
+ }
13148
13408
  parameter.foreBrush = new PdfBrush(this.color);
13149
13409
  var border = this.border;
13150
13410
  parameter.borderPen = new PdfPen(this.borderColor, border.width);
13151
13411
  parameter.borderStyle = border.style;
13152
13412
  parameter.borderWidth = border.width;
13153
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13154
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13155
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
13156
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
13157
- parameter.shadowBrush = new PdfBrush(color);
13413
+ if (backcolor) {
13414
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13415
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13416
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
13417
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
13418
+ parameter.shadowBrush = new PdfBrush(color);
13419
+ }
13158
13420
  parameter.rotationAngle = this.rotationAngle;
13159
13421
  var alignment = typeof this.textAlignment !== 'undefined' ? this.textAlignment : PdfTextAlignment.left;
13160
13422
  var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
@@ -13492,17 +13754,21 @@ var PdfListBoxField = /** @__PURE__ @class */ (function (_super) {
13492
13754
  parameter.bounds = [0, 0, bounds.width, bounds.height];
13493
13755
  }
13494
13756
  var backcolor = item.backColor;
13495
- parameter.backBrush = new PdfBrush(backcolor);
13757
+ if (backcolor) {
13758
+ parameter.backBrush = new PdfBrush(backcolor);
13759
+ }
13496
13760
  parameter.foreBrush = new PdfBrush(item.color);
13497
13761
  var border = item.border;
13498
13762
  parameter.borderPen = new PdfPen(item.borderColor, border.width);
13499
13763
  parameter.borderStyle = border.style;
13500
13764
  parameter.borderWidth = border.width;
13501
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13502
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13503
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
13504
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
13505
- parameter.shadowBrush = new PdfBrush(color);
13765
+ if (backcolor) {
13766
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13767
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13768
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
13769
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
13770
+ parameter.shadowBrush = new PdfBrush(color);
13771
+ }
13506
13772
  parameter.rotationAngle = item.rotate;
13507
13773
  var alignment = typeof item.textAlignment !== 'undefined' ? item.textAlignment : PdfTextAlignment.left;
13508
13774
  var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
@@ -13520,17 +13786,21 @@ var PdfListBoxField = /** @__PURE__ @class */ (function (_super) {
13520
13786
  parameter.bounds = [0, 0, bounds.width, bounds.height];
13521
13787
  }
13522
13788
  var backcolor = this.backColor;
13523
- parameter.backBrush = new PdfBrush(backcolor);
13789
+ if (backcolor) {
13790
+ parameter.backBrush = new PdfBrush(backcolor);
13791
+ }
13524
13792
  parameter.foreBrush = new PdfBrush(this.color);
13525
13793
  var border = this.border;
13526
13794
  parameter.borderPen = new PdfPen(this.borderColor, border.width);
13527
13795
  parameter.borderStyle = border.style;
13528
13796
  parameter.borderWidth = border.width;
13529
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13530
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13531
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
13532
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
13533
- parameter.shadowBrush = new PdfBrush(color);
13797
+ if (backcolor) {
13798
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13799
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13800
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
13801
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
13802
+ parameter.shadowBrush = new PdfBrush(color);
13803
+ }
13534
13804
  parameter.rotationAngle = this.rotationAngle;
13535
13805
  var alignment = typeof this.textAlignment !== 'undefined' ? this.textAlignment : PdfTextAlignment.left;
13536
13806
  var verticalAlignment = this.multiSelect ? PdfVerticalAlignment.top : PdfVerticalAlignment.middle;
@@ -13743,6 +14013,54 @@ var PdfSignatureField = /** @__PURE__ @class */ (function (_super) {
13743
14013
  enumerable: true,
13744
14014
  configurable: true
13745
14015
  });
14016
+ Object.defineProperty(PdfSignatureField.prototype, "backColor", {
14017
+ /**
14018
+ * Gets the background color of the field.
14019
+ *
14020
+ * @returns {number[]} R, G, B color values in between 0 to 255.
14021
+ * ```typescript
14022
+ * // Load an existing PDF document
14023
+ * let document: PdfDocument = new PdfDocument(data, password);
14024
+ * // Access the form field at index 0
14025
+ * let field: PdfField = document.form.fieldAt(0);
14026
+ * // Gets the background color of the field.
14027
+ * let backColor: number[] = field.backColor;
14028
+ * // Save the document
14029
+ * document.save('output.pdf');
14030
+ * // Destroy the document
14031
+ * document.destroy();
14032
+ * ```
14033
+ */
14034
+ get: function () {
14035
+ return this._parseBackColor(true);
14036
+ },
14037
+ /**
14038
+ * Sets the background color of the field.
14039
+ *
14040
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
14041
+ * ```typescript
14042
+ * // Load an existing PDF document
14043
+ * let document: PdfDocument = new PdfDocument(data, password);
14044
+ * // Access the signature field at index 0
14045
+ * let field1: PdfField = document.form.fieldAt(0);
14046
+ * // Sets the background color of the field.
14047
+ * field1.backColor = [255, 0, 0];
14048
+ * // Access the signature field at index 1
14049
+ * let field2: PdfField = document.form.fieldAt(1);
14050
+ * // Sets the background color of the field to transparent.
14051
+ * field2.backColor = [0, 0, 0, 0];
14052
+ * // Save the document
14053
+ * document.save('output.pdf');
14054
+ * // Destroy the document
14055
+ * document.destroy();
14056
+ * ```
14057
+ */
14058
+ set: function (value) {
14059
+ this._updateBackColor(value, true);
14060
+ },
14061
+ enumerable: true,
14062
+ configurable: true
14063
+ });
13746
14064
  PdfSignatureField._load = function (form, dictionary, crossReference, reference) {
13747
14065
  var field = new PdfSignatureField();
13748
14066
  field._isLoaded = true;
@@ -13826,7 +14144,7 @@ var PdfSignatureField = /** @__PURE__ @class */ (function (_super) {
13826
14144
  var parameter = new _PaintParameter();
13827
14145
  parameter.bounds = [0, 0, bounds.width, bounds.height];
13828
14146
  var backcolor = widget.backColor;
13829
- if (isFlatten) {
14147
+ if (isFlatten && backcolor) {
13830
14148
  parameter.backBrush = new PdfBrush(backcolor);
13831
14149
  }
13832
14150
  parameter.foreBrush = new PdfBrush(widget.color);
@@ -13834,11 +14152,13 @@ var PdfSignatureField = /** @__PURE__ @class */ (function (_super) {
13834
14152
  parameter.borderPen = new PdfPen(widget.borderColor, border.width);
13835
14153
  parameter.borderStyle = border.style;
13836
14154
  parameter.borderWidth = border.width;
13837
- var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
13838
- var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
13839
- shadowColor[1] >= 0 ? shadowColor[1] : 0,
13840
- shadowColor[2] >= 0 ? shadowColor[2] : 0];
13841
- parameter.shadowBrush = new PdfBrush(color);
14155
+ if (backcolor) {
14156
+ var shadowColor = [backcolor[0] - 64, backcolor[1] - 64, backcolor[2] - 64];
14157
+ var color = [shadowColor[0] >= 0 ? shadowColor[0] : 0,
14158
+ shadowColor[1] >= 0 ? shadowColor[1] : 0,
14159
+ shadowColor[2] >= 0 ? shadowColor[2] : 0];
14160
+ parameter.shadowBrush = new PdfBrush(color);
14161
+ }
13842
14162
  parameter.rotationAngle = widget.rotate;
13843
14163
  graphics.save();
13844
14164
  graphics._initializeCoordinates();
@@ -24158,7 +24478,7 @@ var PdfSoundAnnotation = /** @__PURE__ @class */ (function (_super) {
24158
24478
  * // Get the first page
24159
24479
  * let page: PdfPage = document.getPage(0) as PdfPage;
24160
24480
  * // Create a new free text annotation
24161
- * const annotation: PdfFreeTextAnnotation = new PdfFreeTextAnnotation (50, 100, 100, 50);
24481
+ * const annotation: PdfFreeTextAnnotation = new PdfFreeTextAnnotation(50, 100, 100, 50);
24162
24482
  * // Add annotation to the page
24163
24483
  * page.annotations.add(annotation);
24164
24484
  * // Destroy the document
@@ -25973,6 +26293,7 @@ var PdfWidgetAnnotation = /** @__PURE__ @class */ (function (_super) {
25973
26293
  _this._isAutoResize = false;
25974
26294
  _this._visibility = PdfFormFieldVisibility.visible;
25975
26295
  _this._isFont = false;
26296
+ _this._isTransparentBackColor = false;
25976
26297
  _this._isWidget = true;
25977
26298
  _this._type = _PdfAnnotationType.widgetAnnotation;
25978
26299
  return _this;
@@ -26087,44 +26408,30 @@ var PdfWidgetAnnotation = /** @__PURE__ @class */ (function (_super) {
26087
26408
  * ```typescript
26088
26409
  * // Load an existing PDF document
26089
26410
  * let document: PdfDocument = new PdfDocument(data, password);
26090
- * // Get the first page
26091
- * let page: PdfPage = document.getPage(0) as PdfPage;
26092
- * // Get the first annotation of the page
26093
- * let annotation: PdfWidgetAnnotation = page.annotations.at(0) as PdfWidgetAnnotation;
26411
+ * // Access the text box field at index 0
26412
+ * let field: PdfField = document.form.fieldAt(0);
26094
26413
  * // Gets the back color of the annotation
26095
- * let backColor: number[] = annotation.backColor;
26414
+ * let backColor: number[] = field.itemAt(0).backColor;
26096
26415
  * // Destroy the document
26097
26416
  * document.destroy();
26098
26417
  * ```
26099
26418
  */
26100
26419
  get: function () {
26101
- if (typeof this._backColor === 'undefined') {
26102
- var dictionary = this._mkDictionary;
26103
- if (dictionary && dictionary.has('BG')) {
26104
- var colorArray = dictionary.getArray('BG');
26105
- if (colorArray) {
26106
- this._backColor = _parseColor(colorArray);
26107
- }
26108
- }
26109
- }
26110
- if (typeof this._backColor === 'undefined' || this._backColor === null) {
26111
- this._backColor = [255, 255, 255];
26112
- }
26113
- return this._backColor;
26420
+ return this._parseBackColor();
26114
26421
  },
26115
26422
  /**
26116
26423
  * Sets the back color of the annotation.
26117
26424
  *
26118
- * @param {number[]} value Color as R, G, B color array in between 0 to 255.
26425
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
26119
26426
  * ```typescript
26120
26427
  * // Load an existing PDF document
26121
26428
  * let document: PdfDocument = new PdfDocument(data, password);
26122
- * // Get the first page
26123
- * let page: PdfPage = document.getPage(0) as PdfPage;
26124
- * // Get the first annotation of the page
26125
- * let annotation: PdfWidgetAnnotation = page.annotations.at(0) as PdfWidgetAnnotation;
26126
- * // Sets the back color of the annotation.
26127
- * annotation.backColor = [255,255,255];
26429
+ * // Access the text box field at index 0
26430
+ * let field: PdfField = document.form.fieldAt(0);
26431
+ * // Sets the background color of the field item
26432
+ * field.itemAt(0).backColor = [255, 0, 0];
26433
+ * // Sets the background color of the field item to transparent
26434
+ * field.itemAt(1).backColor = [0, 0, 0, 0];
26128
26435
  * // Save the document
26129
26436
  * document.save('output.pdf');
26130
26437
  * // Destroy the document
@@ -26132,14 +26439,19 @@ var PdfWidgetAnnotation = /** @__PURE__ @class */ (function (_super) {
26132
26439
  * ```
26133
26440
  */
26134
26441
  set: function (value) {
26135
- if (typeof this.backColor === 'undefined' || this.backColor !== value) {
26136
- if (typeof this._mkDictionary === 'undefined') {
26137
- this._dictionary.update('MK', new _PdfDictionary(this._crossReference));
26138
- }
26139
- this._mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
26140
- Number.parseFloat((value[1] / 255).toFixed(3)),
26141
- Number.parseFloat((value[2] / 255).toFixed(3))]);
26142
- this._backColor = value;
26442
+ this._updateBackColor(value);
26443
+ },
26444
+ enumerable: true,
26445
+ configurable: true
26446
+ });
26447
+ Object.defineProperty(PdfWidgetAnnotation.prototype, "_hasBackColor", {
26448
+ get: function () {
26449
+ if (this._isLoaded) {
26450
+ var mkDictionary = this._mkDictionary;
26451
+ return (mkDictionary && mkDictionary.has('BG'));
26452
+ }
26453
+ else {
26454
+ return !this._isTransparentBackColor;
26143
26455
  }
26144
26456
  },
26145
26457
  enumerable: true,
@@ -26816,6 +27128,59 @@ var PdfWidgetAnnotation = /** @__PURE__ @class */ (function (_super) {
26816
27128
  this._dictionary.update('Rect', _getUpdatedBounds([value.x, value.y, value.width, value.height], this._page));
26817
27129
  }
26818
27130
  };
27131
+ PdfWidgetAnnotation.prototype._parseBackColor = function () {
27132
+ var value;
27133
+ if ((this._isLoaded && this._hasBackColor) || (!this._isLoaded && !this._isTransparentBackColor)) {
27134
+ if (typeof this._backColor === 'undefined') {
27135
+ var dictionary = this._mkDictionary;
27136
+ if (dictionary && dictionary.has('BG')) {
27137
+ var colorArray = dictionary.getArray('BG');
27138
+ if (colorArray) {
27139
+ this._backColor = _parseColor(colorArray);
27140
+ }
27141
+ }
27142
+ }
27143
+ if (typeof this._backColor === 'undefined' || this._backColor === null) {
27144
+ this._backColor = [255, 255, 255];
27145
+ }
27146
+ value = this._backColor;
27147
+ }
27148
+ return value;
27149
+ };
27150
+ PdfWidgetAnnotation.prototype._updateBackColor = function (value, setAppearance) {
27151
+ if (setAppearance === void 0) { setAppearance = false; }
27152
+ var isChanged = false;
27153
+ if (value.length === 4 && value[3] !== 255) {
27154
+ this._isTransparentBackColor = true;
27155
+ if (this._dictionary.has('BG')) {
27156
+ delete this._dictionary._map.BG;
27157
+ isChanged = true;
27158
+ }
27159
+ var mkDictionary = this._mkDictionary;
27160
+ if (mkDictionary && mkDictionary.has('BG')) {
27161
+ delete mkDictionary._map.BG;
27162
+ this._dictionary._updated = true;
27163
+ isChanged = true;
27164
+ }
27165
+ }
27166
+ else {
27167
+ this._isTransparentBackColor = false;
27168
+ if (typeof this.backColor === 'undefined' || this._backColor !== value) {
27169
+ if (typeof this._mkDictionary === 'undefined') {
27170
+ this._dictionary.update('MK', new _PdfDictionary(this._crossReference));
27171
+ }
27172
+ this._mkDictionary.update('BG', [Number.parseFloat((value[0] / 255).toFixed(3)),
27173
+ Number.parseFloat((value[1] / 255).toFixed(3)),
27174
+ Number.parseFloat((value[2] / 255).toFixed(3))]);
27175
+ this._backColor = [value[0], value[1], value[2]];
27176
+ this._dictionary._updated = true;
27177
+ isChanged = true;
27178
+ }
27179
+ }
27180
+ if (setAppearance && isChanged && this._field) {
27181
+ this._field._setAppearance = true;
27182
+ }
27183
+ };
26819
27184
  return PdfWidgetAnnotation;
26820
27185
  }(PdfAnnotation));
26821
27186
  /**
@@ -27167,6 +27532,56 @@ var PdfRadioButtonListItem = /** @__PURE__ @class */ (function (_super) {
27167
27532
  enumerable: true,
27168
27533
  configurable: true
27169
27534
  });
27535
+ Object.defineProperty(PdfRadioButtonListItem.prototype, "backColor", {
27536
+ /**
27537
+ * Gets the back color of the annotation.
27538
+ *
27539
+ * @returns {number[]} Color as R, G, B color array in between 0 to 255.
27540
+ * ```typescript
27541
+ * // Load an existing PDF document
27542
+ * let document: PdfDocument = new PdfDocument(data, password);
27543
+ * // Get the first page
27544
+ * let page: PdfPage = document.getPage(0) as PdfPage;
27545
+ * // Get the first annotation of the page
27546
+ * let annotation: PdfWidgetAnnotation = page.annotations.at(0) as PdfWidgetAnnotation;
27547
+ * // Gets the back color of the annotation
27548
+ * let backColor: number[] = annotation.backColor;
27549
+ * // Destroy the document
27550
+ * document.destroy();
27551
+ * ```
27552
+ */
27553
+ get: function () {
27554
+ return this._parseBackColor();
27555
+ },
27556
+ /**
27557
+ * Sets the back color of the annotation.
27558
+ *
27559
+ * @param {number[]} value Array with R, G, B, A color values in between 0 to 255. For optional A (0-254), it signifies transparency.
27560
+ * ```typescript
27561
+ * // Load an existing PDF document
27562
+ * let document: PdfDocument = new PdfDocument(data);
27563
+ * // Gets the first page of the document
27564
+ * let page: PdfPage = document.getPage(0);
27565
+ * // Access the PDF form
27566
+ * let form: PdfForm = document.form;
27567
+ * // Access the radio button list field
27568
+ * let field: PdfRadioButtonListField = form.fieldAt(0) as PdfRadioButtonListField;
27569
+ * // Sets the back color of the radio button list item
27570
+ * field.itemAt(0).backColor = [255, 255, 255];
27571
+ * // Sets the background color of the field item to transparent
27572
+ * field.itemAt(1).backColor = [0, 0, 0, 0];
27573
+ * // Save the document
27574
+ * document.save('output.pdf');
27575
+ * // Destroy the document
27576
+ * document.destroy();
27577
+ * ```
27578
+ */
27579
+ set: function (value) {
27580
+ this._updateBackColor(value, true);
27581
+ },
27582
+ enumerable: true,
27583
+ configurable: true
27584
+ });
27170
27585
  PdfRadioButtonListItem.prototype._initializeItem = function (value, bounds, page, field) {
27171
27586
  this._optionValue = value;
27172
27587
  this._page = page;