@adnsistemas/pdf-lib 2.8.0 → 2.8.1

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/dist/pdf-lib.js CHANGED
@@ -10363,8 +10363,9 @@
10363
10363
  // only the last XRef Stream will be regenerated on save
10364
10364
  if (!this._lastXRefObjectNumber) {
10365
10365
  // if no XRef Stream, then nothing should be skipped
10366
- this._lastXRefObjectNumber = this.context.largestObjectNumber + 1;
10367
- const checkWatermark = this._lastXRefObjectNumber - 10; // max number of objects in the final part of the PDF to check
10366
+ // if we are adding a XRef Stream, then its number if this.context.largestObjectNumber + 1, so adding 10 ensures we won't skip current generade XRref Stream
10367
+ this._lastXRefObjectNumber = this.context.largestObjectNumber + 10;
10368
+ const checkWatermark = this._lastXRefObjectNumber - 20; // max number of objects in the final part of the PDF to check
10368
10369
  // search the last XRef Stream, if there is one, objects are expected to be in object number order
10369
10370
  for (let idx = objects.length - 1; idx > 0; idx--) {
10370
10371
  // if not in last 'rangeToCheck' objects, there is none that should be skipped, most probably a linearized PDF, or without XRef Streams
@@ -12699,7 +12700,7 @@
12699
12700
  for (let idx = 0, len = indirectObjects.length; idx < len; idx++) {
12700
12701
  const indirectObject = indirectObjects[idx];
12701
12702
  const [ref, object] = indirectObject;
12702
- if (!this.snapshot.shouldSave(ref.objectNumber)) {
12703
+ if (!this.shouldSave(incremental, ref.objectNumber, indirectObjects)) {
12703
12704
  continue;
12704
12705
  }
12705
12706
  const shouldNotCompress = ref === this.context.trailerInfo.Encrypt ||