@syncfusion/ej2-pdf 25.1.37 → 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.
@@ -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 = value.getString(true);
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 isNormalMatrix = this._validateTemplateMatrix(this._appearanceTemplate._content.dictionary);
27383
- this._flattenAnnotationTemplate(this._appearanceTemplate, isNormalMatrix);
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._unit, this._unitString);
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._unit, this._unitString);
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._unit, this._unitString);
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
- var bytes = this.getBytes();
45109
- if (typeof bytes === 'undefined' || bytes === null || typeof bytes.length === 'undefined') {
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
- var len = bytes.length;
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);