@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
|
@@ -13196,7 +13196,19 @@ class _JsonDocument extends _ExportHelper {
|
|
|
13196
13196
|
const dataTable = new Map(); // eslint-disable-line
|
|
13197
13197
|
const streamTable = new Map(); // eslint-disable-line
|
|
13198
13198
|
const streamDictionary = value.dictionary;
|
|
13199
|
-
|
|
13199
|
+
let data;
|
|
13200
|
+
let baseStream = value; // eslint-disable-line
|
|
13201
|
+
let isImageStream = false;
|
|
13202
|
+
if (streamDictionary.has('Subtype') && streamDictionary.get('Subtype').name === 'Image') {
|
|
13203
|
+
isImageStream = true;
|
|
13204
|
+
}
|
|
13205
|
+
if (isImageStream && baseStream.stream && baseStream.stream instanceof _PdfStream) {
|
|
13206
|
+
const stream = baseStream.stream;
|
|
13207
|
+
data = baseStream.getString(true, stream.getByteRange(stream.start, stream.end));
|
|
13208
|
+
}
|
|
13209
|
+
else {
|
|
13210
|
+
data = value.getString(true);
|
|
13211
|
+
}
|
|
13200
13212
|
if (!streamDictionary.has('Length') && data && data !== '') {
|
|
13201
13213
|
streamDictionary.update('Length', value.length);
|
|
13202
13214
|
}
|
|
@@ -26382,8 +26394,26 @@ class PdfSquareAnnotation extends PdfComment {
|
|
|
26382
26394
|
}
|
|
26383
26395
|
}
|
|
26384
26396
|
if (isFlatten && this._appearanceTemplate) {
|
|
26385
|
-
const
|
|
26386
|
-
|
|
26397
|
+
const appearanceDictionary = this._appearanceTemplate._content.dictionary;
|
|
26398
|
+
const isValid = appearanceDictionary && appearanceDictionary.has('BBox') && !appearanceDictionary.has('CropBox') && !appearanceDictionary.has('MediaBox');
|
|
26399
|
+
if (isValid && this.measure) {
|
|
26400
|
+
const graphics = this._page.graphics;
|
|
26401
|
+
const state = graphics.save();
|
|
26402
|
+
if (typeof this.opacity !== 'undefined' && this._opacity < 1) {
|
|
26403
|
+
graphics.setTransparency(this._opacity);
|
|
26404
|
+
}
|
|
26405
|
+
const point = this.bounds;
|
|
26406
|
+
const box = this._appearanceTemplate._content.dictionary.getArray('BBox');
|
|
26407
|
+
point.x -= box[0];
|
|
26408
|
+
point.y += box[1];
|
|
26409
|
+
graphics.drawTemplate(this._appearanceTemplate, point);
|
|
26410
|
+
graphics.restore(state);
|
|
26411
|
+
this._removeAnnotationFromPage(this._page, this);
|
|
26412
|
+
}
|
|
26413
|
+
else {
|
|
26414
|
+
const isNormalMatrix = this._validateTemplateMatrix(this._appearanceTemplate._content.dictionary);
|
|
26415
|
+
this._flattenAnnotationTemplate(this._appearanceTemplate, isNormalMatrix);
|
|
26416
|
+
}
|
|
26387
26417
|
}
|
|
26388
26418
|
if (!isFlatten && this._setAppearance && !this.measure) {
|
|
26389
26419
|
let appearance;
|
|
@@ -26518,16 +26548,16 @@ class PdfSquareAnnotation extends PdfComment {
|
|
|
26518
26548
|
const converter = new _PdfUnitConvertor();
|
|
26519
26549
|
let value;
|
|
26520
26550
|
if (this.bounds.width === this.bounds.height) {
|
|
26521
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
26551
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
26522
26552
|
this._unitString = value.unitString;
|
|
26523
26553
|
const width = converter._convertUnits(this.bounds.width, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
26524
26554
|
area = width * width;
|
|
26525
26555
|
}
|
|
26526
26556
|
else {
|
|
26527
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
26557
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
26528
26558
|
this._unitString = value.unitString;
|
|
26529
26559
|
const width = converter._convertUnits(this.bounds.width, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
26530
|
-
value = this._getEqualPdfGraphicsUnit(this.
|
|
26560
|
+
value = this._getEqualPdfGraphicsUnit(this.unit, this._unitString);
|
|
26531
26561
|
this._unitString = value.unitString;
|
|
26532
26562
|
const height = converter._convertUnits(this.bounds.height, _PdfGraphicsUnit.point, value.graphicsUnit);
|
|
26533
26563
|
area = width * height;
|
|
@@ -43510,25 +43540,15 @@ class _PdfBaseStream {
|
|
|
43510
43540
|
moveStart() {
|
|
43511
43541
|
return null;
|
|
43512
43542
|
}
|
|
43513
|
-
getString(isHex = false) {
|
|
43514
|
-
|
|
43515
|
-
|
|
43516
|
-
throw new Error('Invalid argument for bytesToString');
|
|
43543
|
+
getString(isHex = false, bytes) {
|
|
43544
|
+
if (typeof bytes === 'undefined' || bytes === null) {
|
|
43545
|
+
bytes = this.getBytes();
|
|
43517
43546
|
}
|
|
43518
43547
|
if (isHex) {
|
|
43519
43548
|
return _byteArrayToHexString(bytes);
|
|
43520
43549
|
}
|
|
43521
43550
|
else {
|
|
43522
|
-
|
|
43523
|
-
const max = 8192;
|
|
43524
|
-
if (len < max) {
|
|
43525
|
-
return String.fromCharCode.apply(null, bytes);
|
|
43526
|
-
}
|
|
43527
|
-
const stringBuffer = [];
|
|
43528
|
-
for (let i = 0; i < len; i += max) {
|
|
43529
|
-
stringBuffer.push(String.fromCharCode.apply(null, bytes.subarray(i, Math.min(i + max, len))));
|
|
43530
|
-
}
|
|
43531
|
-
return stringBuffer.join('');
|
|
43551
|
+
return _bytesToString(bytes);
|
|
43532
43552
|
}
|
|
43533
43553
|
}
|
|
43534
43554
|
skip(n) {
|
|
@@ -47464,6 +47484,9 @@ class _PdfCrossReference {
|
|
|
47464
47484
|
_setStartXRef(startXRef) {
|
|
47465
47485
|
this._startXRefQueue = [startXRef];
|
|
47466
47486
|
this._prevStartXref = startXRef;
|
|
47487
|
+
if (typeof this._prevXRefOffset === 'undefined' || this._prevXRefOffset === null) {
|
|
47488
|
+
this._prevXRefOffset = startXRef;
|
|
47489
|
+
}
|
|
47467
47490
|
}
|
|
47468
47491
|
_parse(recoveryMode) {
|
|
47469
47492
|
let trailerDictionary;
|
|
@@ -48265,7 +48288,7 @@ class _PdfCrossReference {
|
|
|
48265
48288
|
}
|
|
48266
48289
|
_copyTrailer(newXref) {
|
|
48267
48290
|
newXref.set('Size', this._nextReferenceNumber);
|
|
48268
|
-
newXref.set('Prev', this._prevStartXref);
|
|
48291
|
+
this._document._isEncrypted ? newXref.set('Prev', this._prevXRefOffset) : newXref.set('Prev', this._prevStartXref);
|
|
48269
48292
|
const root = this._trailer.getRaw('Root'); // eslint-disable-line
|
|
48270
48293
|
if (typeof root !== 'undefined' && root !== null) {
|
|
48271
48294
|
newXref.set('Root', root);
|
|
@@ -51195,31 +51218,45 @@ class PdfDocument {
|
|
|
51195
51218
|
pageDictionary.objId = pageReference.toString();
|
|
51196
51219
|
pageDictionary.update('Parent', sectionReference);
|
|
51197
51220
|
sectionDictionary.update('Kids', [pageReference]);
|
|
51198
|
-
|
|
51199
|
-
|
|
51200
|
-
|
|
51201
|
-
|
|
51202
|
-
|
|
51203
|
-
|
|
51204
|
-
|
|
51205
|
-
|
|
51206
|
-
|
|
51207
|
-
|
|
51208
|
-
|
|
51209
|
-
|
|
51210
|
-
|
|
51211
|
-
|
|
51212
|
-
|
|
51213
|
-
|
|
51214
|
-
|
|
51215
|
-
|
|
51216
|
-
|
|
51217
|
-
|
|
51221
|
+
if (this.pageCount === 0) {
|
|
51222
|
+
const parentReference = this._catalog._catalogDictionary._get('Pages');
|
|
51223
|
+
if (parentReference && this._catalog._topPagesDictionary) {
|
|
51224
|
+
this._catalog._topPagesDictionary.update('Kids', [sectionReference]);
|
|
51225
|
+
sectionDictionary.update('Parent', parentReference);
|
|
51226
|
+
}
|
|
51227
|
+
else {
|
|
51228
|
+
this._catalog._catalogDictionary.update('Pages', sectionReference);
|
|
51229
|
+
}
|
|
51230
|
+
this._pages = new Map();
|
|
51231
|
+
this._pageCount = 1;
|
|
51232
|
+
}
|
|
51233
|
+
else {
|
|
51234
|
+
const lastPage = this.getPage(pageIndex === this.pageCount ? (pageIndex - 1) : pageIndex);
|
|
51235
|
+
if (lastPage && lastPage._pageDictionary) {
|
|
51236
|
+
const parentReference = lastPage._pageDictionary._get('Parent');
|
|
51237
|
+
const parentDictionary = this._crossReference._fetch(parentReference);
|
|
51238
|
+
if (parentDictionary && parentDictionary.has('Kids')) {
|
|
51239
|
+
let kids = parentDictionary.get('Kids');
|
|
51240
|
+
if (kids) {
|
|
51241
|
+
if (pageIndex === this.pageCount) {
|
|
51242
|
+
kids.push(sectionReference);
|
|
51243
|
+
}
|
|
51244
|
+
else {
|
|
51245
|
+
const newKids = [];
|
|
51246
|
+
kids.forEach((entry) => {
|
|
51247
|
+
if (entry === lastPage._ref) {
|
|
51248
|
+
newKids.push(sectionReference);
|
|
51249
|
+
}
|
|
51250
|
+
newKids.push(entry);
|
|
51251
|
+
});
|
|
51252
|
+
kids = newKids;
|
|
51253
|
+
this._updatePageCache(pageIndex);
|
|
51254
|
+
}
|
|
51255
|
+
parentDictionary.update('Kids', kids);
|
|
51256
|
+
sectionDictionary.update('Parent', parentReference);
|
|
51257
|
+
this._updatePageCount(parentDictionary, 1);
|
|
51258
|
+
this._pageCount = this.pageCount + 1;
|
|
51218
51259
|
}
|
|
51219
|
-
parentDictionary.update('Kids', kids);
|
|
51220
|
-
sectionDictionary.update('Parent', parentReference);
|
|
51221
|
-
this._updatePageCount(parentDictionary, 1);
|
|
51222
|
-
this._pageCount = this.pageCount + 1;
|
|
51223
51260
|
}
|
|
51224
51261
|
}
|
|
51225
51262
|
}
|
|
@@ -51318,17 +51355,19 @@ class PdfDocument {
|
|
|
51318
51355
|
}
|
|
51319
51356
|
}
|
|
51320
51357
|
_removeParent(referenceToRemove, dictionary) {
|
|
51321
|
-
|
|
51322
|
-
|
|
51323
|
-
|
|
51324
|
-
|
|
51325
|
-
|
|
51326
|
-
|
|
51327
|
-
|
|
51328
|
-
|
|
51329
|
-
|
|
51330
|
-
|
|
51331
|
-
|
|
51358
|
+
if (dictionary.has('Parent')) {
|
|
51359
|
+
const parentReference = dictionary._get('Parent');
|
|
51360
|
+
const parentDictionary = this._crossReference._fetch(parentReference);
|
|
51361
|
+
if (parentDictionary && parentDictionary.has('Kids')) {
|
|
51362
|
+
let kids = parentDictionary.get('Kids');
|
|
51363
|
+
if (kids.length === 1 && parentDictionary && parentDictionary.get('Type').name === 'Pages') {
|
|
51364
|
+
this._removeParent(parentReference, parentDictionary);
|
|
51365
|
+
}
|
|
51366
|
+
else {
|
|
51367
|
+
kids = kids.filter((item) => item !== referenceToRemove);
|
|
51368
|
+
parentDictionary.update('Kids', kids);
|
|
51369
|
+
this._updatePageCount(parentDictionary, -1);
|
|
51370
|
+
}
|
|
51332
51371
|
}
|
|
51333
51372
|
}
|
|
51334
51373
|
}
|