@syncfusion/ej2-pdf 25.1.38 → 25.1.40

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 25.1.38
3
+ * version : 25.1.40
4
4
  * Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "@syncfusion/ej2-pdf@*",
3
- "_id": "@syncfusion/ej2-pdf@25.1.35",
3
+ "_id": "@syncfusion/ej2-pdf@25.1.39",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-iBGhkTWsEumkoXouPSj9/1bChb4oyYYnNtgj/vx6+oCHzKHwfJ4hWivcSghHRklm5bMfRtjKzkIT69U0W9k6nw==",
5
+ "_integrity": "sha512-pWE0zlFyKavaIdUTvXidwDuQ3V8v58EB5Vgp+sqfyF+XyBoes9xjzKAsS7lKfnjJ+69lmjP6+cc6hnXfp5lsxg==",
6
6
  "_location": "/@syncfusion/ej2-pdf",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -21,8 +21,8 @@
21
21
  "/@syncfusion/ej2",
22
22
  "/@syncfusion/ej2-pdfviewer"
23
23
  ],
24
- "_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-25.1.35.tgz",
25
- "_shasum": "569d9e8c30a75a1f8403aecab1ac5626a9b1ef40",
24
+ "_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-25.1.39.tgz",
25
+ "_shasum": "5a2d3f5d6c5b9c74f92db621290da632cc3682c0",
26
26
  "_spec": "@syncfusion/ej2-pdf@*",
27
27
  "_where": "/jenkins/workspace/elease-automation_release_25.1.1/packages/included",
28
28
  "author": {
@@ -55,7 +55,7 @@
55
55
  "url": "https://github.com/syncfusion/ej2-javascript-ui-controls/tree/master/controls/pdf"
56
56
  },
57
57
  "typings": "index.d.ts",
58
- "version": "25.1.38",
58
+ "version": "25.1.40",
59
59
  "sideEffects": false,
60
60
  "homepage": "https://www.syncfusion.com/javascript-ui-controls"
61
61
  }
@@ -8136,33 +8136,53 @@ var PdfDocumentLinkAnnotation = /** @class */ (function (_super) {
8136
8136
  }
8137
8137
  if (holder) {
8138
8138
  var index = _getPageIndex(this._crossReference._document, this._crossReference._fetch(holder));
8139
- var page = this._crossReference._document.getPage(index);
8140
- if (array[1] instanceof _PdfName) {
8141
- var mode = array[1];
8142
- if (mode) {
8143
- if (mode.name === 'XYZ') {
8144
- var left = array[2];
8145
- var top_4 = array[3];
8146
- var zoom = array[4];
8147
- var topValue = (typeof top_4 !== 'undefined' && top_4 !== null) ? (page.size[1] - top_4) : 0;
8148
- var leftValue = (typeof left !== 'undefined' && left !== null) ? left : 0;
8149
- this._destination = new PdfDestination(page, [leftValue, topValue]);
8150
- if (typeof zoom !== 'undefined' && zoom !== null) {
8151
- this._destination.zoom = zoom;
8152
- }
8153
- if ((typeof left === 'undefined' && left === null) || (typeof top_4 === 'undefined' && top_4 === null)
8154
- || (typeof zoom === 'undefined' && zoom === null)) {
8155
- this._destination._setValidation(false);
8139
+ if (index >= 0) {
8140
+ var page = this._crossReference._document.getPage(index);
8141
+ if (page && array[1] instanceof _PdfName) {
8142
+ var mode = array[1];
8143
+ if (mode) {
8144
+ if (mode.name === 'XYZ') {
8145
+ var left = array[2];
8146
+ var top_4 = array[3];
8147
+ var zoom = array[4];
8148
+ var topValue = (typeof top_4 !== 'undefined' && top_4 !== null) ? (page.size[1] - top_4) : 0;
8149
+ var leftValue = (typeof left !== 'undefined' && left !== null) ? left : 0;
8150
+ this._destination = new PdfDestination(page, [leftValue, topValue]);
8151
+ if (typeof zoom !== 'undefined' && zoom !== null) {
8152
+ this._destination.zoom = zoom;
8153
+ }
8154
+ if ((typeof left === 'undefined' && left === null) || (typeof top_4 === 'undefined' && top_4 === null)
8155
+ || (typeof zoom === 'undefined' && zoom === null)) {
8156
+ this._destination._setValidation(false);
8157
+ }
8156
8158
  }
8157
- }
8158
- else {
8159
- if (page && mode.name === 'Fit') {
8159
+ else if (mode.name === 'Fit') {
8160
8160
  this._destination = new PdfDestination(page);
8161
8161
  this._destination.mode = PdfDestinationMode.fitToPage;
8162
8162
  }
8163
8163
  }
8164
8164
  }
8165
8165
  }
8166
+ else {
8167
+ this._destination = new PdfDestination();
8168
+ var zoom = array[4];
8169
+ var mode = array[1];
8170
+ if (typeof zoom !== 'undefined' && zoom !== null) {
8171
+ this._destination.zoom = zoom;
8172
+ }
8173
+ if (mode.name === 'Fit') {
8174
+ this._destination.mode = PdfDestinationMode.fitToPage;
8175
+ }
8176
+ else if (mode.name === 'XYZ') {
8177
+ var left = array[2];
8178
+ var topValue = array[3];
8179
+ if ((typeof left === 'undefined' && left === null) || (typeof topValue === 'undefined' && topValue === null)
8180
+ || (typeof zoom === 'undefined' && zoom === null)) {
8181
+ this._destination._setValidation(false);
8182
+ }
8183
+ }
8184
+ this._destination._index = index;
8185
+ }
8166
8186
  }
8167
8187
  }
8168
8188
  else if (this._dictionary.has('A') && !this._destination) {
@@ -9687,6 +9707,7 @@ var PdfRubberStampAnnotation = /** @class */ (function (_super) {
9687
9707
  }
9688
9708
  else if (bounds) {
9689
9709
  templateDictionary.update('Matrix', [1, 0, 0, 1, -bounds[0], -bounds[1]]);
9710
+ template._size = [bounds[2], bounds[3]];
9690
9711
  }
9691
9712
  template._exportStream(dictionary, this._crossReference);
9692
9713
  }
@@ -3101,8 +3101,7 @@ var PdfTextBoxField = /** @class */ (function (_super) {
3101
3101
  }
3102
3102
  }
3103
3103
  parameter.bounds[2] = width;
3104
- format.alignment = PdfTextAlignment.center;
3105
- this._drawTextBox(g, parameter, text, font, format, multiline, scroll);
3104
+ this._drawTextBox(g, parameter, text, font, new PdfStringFormat(PdfTextAlignment.center), multiline, scroll);
3106
3105
  parameter.bounds[0] = parameter.bounds[0] + width;
3107
3106
  if (parameter.borderWidth) {
3108
3107
  g.drawLine(parameter.borderPen, parameter.bounds[0], parameter.bounds[1], parameter.bounds[0], parameter.bounds[1] + parameter.bounds[3]);
@@ -239,7 +239,6 @@ var PdfForm = /** @class */ (function () {
239
239
  this._dictionary.update('Fields', this._fields);
240
240
  this._parsedFields.set(this._fields.length - 1, field);
241
241
  field._form = this;
242
- this._crossReference._allowCatalog = true;
243
242
  this._crossReference._root._updated = true;
244
243
  if (field._kidsCount > 0) {
245
244
  for (var i = 0; i < field._kidsCount; i++) {
@@ -60,6 +60,8 @@ var _PdfCatalog = /** @class */ (function () {
60
60
  this._crossReference._cacheMap.set(ref, form);
61
61
  this._catalogDictionary.set('AcroForm', ref);
62
62
  this._catalogDictionary._updated = true;
63
+ this._crossReference._allowCatalog = true;
64
+ form._updated = true;
63
65
  return form;
64
66
  };
65
67
  _PdfCatalog.prototype.getPageDictionary = function (pageIndex) {
@@ -1,6 +1,6 @@
1
1
  import { _PdfStream } from './base-stream';
2
2
  import { _PdfDictionary, _PdfReferenceSet, _isCommand, _PdfReference, _PdfName } from './pdf-primitives';
3
- import { BaseException, FormatError, _escapePdfName, _bytesToString, ParserEndOfFileException, _numberToString, _stringToPdfString } from './utils';
3
+ import { BaseException, FormatError, _escapePdfName, _bytesToString, ParserEndOfFileException, _numberToString, _stringToPdfString, _getSize } from './utils';
4
4
  import { _PdfParser, _PdfLexicalOperator } from './pdf-parser';
5
5
  import { _PdfBaseStream } from './base-stream';
6
6
  import { PdfCrossReferenceType } from './enumerator';
@@ -742,39 +742,40 @@ var _PdfCrossReference = /** @class */ (function () {
742
742
  }
743
743
  this._writeObject(archiveStream, buffer, archiveRef, cipher_2);
744
744
  }
745
+ var formatValue = Math.max(_getSize(this._stream.bytes.length), _getSize(this._nextReferenceNumber));
745
746
  var newRef = this._getNextReference();
746
747
  var newStartXref = currentLength + buffer.length;
747
748
  var newXref = new _PdfDictionary(this);
748
749
  newXref.set('Type', _PdfName.get('XRef'));
749
750
  newXref.set('Index', indexes_1);
750
- newXref.set('W', [1, 3, 1]);
751
+ newXref.set('W', [1, formatValue, 1]);
751
752
  this._copyTrailer(newXref);
752
753
  if (this._ids && this._ids.length > 0) {
753
754
  newXref.update('ID', [this._ids[0], this._computeMessageDigest(newStartXref)]);
754
755
  }
755
756
  var newXrefData = [];
756
757
  this._writeLong(0, 1, newXrefData);
757
- this._writeLong(1, 3, newXrefData);
758
+ this._writeLong(1, formatValue, newXrefData);
758
759
  this._writeLong(-1, 1, newXrefData);
759
760
  if (uncompressedCount > 0) {
760
761
  for (var index = 0; index < uncompressedCount; index++) {
761
762
  this._writeLong(1, 1, newXrefData);
762
- this._writeLong(uncompressedOffsets_1[index], 3, newXrefData); // eslint-disable-line
763
+ this._writeLong(uncompressedOffsets_1[index], formatValue, newXrefData); // eslint-disable-line
763
764
  this._writeLong(0, 1, newXrefData);
764
765
  }
765
766
  }
766
767
  if (updatedCount > 0) {
767
768
  for (var index = 0; index < updatedCount; index++) {
768
769
  this._writeLong(2, 1, newXrefData);
769
- this._writeLong(archiveRef.objectNumber, 3, newXrefData);
770
+ this._writeLong(archiveRef.objectNumber, formatValue, newXrefData);
770
771
  this._writeLong(index, 1, newXrefData);
771
772
  }
772
773
  this._writeLong(1, 1, newXrefData);
773
- this._writeLong(archiveOffset, 3, newXrefData);
774
+ this._writeLong(archiveOffset, formatValue, newXrefData);
774
775
  this._writeLong(0, 1, newXrefData);
775
776
  }
776
777
  this._writeLong(1, 1, newXrefData);
777
- this._writeLong(newStartXref, 3, newXrefData);
778
+ this._writeLong(newStartXref, formatValue, newXrefData);
778
779
  this._writeLong(0, 1, newXrefData);
779
780
  newXref.set('Length', newXrefData.length);
780
781
  var newXrefStream = new _PdfStream(newXrefData, newXref, 0, newXrefData.length);
@@ -826,8 +827,9 @@ var _PdfCrossReference = /** @class */ (function () {
826
827
  return array;
827
828
  };
828
829
  _PdfCrossReference.prototype._copyTrailer = function (newXref) {
829
- newXref.set('Size', this._nextReferenceNumber);
830
- this._document._isEncrypted ? newXref.set('Prev', this._prevXRefOffset) : newXref.set('Prev', this._prevStartXref);
830
+ var reference = this._getNextReference();
831
+ newXref.set('Size', reference.objectNumber);
832
+ newXref.set('Prev', this._prevXRefOffset);
831
833
  var root = this._trailer.getRaw('Root'); // eslint-disable-line
832
834
  if (typeof root !== 'undefined' && root !== null) {
833
835
  newXref.set('Root', root);
@@ -1110,19 +1110,21 @@ var PdfDocument = /** @class */ (function () {
1110
1110
  };
1111
1111
  PdfDocument.prototype._doPostProcessOnFormFields = function (isFlatten) {
1112
1112
  if (isFlatten === void 0) { isFlatten = false; }
1113
- this.form._doPostProcess(isFlatten);
1114
- if (isFlatten) {
1115
- var formObject = this._catalog._catalogDictionary.getRaw('AcroForm');
1116
- var dictionary = new _PdfDictionary(this._crossReference);
1117
- dictionary._updated = true;
1118
- if (formObject instanceof _PdfReference) {
1119
- this._crossReference._cacheMap.set(formObject, dictionary);
1120
- }
1121
- else {
1122
- this.form._dictionary = dictionary;
1123
- this._crossReference._allowCatalog = true;
1113
+ if (this._catalog._catalogDictionary.has('AcroForm')) {
1114
+ this.form._doPostProcess(isFlatten);
1115
+ if (isFlatten) {
1116
+ var formObject = this._catalog._catalogDictionary.getRaw('AcroForm');
1117
+ var dictionary = new _PdfDictionary(this._crossReference);
1118
+ dictionary._updated = true;
1119
+ if (formObject instanceof _PdfReference) {
1120
+ this._crossReference._cacheMap.set(formObject, dictionary);
1121
+ }
1122
+ else {
1123
+ this.form._dictionary = dictionary;
1124
+ this._crossReference._allowCatalog = true;
1125
+ }
1126
+ this.form._clear();
1124
1127
  }
1125
- this.form._clear();
1126
1128
  }
1127
1129
  };
1128
1130
  PdfDocument.prototype._doPostProcessOnAnnotations = function (isFlatten) {
@@ -59,7 +59,10 @@ var PdfPage = /** @class */ (function () {
59
59
  if (this._pageDictionary.has('Annots')) {
60
60
  var annots = this._getProperty('Annots');
61
61
  if (annots && Array.isArray(annots)) {
62
- var widgets_1 = this._crossReference._document.form._parseWidgetReferences();
62
+ var widgets_1;
63
+ if (this._crossReference._document._catalog._catalogDictionary.has('AcroForm')) {
64
+ widgets_1 = this._crossReference._document.form._parseWidgetReferences();
65
+ }
63
66
  if (widgets_1 && widgets_1.length > 0) {
64
67
  var validAnnotations_1 = [];
65
68
  annots.forEach(function (entry) {
@@ -1,5 +1,5 @@
1
1
  import { _PdfCommand, _PdfName, _PdfDictionary, _isCommand, _PdfReference, _isName } from './pdf-primitives';
2
- import { _isWhiteSpace, _stringToBytes, FormatError, ParserEndOfFileException } from './utils';
2
+ import { _isWhiteSpace, FormatError, ParserEndOfFileException, _decodeText } from './utils';
3
3
  import { _PdfNullStream } from './base-stream';
4
4
  import { PdfPredictorStream } from './predictor-stream';
5
5
  import { _PdfFlateStream } from './flate-stream';
@@ -500,6 +500,7 @@ var _PdfParser = /** @class */ (function () {
500
500
  if (array.length === 0 && _isName(entry, 'Indexed')) {
501
501
  this._isColorSpace = true;
502
502
  }
503
+ entry = _decodeText(entry, this._isColorSpace, this._isPassword);
503
504
  array.push(entry);
504
505
  }
505
506
  if (this.first === endOfFile) {
@@ -528,23 +529,7 @@ var _PdfParser = /** @class */ (function () {
528
529
  break;
529
530
  }
530
531
  var value = this.getObject(cipherTransform); // eslint-disable-line
531
- if (value && typeof value === 'string' && !this._isColorSpace && !this._isPassword) {
532
- if (value.startsWith('þÿ')) {
533
- value = value.substring(2);
534
- if (value.endsWith('ÿý')) {
535
- value = value.substring(0, value.length - 2);
536
- }
537
- var bytes = _stringToBytes(value);
538
- var result = '';
539
- for (var i = 0; i < bytes.length; i += 2) {
540
- var x = bytes[Number.parseInt(i.toString(), 10)] << 8;
541
- var y = bytes[Number.parseInt((i + 1).toString(), 10)];
542
- var codeUnit = x | y;
543
- result += String.fromCharCode(codeUnit);
544
- }
545
- value = result;
546
- }
547
- }
532
+ value = _decodeText(value, this._isColorSpace, this._isPassword);
548
533
  this._isPassword = false;
549
534
  dictionary.set(key, value);
550
535
  }
@@ -749,3 +749,19 @@ export declare function _obtainDestination(dictionary: _PdfDictionary, key: stri
749
749
  * @returns {number[]} bounds.
750
750
  */
751
751
  export declare function _updateBounds(annotation: PdfAnnotation, bounds?: number[]): number[];
752
+ /**
753
+ * Decode text.
754
+ *
755
+ * @param {string} text Text to decode.
756
+ * @param {boolean} isColorSpace Color space or not
757
+ * @param {boolean} isPassword Password or not
758
+ * @returns {string} Decoded text.
759
+ */
760
+ export declare function _decodeText(text: string, isColorSpace: boolean, isPassword: boolean): string;
761
+ /**
762
+ * Number of bytes required to save the number.
763
+ *
764
+ * @param {number} input number.
765
+ * @returns {number} number of bytes.
766
+ */
767
+ export declare function _getSize(input: number): number;
@@ -3929,3 +3929,65 @@ export function _updateBounds(annotation, bounds) {
3929
3929
  }
3930
3930
  return rect;
3931
3931
  }
3932
+ /**
3933
+ * Decode text.
3934
+ *
3935
+ * @param {string} text Text to decode.
3936
+ * @param {boolean} isColorSpace Color space or not
3937
+ * @param {boolean} isPassword Password or not
3938
+ * @returns {string} Decoded text.
3939
+ */
3940
+ export function _decodeText(text, isColorSpace, isPassword) {
3941
+ if (text && typeof text === 'string' && !isColorSpace && !isPassword) {
3942
+ if (text.startsWith('þÿ')) {
3943
+ text = text.substring(2);
3944
+ if (text.endsWith('ÿý')) {
3945
+ text = text.substring(0, text.length - 2);
3946
+ }
3947
+ var bytes = _stringToBytes(text);
3948
+ var result = '';
3949
+ for (var i = 0; i < bytes.length; i += 2) {
3950
+ var x = bytes[Number.parseInt(i.toString(), 10)] << 8;
3951
+ var y = bytes[Number.parseInt((i + 1).toString(), 10)];
3952
+ var codeUnit = x | y;
3953
+ result += String.fromCharCode(codeUnit);
3954
+ }
3955
+ text = result;
3956
+ }
3957
+ }
3958
+ return text;
3959
+ }
3960
+ /**
3961
+ * Number of bytes required to save the number.
3962
+ *
3963
+ * @param {number} input number.
3964
+ * @returns {number} number of bytes.
3965
+ */
3966
+ export function _getSize(input) {
3967
+ var size = 0;
3968
+ var uintMaxValue = 0xFFFFFFFF;
3969
+ var ushortMaxValue = 0xFFFF;
3970
+ var byteMaxValue = 0xFF;
3971
+ if (input <= uintMaxValue) {
3972
+ if (input <= ushortMaxValue) {
3973
+ if (input <= byteMaxValue) {
3974
+ size = 1;
3975
+ }
3976
+ else {
3977
+ size = 2;
3978
+ }
3979
+ }
3980
+ else {
3981
+ if (input <= (ushortMaxValue | (ushortMaxValue << 8))) {
3982
+ size = 3;
3983
+ }
3984
+ else {
3985
+ size = 4;
3986
+ }
3987
+ }
3988
+ }
3989
+ else {
3990
+ size = 8;
3991
+ }
3992
+ return size;
3993
+ }