@adnsistemas/pdf-lib 2.6.3 → 2.6.4

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
@@ -37048,7 +37048,10 @@ end\
37048
37048
  */
37049
37049
  save(options = {}) {
37050
37050
  return __awaiter(this, void 0, void 0, function* () {
37051
- const { useObjectStreams = true, objectsPerTick = 50, rewrite = false, } = options;
37051
+ // check PDF version
37052
+ const vparts = this.context.header.getVersionString().split('.');
37053
+ const uOS = options.rewrite || Number(vparts[0]) > 1 || Number(vparts[1]) >= 5;
37054
+ const { useObjectStreams = uOS, objectsPerTick = 50, rewrite = false, } = options;
37052
37055
  assertIs(useObjectStreams, 'useObjectStreams', ['boolean']);
37053
37056
  assertIs(objectsPerTick, 'objectsPerTick', ['number']);
37054
37057
  assertIs(rewrite, 'rewrite', ['boolean']);
@@ -37091,13 +37094,14 @@ end\
37091
37094
  */
37092
37095
  saveIncremental(snapshot, options = {}) {
37093
37096
  return __awaiter(this, void 0, void 0, function* () {
37097
+ // check PDF version
37098
+ const vparts = this.context.header.getVersionString().split('.');
37099
+ const uOS = Number(vparts[0]) > 1 || Number(vparts[1]) >= 5;
37094
37100
  const { objectsPerTick = 50 } = options;
37095
37101
  assertIs(objectsPerTick, 'objectsPerTick', ['number']);
37096
- const saveOptions = Object.assign(Object.assign({}, options), { addDefaultPage: false, updateFieldAppearances: false });
37102
+ const saveOptions = Object.assign(Object.assign({ useObjectStreams: uOS }, options), { addDefaultPage: false, updateFieldAppearances: false });
37097
37103
  yield this.prepareForSave(saveOptions);
37098
- const Writer = this.context.pdfFileDetails.useObjectStreams
37099
- ? PDFStreamWriter
37100
- : PDFWriter;
37104
+ const Writer = saveOptions.useObjectStreams ? PDFStreamWriter : PDFWriter;
37101
37105
  return Writer.forContextWithSnapshot(this.context, objectsPerTick, snapshot).serializeToBuffer();
37102
37106
  });
37103
37107
  }