mozilla/pdf.js · error · Error

doc.requiresFullSave is read-only

Error message

doc.requiresFullSave is read-only

What it means

`Doc.requiresFullSave` indicates whether an incremental save is disallowed and a full save is required; PDF.js returns `false` because it does not track save-state in the scripting sandbox. It is read-only by the Acrobat spec — the flag is determined by the document's internal state, not settable by scripts. The throwing setter enforces that contract.

Source

Thrown at src/scripting_api/doc.js:615

  set permStatusReady(_) {
    throw new Error("doc.permStatusReady is read-only");
  }

  get producer() {
    return this._producer;
  }

  set producer(_) {
    throw new Error("doc.producer is read-only");
  }

  get requiresFullSave() {
    return false;
  }

  set requiresFullSave(_) {
    throw new Error("doc.requiresFullSave is read-only");
  }

  get securityHandler() {
    return this._securityHandler;
  }

  set securityHandler(_) {
    throw new Error("doc.securityHandler is read-only");
  }

  get selectedAnnots() {
    return [];
  }

  set selectedAnnots(_) {
    throw new Error("doc.selectedAnnots is read-only");
  }

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Remove the assignment; read the value (`var need = doc.requiresFullSave;`, false in PDF.js).
  2. Implement save logic at the host layer — PDF.js scripting does not persist documents.
  3. Guard legacy save scripts with try/catch.

Example fix

// before
doc.requiresFullSave = true;

// after
var need = doc.requiresFullSave; // false in PDF.js; not settable
Defensive patterns

Strategy: try-catch

Validate before calling

const READ_ONLY_DOC_PROPS = new Set(['requiresFullSave','permStatusReady' /* ... */]);
function assertsNoReadOnlyWrite(scriptSrc) {
  for (const p of READ_ONLY_DOC_PROPS) {
    if (new RegExp(`\\bdoc\\.${p}\\s*=[^=]`).test(scriptSrc)) {
      throw new Error(`Script writes read-only property doc.${p}`);
    }
  }
}
assertsNoReadOnlyWrite(myScript);

Type guard

function isReadOnlyDocProp(doc, prop) {
  const desc = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(doc), prop)
    || Object.getOwnPropertyDescriptor(doc, prop);
  return !!desc && !!desc.get && !desc.set;
}
isReadOnlyDocProp(doc, 'requiresFullSave'); // true

Try / catch

try {
  doc.requiresFullSave = true;
} catch (e) {
  if (/requiresFullSave is read-only/.test(e.message)) console.warn(e.message);
  else throw e;
}

Prevention

When it happens

Trigger: A script writes `doc.requiresFullSave = true;`, often before calling `saveAs`. The setter throws on that line.

Common situations: Save-workflow scripts from desktop Acrobat; code copied from SDK samples that demonstrate save behavior; scripts unaware PDF.js has no save support.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/e05668b9e4d9ca43. Report an issue: GitHub.