mozilla/pdf.js · error · Error

doc.permStatusReady is read-only

Error message

doc.permStatusReady is read-only

What it means

`Doc.permStatusReady` indicates whether the document's permission status (rights/usage-rights) has finished loading; PDF.js returns `true` because it does not perform asynchronous usage-rights resolution. It is read-only by the Acrobat spec — a script observes the state, it cannot change it. The throwing setter keeps that contract.

Source

Thrown at src/scripting_api/doc.js:599

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

  get path() {
    return "";
  }

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

  get permStatusReady() {
    return true;
  }

  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");
  }

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Remove the assignment — observe the value (`var ready = doc.permStatusReady;`, always true in PDF.js).
  2. Handle permissions/rights at the document-loading layer, not in-document.
  3. Guard legacy scripts with try/catch.

Example fix

// before
doc.permStatusReady = true;

// after
if (doc.permStatusReady) { /* always true in PDF.js */ }
Defensive patterns

Strategy: try-catch

Validate before calling

const READ_ONLY_DOC_PROPS = new Set(['permStatusReady','requiresFullSave' /* ... */]);
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, 'permStatusReady'); // true

Try / catch

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

Prevention

When it happens

Trigger: A script writes `doc.permStatusReady = true/false;`, attempting to force or reset the permissions-ready flag. The setter throws.

Common situations: Rights-management scripts from LiveCycle/Acrobat; scripts that toggle flags before reading `doc.dynamicXFAForm` or related; legacy enterprise form logic.

Related errors


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