@syncfusion/ej2-pdf 25.1.35 → 25.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 +2 -2
- package/dist/ej2-pdf.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf.es2015.js +95 -56
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +95 -56
- package/dist/es6/ej2-pdf.es5.js.map +1 -1
- package/dist/global/ej2-pdf.min.js +2 -2
- package/dist/global/ej2-pdf.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +5 -5
- package/src/pdf/core/annotations/annotation.js +23 -5
- package/src/pdf/core/base-stream.d.ts +1 -1
- package/src/pdf/core/base-stream.js +5 -15
- package/src/pdf/core/import-export/json-document.js +14 -2
- package/src/pdf/core/pdf-cross-reference.d.ts +1 -0
- package/src/pdf/core/pdf-cross-reference.js +4 -1
- package/src/pdf/core/pdf-document.js +51 -35
package/dist/es6/ej2-pdf.es5.js
CHANGED
|
@@ -13613,7 +13613,19 @@ var _JsonDocument = /** @__PURE__ @class */ (function (_super) {
|
|
|
13613
13613
|
var dataTable = new Map(); // eslint-disable-line
|
|
13614
13614
|
var streamTable = new Map(); // eslint-disable-line
|
|
13615
13615
|
var streamDictionary = value.dictionary;
|
|
13616
|
-
var data =
|
|
13616
|
+
var data = void 0;
|
|
13617
|
+
var baseStream = value; // eslint-disable-line
|
|
13618
|
+
var isImageStream = false;
|
|
13619
|
+
if (streamDictionary.has('Subtype') && streamDictionary.get('Subtype').name === 'Image') {
|
|
13620
|
+
isImageStream = true;
|
|
13621
|
+
}
|
|
13622
|
+
if (isImageStream && baseStream.stream && baseStream.stream instanceof _PdfStream) {
|
|
13623
|
+
var stream = baseStream.stream;
|
|
13624
|
+
data = baseStream.getString(true, stream.getByteRange(stream.start, stream.end));
|
|
13625
|
+
}
|
|
13626
|
+
else {
|
|
13627
|
+
data = value.getString(true);
|
|
13628
|
+
}
|
|
13617
13629
|
if (!streamDictionary.has('Length') && data && data !== '') {
|
|
13618
13630
|
streamDictionary.update('Length', value.length);
|
|
13619
13631
|
}
|
|
@@ -27379,8 +27391,26 @@ var PdfSquareAnnotation = /** @__PURE__ @class */ (function (_super) {
|
|
|
27379
27391
|
}
|
|
27380
27392
|
}
|
|
27381
27393
|
if (isFlatten && this._appearanceTemplate) {
|
|
27382
|
-
var
|
|
27383
|
-
|
|
27394
|
+
var appearanceDictionary = this._appearanceTemplate._content.dictionary;
|
|
27395
|
+
var isValid = appearanceDictionary && appearanceDictionary.has('BBox') && !appearanceDictionary.has('CropBox') && !appearanceDictionary.has('MediaBox');
|
|
27396
|
+
if (isValid && this.measure) {
|
|
27397
|
+
var graphics = this._page.graphics;
|
|
27398
|
+
var state = graphics.save();
|
|
27399
|
+
if (typeof this.opacity !== 'undefined' && this._opacity < 1) {
|
|
27400
|
+
graphics.setTransparency(this._opacity);
|
|
27401
|
+
}
|
|
27402
|
+
var point = this.bounds;
|
|
27403
|
+
var box = this._appearanceTemplate._content.dictionary.getArray('BBox');
|
|
27404
|
+
point.x -= box[0];
|
|
27405
|
+
point.y += box[1];
|
|
27406
|
+
graphics.drawTemplate(this._appearanceTemplate, point);
|
|
27407
|
+
graphics.restore(state);
|
|
27408
|
+
this._removeAnnotationFromPage(this._page, this);
|
|
27409
|
+
}
|
|
27410
|
+
else {
|
|
27411
|
+
var isNormalMatrix = this._validateTemplateMatrix(this._appearanceTemplate._content.dictionary);
|
|
27412
|
+
this._flattenAnnotationTemplate(this._appearanceTemplate, isNormalMatrix);
|
|
27413
|
+
}
|
|
27384
27414
|
}
|
|
27385
27415
|
if (!isFlatten && this._setAppearance && !this.measure) {
|
|
27386
27416
|
var appearance = void 0;
|
|
@@ -27515,16 +27545,16 @@ var PdfSquareAnnotation = /** @__PURE__ @class */ (function (_super) {
|
|
|
27515
27545
|
var converter = new _PdfUnitConvertor();
|
|
27516
27546
|
var value;
|
|
27517
27547
|
if (this.bounds.width === this.bounds.height) {
|
|
27518
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
27548
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
27519
27549
|
this._unitString = value.unitString;
|
|
27520
27550
|
var width = converter._convertUnits(this.bounds.width, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
27521
27551
|
area = width * width;
|
|
27522
27552
|
}
|
|
27523
27553
|
else {
|
|
27524
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
27554
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
27525
27555
|
this._unitString = value.unitString;
|
|
27526
27556
|
var width = converter._convertUnits(this.bounds.width, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
27527
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
27557
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
27528
27558
|
this._unitString = value.unitString;
|
|
27529
27559
|
var height = converter._convertUnits(this.bounds.height, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
27530
27560
|
area = width * height;
|
|
@@ -45103,26 +45133,16 @@ var _PdfBaseStream = /** @__PURE__ @class */ (function () {
|
|
|
45103
45133
|
_PdfBaseStream.prototype.moveStart = function () {
|
|
45104
45134
|
return null;
|
|
45105
45135
|
};
|
|
45106
|
-
_PdfBaseStream.prototype.getString = function (isHex) {
|
|
45136
|
+
_PdfBaseStream.prototype.getString = function (isHex, bytes) {
|
|
45107
45137
|
if (isHex === void 0) { isHex = false; }
|
|
45108
|
-
|
|
45109
|
-
|
|
45110
|
-
throw new Error('Invalid argument for bytesToString');
|
|
45138
|
+
if (typeof bytes === 'undefined' || bytes === null) {
|
|
45139
|
+
bytes = this.getBytes();
|
|
45111
45140
|
}
|
|
45112
45141
|
if (isHex) {
|
|
45113
45142
|
return _byteArrayToHexString(bytes);
|
|
45114
45143
|
}
|
|
45115
45144
|
else {
|
|
45116
|
-
|
|
45117
|
-
var max = 8192;
|
|
45118
|
-
if (len < max) {
|
|
45119
|
-
return String.fromCharCode.apply(null, bytes);
|
|
45120
|
-
}
|
|
45121
|
-
var stringBuffer = [];
|
|
45122
|
-
for (var i = 0; i < len; i += max) {
|
|
45123
|
-
stringBuffer.push(String.fromCharCode.apply(null, bytes.subarray(i, Math.min(i + max, len))));
|
|
45124
|
-
}
|
|
45125
|
-
return stringBuffer.join('');
|
|
45145
|
+
return _bytesToString(bytes);
|
|
45126
45146
|
}
|
|
45127
45147
|
};
|
|
45128
45148
|
_PdfBaseStream.prototype.skip = function (n) {
|
|
@@ -49252,6 +49272,9 @@ var _PdfCrossReference = /** @__PURE__ @class */ (function () {
|
|
|
49252
49272
|
_PdfCrossReference.prototype._setStartXRef = function (startXRef) {
|
|
49253
49273
|
this._startXRefQueue = [startXRef];
|
|
49254
49274
|
this._prevStartXref = startXRef;
|
|
49275
|
+
if (typeof this._prevXRefOffset === 'undefined' || this._prevXRefOffset === null) {
|
|
49276
|
+
this._prevXRefOffset = startXRef;
|
|
49277
|
+
}
|
|
49255
49278
|
};
|
|
49256
49279
|
_PdfCrossReference.prototype._parse = function (recoveryMode) {
|
|
49257
49280
|
var trailerDictionary;
|
|
@@ -50055,7 +50078,7 @@ var _PdfCrossReference = /** @__PURE__ @class */ (function () {
|
|
|
50055
50078
|
};
|
|
50056
50079
|
_PdfCrossReference.prototype._copyTrailer = function (newXref) {
|
|
50057
50080
|
newXref.set('Size', this._nextReferenceNumber);
|
|
50058
|
-
newXref.set('Prev', this._prevStartXref);
|
|
50081
|
+
this._document._isEncrypted ? newXref.set('Prev', this._prevXRefOffset) : newXref.set('Prev', this._prevStartXref);
|
|
50059
50082
|
var root = this._trailer.getRaw('Root'); // eslint-disable-line
|
|
50060
50083
|
if (typeof root !== 'undefined' && root !== null) {
|
|
50061
50084
|
newXref.set('Root', root);
|
|
@@ -53173,31 +53196,45 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
|
|
|
53173
53196
|
pageDictionary.objId = pageReference.toString();
|
|
53174
53197
|
pageDictionary.update('Parent', sectionReference);
|
|
53175
53198
|
sectionDictionary.update('Kids', [pageReference]);
|
|
53176
|
-
|
|
53177
|
-
|
|
53178
|
-
|
|
53179
|
-
|
|
53180
|
-
|
|
53181
|
-
|
|
53182
|
-
|
|
53183
|
-
|
|
53184
|
-
|
|
53185
|
-
|
|
53186
|
-
|
|
53187
|
-
|
|
53188
|
-
|
|
53189
|
-
|
|
53190
|
-
|
|
53191
|
-
|
|
53192
|
-
|
|
53193
|
-
|
|
53194
|
-
|
|
53195
|
-
|
|
53199
|
+
if (this.pageCount === 0) {
|
|
53200
|
+
var parentReference = this._catalog._catalogDictionary._get('Pages');
|
|
53201
|
+
if (parentReference && this._catalog._topPagesDictionary) {
|
|
53202
|
+
this._catalog._topPagesDictionary.update('Kids', [sectionReference]);
|
|
53203
|
+
sectionDictionary.update('Parent', parentReference);
|
|
53204
|
+
}
|
|
53205
|
+
else {
|
|
53206
|
+
this._catalog._catalogDictionary.update('Pages', sectionReference);
|
|
53207
|
+
}
|
|
53208
|
+
this._pages = new Map();
|
|
53209
|
+
this._pageCount = 1;
|
|
53210
|
+
}
|
|
53211
|
+
else {
|
|
53212
|
+
var lastPage_1 = this.getPage(pageIndex === this.pageCount ? (pageIndex - 1) : pageIndex);
|
|
53213
|
+
if (lastPage_1 && lastPage_1._pageDictionary) {
|
|
53214
|
+
var parentReference = lastPage_1._pageDictionary._get('Parent');
|
|
53215
|
+
var parentDictionary = this._crossReference._fetch(parentReference);
|
|
53216
|
+
if (parentDictionary && parentDictionary.has('Kids')) {
|
|
53217
|
+
var kids = parentDictionary.get('Kids');
|
|
53218
|
+
if (kids) {
|
|
53219
|
+
if (pageIndex === this.pageCount) {
|
|
53220
|
+
kids.push(sectionReference);
|
|
53221
|
+
}
|
|
53222
|
+
else {
|
|
53223
|
+
var newKids_1 = [];
|
|
53224
|
+
kids.forEach(function (entry) {
|
|
53225
|
+
if (entry === lastPage_1._ref) {
|
|
53226
|
+
newKids_1.push(sectionReference);
|
|
53227
|
+
}
|
|
53228
|
+
newKids_1.push(entry);
|
|
53229
|
+
});
|
|
53230
|
+
kids = newKids_1;
|
|
53231
|
+
this._updatePageCache(pageIndex);
|
|
53232
|
+
}
|
|
53233
|
+
parentDictionary.update('Kids', kids);
|
|
53234
|
+
sectionDictionary.update('Parent', parentReference);
|
|
53235
|
+
this._updatePageCount(parentDictionary, 1);
|
|
53236
|
+
this._pageCount = this.pageCount + 1;
|
|
53196
53237
|
}
|
|
53197
|
-
parentDictionary.update('Kids', kids);
|
|
53198
|
-
sectionDictionary.update('Parent', parentReference);
|
|
53199
|
-
this._updatePageCount(parentDictionary, 1);
|
|
53200
|
-
this._pageCount = this.pageCount + 1;
|
|
53201
53238
|
}
|
|
53202
53239
|
}
|
|
53203
53240
|
}
|
|
@@ -53297,17 +53334,19 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
|
|
|
53297
53334
|
}
|
|
53298
53335
|
};
|
|
53299
53336
|
PdfDocument.prototype._removeParent = function (referenceToRemove, dictionary) {
|
|
53300
|
-
|
|
53301
|
-
|
|
53302
|
-
|
|
53303
|
-
|
|
53304
|
-
|
|
53305
|
-
|
|
53306
|
-
|
|
53307
|
-
|
|
53308
|
-
|
|
53309
|
-
|
|
53310
|
-
|
|
53337
|
+
if (dictionary.has('Parent')) {
|
|
53338
|
+
var parentReference = dictionary._get('Parent');
|
|
53339
|
+
var parentDictionary = this._crossReference._fetch(parentReference);
|
|
53340
|
+
if (parentDictionary && parentDictionary.has('Kids')) {
|
|
53341
|
+
var kids = parentDictionary.get('Kids');
|
|
53342
|
+
if (kids.length === 1 && parentDictionary && parentDictionary.get('Type').name === 'Pages') {
|
|
53343
|
+
this._removeParent(parentReference, parentDictionary);
|
|
53344
|
+
}
|
|
53345
|
+
else {
|
|
53346
|
+
kids = kids.filter(function (item) { return item !== referenceToRemove; });
|
|
53347
|
+
parentDictionary.update('Kids', kids);
|
|
53348
|
+
this._updatePageCount(parentDictionary, -1);
|
|
53349
|
+
}
|
|
53311
53350
|
}
|
|
53312
53351
|
}
|
|
53313
53352
|
};
|