@syncfusion/ej2-pdf 23.1.36 → 23.1.38
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 +11 -0
- package/dist/ej2-pdf.umd.min.js +3 -3
- package/dist/ej2-pdf.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf.es2015.js +156 -29
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +156 -30
- package/dist/es6/ej2-pdf.es5.js.map +1 -1
- package/dist/global/ej2-pdf.min.js +3 -3
- package/dist/global/ej2-pdf.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +6 -6
- package/src/pdf/core/annotations/annotation-collection.js +12 -1
- package/src/pdf/core/annotations/annotation.d.ts +21 -1
- package/src/pdf/core/annotations/annotation.js +23 -23
- package/src/pdf/core/graphics/images/image-decoder.d.ts +7 -0
- package/src/pdf/core/graphics/images/image-decoder.js +98 -1
- package/src/pdf/core/import-export/xfdf-document.js +1 -1
- package/src/pdf/core/import-export/xml-document.js +3 -3
- package/src/pdf/core/pdf-cross-reference.js +1 -1
- package/src/pdf/core/utils.d.ts +9 -1
- package/src/pdf/core/utils.js +18 -0
package/dist/global/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version : 23.1.
|
|
4
|
-
* Copyright Syncfusion Inc. 2001 -
|
|
3
|
+
* version : 23.1.38
|
|
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
|
|
7
7
|
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_from": "@syncfusion/ej2-pdf@*",
|
|
3
|
-
"_id": "@syncfusion/ej2-pdf@
|
|
3
|
+
"_id": "@syncfusion/ej2-pdf@23.1.36",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-UxecW8YkOzEjWhPgZkAUw8nzEM9h+f7FgHWcrp4hWkhT+4+2nAlGwVuZFBfNQlQnFmP48qIoefBjCzYdKAKOXA==",
|
|
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.syncfusion.com/repository/ej2-
|
|
25
|
-
"_shasum": "
|
|
24
|
+
"_resolved": "https://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-23.1.36.tgz",
|
|
25
|
+
"_shasum": "c692c77b2b0ef1c720b95c073508daaa6e63a2c2",
|
|
26
26
|
"_spec": "@syncfusion/ej2-pdf@*",
|
|
27
27
|
"_where": "/jenkins/workspace/elease-automation_release_23.1.1/packages/included",
|
|
28
28
|
"author": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"bundleDependencies": false,
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@syncfusion/ej2-base": "~23.1.
|
|
33
|
+
"@syncfusion/ej2-base": "~23.1.38",
|
|
34
34
|
"@syncfusion/ej2-compression": "~23.1.36"
|
|
35
35
|
},
|
|
36
36
|
"deprecated": false,
|
|
@@ -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": "23.1.
|
|
58
|
+
"version": "23.1.38",
|
|
59
59
|
"sideEffects": false,
|
|
60
60
|
"homepage": "https://www.syncfusion.com/javascript-ui-controls"
|
|
61
61
|
}
|
|
@@ -131,7 +131,18 @@ var PdfAnnotationCollection = /** @class */ (function () {
|
|
|
131
131
|
var index = this._annotations.length;
|
|
132
132
|
this._annotations.push(reference);
|
|
133
133
|
this._parsedAnnotations.set(index, annotation);
|
|
134
|
-
|
|
134
|
+
var isAdded = false;
|
|
135
|
+
if (this._page._pageDictionary.has('Annots')) {
|
|
136
|
+
var collection = this._page._pageDictionary.get('Annots');
|
|
137
|
+
if (collection !== null && typeof collection !== 'undefined' && collection.indexOf(reference) === -1) {
|
|
138
|
+
collection.push(reference);
|
|
139
|
+
this._page._pageDictionary.set('Annots', collection);
|
|
140
|
+
isAdded = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!isAdded) {
|
|
144
|
+
this._page._pageDictionary.set('Annots', this._annotations);
|
|
145
|
+
}
|
|
135
146
|
this._page._pageDictionary._updated = true;
|
|
136
147
|
if (annotation instanceof PdfComment) {
|
|
137
148
|
this._addCommentsAndReview(annotation, annotation._dictionary.get('F'));
|
|
@@ -2096,6 +2096,7 @@ export declare class PdfInkAnnotation extends PdfComment {
|
|
|
2096
2096
|
private _inkPointsCollection;
|
|
2097
2097
|
private _previousCollection;
|
|
2098
2098
|
private _isFlatten;
|
|
2099
|
+
_isModified: boolean;
|
|
2099
2100
|
/**
|
|
2100
2101
|
* Initializes a new instance of the `PdfInkAnnotation` class.
|
|
2101
2102
|
*
|
|
@@ -2203,7 +2204,26 @@ export declare class PdfPopupAnnotation extends PdfComment {
|
|
|
2203
2204
|
/**
|
|
2204
2205
|
* Initializes a new instance of the `PdfPopupAnnotation` class.
|
|
2205
2206
|
*
|
|
2206
|
-
*
|
|
2207
|
+
* ```typescript
|
|
2208
|
+
* // Load an existing PDF document
|
|
2209
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
2210
|
+
* // Get the first page
|
|
2211
|
+
* let page: PdfPage = document.getPage(0) as PdfPage;
|
|
2212
|
+
* // Create a new line annotation
|
|
2213
|
+
* let lineAnnotation: PdfLineAnnotation = new PdfLineAnnotation([10, 50, 250, 50]);
|
|
2214
|
+
* // Create a new popup annotation
|
|
2215
|
+
* let popup: PdfPopupAnnotation = new PdfPopupAnnotation();
|
|
2216
|
+
* // Set the author name
|
|
2217
|
+
* popup.author = 'Syncfusion';
|
|
2218
|
+
* // Set the text
|
|
2219
|
+
* popup.text = 'This is first comment';
|
|
2220
|
+
* // Add comments to the annotation
|
|
2221
|
+
* lineAnnotation.comments.add(popup);
|
|
2222
|
+
* // Add annotation to the page
|
|
2223
|
+
* page.annotations.add(lineAnnotation);
|
|
2224
|
+
* // Destroy the document
|
|
2225
|
+
* document.destroy();
|
|
2226
|
+
* ```
|
|
2207
2227
|
*/
|
|
2208
2228
|
constructor();
|
|
2209
2229
|
/**
|
|
@@ -14,7 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
import { PdfDestination } from './../pdf-page';
|
|
15
15
|
import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
|
|
16
16
|
import { PdfFormFieldVisibility, _PdfCheckFieldState, PdfAnnotationFlag, PdfBorderStyle, PdfLineCaptionType, PdfLineEndingStyle, PdfLineIntent, PdfRotationAngle, PdfTextAlignment, PdfBorderEffectStyle, PdfMeasurementUnit, _PdfGraphicsUnit, PdfCircleMeasurementType, PdfRubberStampAnnotationIcon, PdfCheckBoxStyle, PdfTextMarkupAnnotationType, PdfPopupIcon, PdfAnnotationState, PdfAnnotationStateModel, PdfAttachmentIcon, PdfAnnotationIntent, _PdfAnnotationType, PdfDestinationMode, PdfBlendMode, PdfDashStyle, PdfLineCap } from './../enumerator';
|
|
17
|
-
import { _checkField, _removeDuplicateReference, _updateVisibility, _getPageIndex, _checkComment, _checkReview, _mapAnnotationStateModel, _mapAnnotationState, _decode, _setMatrix, _convertToColor, _findPage, _getItemValue, _areNotEqual, _calculateBounds, _parseColor, _mapHighlightMode, _reverseMapHighlightMode, _getUpdatedBounds, _mapBorderStyle, _mapLineEndingStyle, _reverseMapEndingStyle, _toRectangle, _mapBorderEffectStyle, _getStateTemplate, _mapMeasurementUnit, _mapGraphicsUnit, _stringToStyle, _styleToString, _mapMarkupAnnotationType, _reverseMarkupAnnotationType, _reverseMapAnnotationState, _reverseMapAnnotationStateModel, _mapPopupIcon, _mapRubberStampIcon, _mapAttachmentIcon, _mapAnnotationIntent, _reverseMapPdfFontStyle, _fromRectangle, _getNewGuidString, _getFontStyle, _mapFont } from './../utils';
|
|
17
|
+
import { _checkField, _removeDuplicateReference, _updateVisibility, _getPageIndex, _checkComment, _checkReview, _mapAnnotationStateModel, _mapAnnotationState, _decode, _setMatrix, _convertToColor, _findPage, _getItemValue, _areNotEqual, _calculateBounds, _parseColor, _mapHighlightMode, _reverseMapHighlightMode, _getUpdatedBounds, _mapBorderStyle, _mapLineEndingStyle, _reverseMapEndingStyle, _toRectangle, _mapBorderEffectStyle, _getStateTemplate, _mapMeasurementUnit, _mapGraphicsUnit, _stringToStyle, _styleToString, _mapMarkupAnnotationType, _reverseMarkupAnnotationType, _reverseMapAnnotationState, _reverseMapAnnotationStateModel, _mapPopupIcon, _mapRubberStampIcon, _mapAttachmentIcon, _mapAnnotationIntent, _reverseMapPdfFontStyle, _fromRectangle, _getNewGuidString, _getFontStyle, _mapFont, _checkInkPoints } from './../utils';
|
|
18
18
|
import { PdfField, _PdfDefaultAppearance, PdfListBoxField, PdfComboBoxField } from './../form/field';
|
|
19
19
|
import { PdfTemplate } from './../graphics/pdf-template';
|
|
20
20
|
import { _TextRenderingMode, PdfBrush, PdfPen, _PdfTransformationMatrix, _PdfUnitConvertor } from './../graphics/pdf-graphics';
|
|
@@ -926,6 +926,9 @@ var PdfAnnotation = /** @class */ (function () {
|
|
|
926
926
|
if (typeof this._rotate === 'undefined' && this._dictionary.has('Rotate')) {
|
|
927
927
|
this._rotate = (this._dictionary.get('Rotate') / 90);
|
|
928
928
|
}
|
|
929
|
+
if (this._rotate === null || typeof this._rotate === 'undefined') {
|
|
930
|
+
this._rotate = PdfRotationAngle.angle0;
|
|
931
|
+
}
|
|
929
932
|
return this._rotate;
|
|
930
933
|
},
|
|
931
934
|
/**
|
|
@@ -6551,6 +6554,7 @@ var PdfInkAnnotation = /** @class */ (function (_super) {
|
|
|
6551
6554
|
var _this = _super.call(this) || this;
|
|
6552
6555
|
_this._inkPointsCollection = [];
|
|
6553
6556
|
_this._previousCollection = [];
|
|
6557
|
+
_this._isModified = false;
|
|
6554
6558
|
_this._dictionary = new _PdfDictionary();
|
|
6555
6559
|
_this._dictionary.update('Type', _PdfName.get('Annot'));
|
|
6556
6560
|
_this._dictionary.update('Subtype', _PdfName.get('Ink'));
|
|
@@ -6616,6 +6620,7 @@ var PdfInkAnnotation = /** @class */ (function (_super) {
|
|
|
6616
6620
|
set: function (value) {
|
|
6617
6621
|
if (Array.isArray(value) && value.length > 0 && value !== this._inkPointsCollection) {
|
|
6618
6622
|
this._inkPointsCollection = value;
|
|
6623
|
+
this._isModified = true;
|
|
6619
6624
|
if (this._isLoaded) {
|
|
6620
6625
|
this._dictionary.update('InkList', value);
|
|
6621
6626
|
}
|
|
@@ -6679,7 +6684,6 @@ var PdfInkAnnotation = /** @class */ (function (_super) {
|
|
|
6679
6684
|
}
|
|
6680
6685
|
};
|
|
6681
6686
|
PdfInkAnnotation.prototype._doPostProcess = function (isFlatten) {
|
|
6682
|
-
var _this = this;
|
|
6683
6687
|
if (isFlatten === void 0) { isFlatten = false; }
|
|
6684
6688
|
this._isFlatten = isFlatten;
|
|
6685
6689
|
if (this._isLoaded) {
|
|
@@ -6751,10 +6755,6 @@ var PdfInkAnnotation = /** @class */ (function (_super) {
|
|
|
6751
6755
|
}
|
|
6752
6756
|
}
|
|
6753
6757
|
}
|
|
6754
|
-
this._previousCollection.forEach(function (element) {
|
|
6755
|
-
_this._inkPointsCollection.push(element);
|
|
6756
|
-
});
|
|
6757
|
-
this._previousCollection = [];
|
|
6758
6758
|
}
|
|
6759
6759
|
if (typeof this.flattenPopups !== 'undefined' && this.flattenPopups) {
|
|
6760
6760
|
if (this._isLoaded) {
|
|
@@ -6920,32 +6920,32 @@ var PdfInkAnnotation = /** @class */ (function (_super) {
|
|
|
6920
6920
|
};
|
|
6921
6921
|
PdfInkAnnotation.prototype._addInkPoints = function () {
|
|
6922
6922
|
var _this = this;
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
_this._previousCollection.push(inkList);
|
|
6926
|
-
});
|
|
6927
|
-
}
|
|
6928
|
-
var _inkCollection = [];
|
|
6929
|
-
if (this._linePoints !== null) {
|
|
6923
|
+
var inkCollection = [];
|
|
6924
|
+
if (this._linePoints !== null && (this._previousCollection.length === 0 || this._isModified)) {
|
|
6930
6925
|
this._inkPointsCollection.unshift(this._linePoints);
|
|
6926
|
+
this._isModified = false;
|
|
6931
6927
|
}
|
|
6932
|
-
|
|
6928
|
+
var isEqual = _checkInkPoints(this._inkPointsCollection, this._previousCollection);
|
|
6929
|
+
if (this._inkPointsCollection !== null && !isEqual) {
|
|
6933
6930
|
for (var i = 0; i < this._inkPointsCollection.length; i++) {
|
|
6934
6931
|
var inkList = this._inkPointsCollection[Number.parseInt(i.toString(), 10)];
|
|
6935
|
-
|
|
6932
|
+
inkCollection.push(inkList);
|
|
6936
6933
|
}
|
|
6934
|
+
this._dictionary.update('InkList', inkCollection);
|
|
6935
|
+
}
|
|
6936
|
+
if (this._inkPointsCollection.length > 0) {
|
|
6937
|
+
this._inkPointsCollection.forEach(function (inkList) {
|
|
6938
|
+
_this._previousCollection.push(inkList);
|
|
6939
|
+
});
|
|
6937
6940
|
}
|
|
6938
|
-
this._dictionary.update('InkList', _inkCollection);
|
|
6939
6941
|
return this._getInkBoundsValue();
|
|
6940
6942
|
};
|
|
6941
6943
|
PdfInkAnnotation.prototype._getInkBoundsValue = function () {
|
|
6942
6944
|
var bounds = [0, 0, 0, 0];
|
|
6943
|
-
if (
|
|
6944
|
-
bounds =
|
|
6945
|
-
}
|
|
6946
|
-
else {
|
|
6947
|
-
bounds = [this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height];
|
|
6945
|
+
if (this._points) {
|
|
6946
|
+
this.bounds = { x: this._points[0], y: this._points[1], width: this._points[2], height: this._points[3] };
|
|
6948
6947
|
}
|
|
6948
|
+
bounds = [this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height];
|
|
6949
6949
|
var borderWidth = this.border.width;
|
|
6950
6950
|
if (this._inkPointsCollection !== null) {
|
|
6951
6951
|
if (this._inkPointsCollection.length > 0) {
|
|
@@ -7368,7 +7368,7 @@ var PdfPopupAnnotation = /** @class */ (function (_super) {
|
|
|
7368
7368
|
};
|
|
7369
7369
|
PdfPopupAnnotation.prototype._postProcess = function () {
|
|
7370
7370
|
if (typeof this.bounds === 'undefined' || this.bounds === null) {
|
|
7371
|
-
|
|
7371
|
+
this._bounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
7372
7372
|
}
|
|
7373
7373
|
var borderWidth;
|
|
7374
7374
|
if (this._dictionary.has('BS')) {
|
|
@@ -9779,7 +9779,7 @@ var PdfRubberStampAnnotation = /** @class */ (function (_super) {
|
|
|
9779
9779
|
}
|
|
9780
9780
|
else {
|
|
9781
9781
|
this._iconString = this._obtainIconName(this._icon);
|
|
9782
|
-
this._dictionary.update('Name', _PdfName.get('#' + this._iconString));
|
|
9782
|
+
this._dictionary.update('Name', _PdfName.get('#23' + this._iconString));
|
|
9783
9783
|
appearance = new PdfAppearance(this, nativeRectangle);
|
|
9784
9784
|
appearance.normal = new PdfTemplate(nativeRectangle, this._crossReference);
|
|
9785
9785
|
}
|
|
@@ -10,6 +10,7 @@ export declare class _ImageDecoder {
|
|
|
10
10
|
_imageData: Uint8Array;
|
|
11
11
|
_imageStream: _PdfStream;
|
|
12
12
|
_position: number;
|
|
13
|
+
_noOfComponents: number;
|
|
13
14
|
static _jpegHeader: number[];
|
|
14
15
|
/**
|
|
15
16
|
* Initializes a new instance of the `_ImageDecoder` class.
|
|
@@ -28,4 +29,10 @@ export declare class _ImageDecoder {
|
|
|
28
29
|
_getImageDictionary(): _PdfStream;
|
|
29
30
|
_getColorSpace(): string;
|
|
30
31
|
_getDecodeParams(): _PdfDictionary;
|
|
32
|
+
_seek(length: number): void;
|
|
33
|
+
_readByte(): number;
|
|
34
|
+
_skipStream(): void;
|
|
35
|
+
_readExceededJpegImage(): void;
|
|
36
|
+
_toUnsigned16(value: number): number;
|
|
37
|
+
_getMarker(): number;
|
|
31
38
|
}
|
|
@@ -10,8 +10,11 @@ var _ImageDecoder = /** @class */ (function () {
|
|
|
10
10
|
*/
|
|
11
11
|
function _ImageDecoder(stream) {
|
|
12
12
|
this._format = _ImageFormat.unknown;
|
|
13
|
+
this._height = 0;
|
|
14
|
+
this._width = 0;
|
|
13
15
|
this._bitsPerComponent = 8;
|
|
14
16
|
this._position = 0;
|
|
17
|
+
this._noOfComponents = -1;
|
|
15
18
|
this._stream = stream;
|
|
16
19
|
this._initialize();
|
|
17
20
|
}
|
|
@@ -43,19 +46,32 @@ var _ImageDecoder = /** @class */ (function () {
|
|
|
43
46
|
this._read(imgData, 0, imgData.byteLength);
|
|
44
47
|
var i = 4;
|
|
45
48
|
var length = this._getBuffer(i) * 256 + this._getBuffer(i + 1);
|
|
49
|
+
var isLengthExceed = false;
|
|
46
50
|
while (i < imgData.byteLength) {
|
|
47
51
|
i += length;
|
|
48
52
|
if (i < imgData.byteLength) {
|
|
49
53
|
if (this._getBuffer(i + 1) === 192) {
|
|
50
54
|
this._height = this._getBuffer(i + 5) * 256 + this._getBuffer(i + 6);
|
|
51
55
|
this._width = this._getBuffer(i + 7) * 256 + this._getBuffer(i + 8);
|
|
52
|
-
|
|
56
|
+
this._noOfComponents = this._getBuffer(i + 9);
|
|
57
|
+
if (this._width !== 0 && this._height !== 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
else {
|
|
55
62
|
i += 2;
|
|
56
63
|
length = this._getBuffer(i) * 256 + this._getBuffer(i + 1);
|
|
57
64
|
}
|
|
58
65
|
}
|
|
66
|
+
else {
|
|
67
|
+
isLengthExceed = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (isLengthExceed) {
|
|
72
|
+
this._reset();
|
|
73
|
+
this._seek(2);
|
|
74
|
+
this._readExceededJpegImage();
|
|
59
75
|
}
|
|
60
76
|
};
|
|
61
77
|
_ImageDecoder.prototype._checkIfJpeg = function () {
|
|
@@ -113,6 +129,12 @@ var _ImageDecoder = /** @class */ (function () {
|
|
|
113
129
|
return this._imageStream;
|
|
114
130
|
};
|
|
115
131
|
_ImageDecoder.prototype._getColorSpace = function () {
|
|
132
|
+
if (this._noOfComponents === 1) {
|
|
133
|
+
return 'DeviceGray';
|
|
134
|
+
}
|
|
135
|
+
else if (this._noOfComponents === 4) {
|
|
136
|
+
return 'DeviceCMYK';
|
|
137
|
+
}
|
|
116
138
|
return 'DeviceRGB';
|
|
117
139
|
};
|
|
118
140
|
_ImageDecoder.prototype._getDecodeParams = function () {
|
|
@@ -124,6 +146,81 @@ var _ImageDecoder = /** @class */ (function () {
|
|
|
124
146
|
decodeParams.set('BitsPerComponent', this._bitsPerComponent);
|
|
125
147
|
return decodeParams;
|
|
126
148
|
};
|
|
149
|
+
_ImageDecoder.prototype._seek = function (length) {
|
|
150
|
+
this._position += length;
|
|
151
|
+
};
|
|
152
|
+
_ImageDecoder.prototype._readByte = function () {
|
|
153
|
+
if (this._position < this._stream.byteLength) {
|
|
154
|
+
var value = this._getBuffer(this._position);
|
|
155
|
+
this._position += 1;
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error('Error decoding JPEG image. Invalid offset.');
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
_ImageDecoder.prototype._skipStream = function () {
|
|
163
|
+
var length = this._getBuffer(this._position) << 8 | this._getBuffer(this._position + 1);
|
|
164
|
+
this._seek(2);
|
|
165
|
+
if (length < 2) {
|
|
166
|
+
throw new Error('Error decoding JPEG image');
|
|
167
|
+
}
|
|
168
|
+
else if (length > 0) {
|
|
169
|
+
this._seek(length - 2);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
_ImageDecoder.prototype._readExceededJpegImage = function () {
|
|
173
|
+
var isContinueReading = true;
|
|
174
|
+
while (isContinueReading) {
|
|
175
|
+
var marker = this._getMarker();
|
|
176
|
+
switch (marker) {
|
|
177
|
+
case 0x00C0:
|
|
178
|
+
case 0x00C1:
|
|
179
|
+
case 0x00C2:
|
|
180
|
+
case 0x00C3:
|
|
181
|
+
case 0x00C5:
|
|
182
|
+
case 0x00C6:
|
|
183
|
+
case 0x00C7:
|
|
184
|
+
case 0x00C9:
|
|
185
|
+
case 0x00CA:
|
|
186
|
+
case 0x00CB:
|
|
187
|
+
case 0x00CD:
|
|
188
|
+
case 0x00CE:
|
|
189
|
+
case 0x00CF:
|
|
190
|
+
this._seek(3);
|
|
191
|
+
this._height = this._getBuffer(this._position) << 8 | this._getBuffer(this._position + 1);
|
|
192
|
+
this._seek(2);
|
|
193
|
+
this._width = this._getBuffer(this._position) << 8 | this._getBuffer(this._position + 1);
|
|
194
|
+
this._seek(2);
|
|
195
|
+
this._noOfComponents = this._getBuffer(this._position);
|
|
196
|
+
this._seek(1);
|
|
197
|
+
isContinueReading = false;
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
this._skipStream();
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
_ImageDecoder.prototype._toUnsigned16 = function (value) {
|
|
206
|
+
value = value & 0xFFFF;
|
|
207
|
+
return value < 0 ? (value + 0x10000) : value;
|
|
208
|
+
};
|
|
209
|
+
_ImageDecoder.prototype._getMarker = function () {
|
|
210
|
+
var skippedByte = 0;
|
|
211
|
+
var marker = this._readByte();
|
|
212
|
+
while (marker != 255) {
|
|
213
|
+
skippedByte++;
|
|
214
|
+
marker = this._readByte();
|
|
215
|
+
}
|
|
216
|
+
do {
|
|
217
|
+
marker = this._readByte();
|
|
218
|
+
} while (marker == 255);
|
|
219
|
+
if (skippedByte != 0) {
|
|
220
|
+
throw new Error('Error decoding JPEG image');
|
|
221
|
+
}
|
|
222
|
+
return this._toUnsigned16(marker);
|
|
223
|
+
};
|
|
127
224
|
_ImageDecoder._jpegHeader = [255, 216];
|
|
128
225
|
return _ImageDecoder;
|
|
129
226
|
}());
|
|
@@ -2628,7 +2628,7 @@ var _XfdfDocument = /** @class */ (function (_super) {
|
|
|
2628
2628
|
if (measurement) {
|
|
2629
2629
|
measureDictionary.update('Type', _PdfName.get('Measure'));
|
|
2630
2630
|
if (measurement.hasAttribute('rateValue')) {
|
|
2631
|
-
var attribute = measurement.getAttribute
|
|
2631
|
+
var attribute = measurement.getAttribute('rateValue');
|
|
2632
2632
|
if (attribute && attribute !== '') {
|
|
2633
2633
|
measureDictionary.update('R', attribute);
|
|
2634
2634
|
}
|
|
@@ -65,7 +65,7 @@ var _XmlDocument = /** @class */ (function (_super) {
|
|
|
65
65
|
if (isAcrobat) {
|
|
66
66
|
this._table.forEach(function (value, key) {
|
|
67
67
|
if (key.includes(' ')) {
|
|
68
|
-
var text = key.replace(
|
|
68
|
+
var text = key.replace(/ /g, '');
|
|
69
69
|
writer._writeStartElement(text.toString());
|
|
70
70
|
writer._writeAttributeString('original', key.toString(), 'xfdf', null);
|
|
71
71
|
}
|
|
@@ -79,7 +79,7 @@ var _XmlDocument = /** @class */ (function (_super) {
|
|
|
79
79
|
else {
|
|
80
80
|
this._table.forEach(function (value, key) {
|
|
81
81
|
if (key.includes(' ')) {
|
|
82
|
-
key = key.replace(
|
|
82
|
+
key = key.replace(/ /g, '_x0020_');
|
|
83
83
|
}
|
|
84
84
|
writer._writeStartElement(key.toString());
|
|
85
85
|
writer._writeString(value.toString());
|
|
@@ -139,7 +139,7 @@ var _XmlDocument = /** @class */ (function (_super) {
|
|
|
139
139
|
}
|
|
140
140
|
var text = key.toString();
|
|
141
141
|
if (text.indexOf('_x0020_') !== -1) {
|
|
142
|
-
text = text.replace(
|
|
142
|
+
text = text.replace(/_x0020_/g, ' ');
|
|
143
143
|
}
|
|
144
144
|
var index = form._getFieldIndex(text);
|
|
145
145
|
if (index !== -1 && index < count) {
|
|
@@ -944,7 +944,7 @@ var _PdfCrossReference = /** @class */ (function () {
|
|
|
944
944
|
};
|
|
945
945
|
_PdfCrossReference.prototype._writeValue = function (value, buffer, transform, isCrossReference) {
|
|
946
946
|
if (value instanceof _PdfName) {
|
|
947
|
-
this._writeString("/" +
|
|
947
|
+
this._writeString("/" + value.name, buffer);
|
|
948
948
|
}
|
|
949
949
|
else if (value instanceof _PdfReference) {
|
|
950
950
|
this._writeString(value.toString() + " R", buffer);
|
package/src/pdf/core/utils.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare function _convertStringToBytes(value: string, destination: number
|
|
|
76
76
|
* @param {number[]} second byte array.
|
|
77
77
|
* @returns {boolean} Equal or not
|
|
78
78
|
*/
|
|
79
|
-
export declare function _areArrayEqual(first: Uint8Array, second: Uint8Array): boolean;
|
|
79
|
+
export declare function _areArrayEqual(first: Uint8Array | number[], second: Uint8Array | number[]): boolean;
|
|
80
80
|
/**
|
|
81
81
|
* Convert number to string as round value with fixed decimal points 2.
|
|
82
82
|
*
|
|
@@ -676,3 +676,11 @@ export declare function _mapFont(name: string, size: number, style: PdfFontStyle
|
|
|
676
676
|
* @returns {Uint8Array} result.
|
|
677
677
|
*/
|
|
678
678
|
export declare function _tryParseFontStream(widgetDictionary: _PdfDictionary, crossReference: _PdfCrossReference, annotation: PdfAnnotation | PdfField): Uint8Array;
|
|
679
|
+
/**
|
|
680
|
+
* Gets the boolean if two arrays are equal.
|
|
681
|
+
*
|
|
682
|
+
* @param {Array<number[]>} inkPointsCollection Ink points collection.
|
|
683
|
+
* @param {Array<number[]>} previousCollection Previous collection.
|
|
684
|
+
* @returns {boolean} result.
|
|
685
|
+
*/
|
|
686
|
+
export declare function _checkInkPoints(inkPointsCollection: Array<number[]>, previousCollection: Array<number[]>): boolean;
|
package/src/pdf/core/utils.js
CHANGED
|
@@ -3605,3 +3605,21 @@ export function _tryParseFontStream(widgetDictionary, crossReference, annotation
|
|
|
3605
3605
|
}
|
|
3606
3606
|
return fontData;
|
|
3607
3607
|
}
|
|
3608
|
+
/**
|
|
3609
|
+
* Gets the boolean if two arrays are equal.
|
|
3610
|
+
*
|
|
3611
|
+
* @param {Array<number[]>} inkPointsCollection Ink points collection.
|
|
3612
|
+
* @param {Array<number[]>} previousCollection Previous collection.
|
|
3613
|
+
* @returns {boolean} result.
|
|
3614
|
+
*/
|
|
3615
|
+
export function _checkInkPoints(inkPointsCollection, previousCollection) {
|
|
3616
|
+
if (inkPointsCollection.length !== previousCollection.length) {
|
|
3617
|
+
return false;
|
|
3618
|
+
}
|
|
3619
|
+
for (var i = 0; i < inkPointsCollection.length; i++) {
|
|
3620
|
+
if (!_areArrayEqual(inkPointsCollection[Number.parseInt(i.toString(), 10)], previousCollection[Number.parseInt(i.toString(), 10)])) {
|
|
3621
|
+
return false;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
return true;
|
|
3625
|
+
}
|