{"record":{"id":"e05668b9e4d9ca43","repo":"mozilla/pdf.js","slug":"doc-requiresfullsave-is-read-only","errorCode":null,"errorMessage":"doc.requiresFullSave is read-only","messagePattern":"doc\\.requiresFullSave is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/doc.js","lineNumber":615,"sourceCode":"\n  set permStatusReady(_) {\n    throw new Error(\"doc.permStatusReady is read-only\");\n  }\n\n  get producer() {\n    return this._producer;\n  }\n\n  set producer(_) {\n    throw new Error(\"doc.producer is read-only\");\n  }\n\n  get requiresFullSave() {\n    return false;\n  }\n\n  set requiresFullSave(_) {\n    throw new Error(\"doc.requiresFullSave is read-only\");\n  }\n\n  get securityHandler() {\n    return this._securityHandler;\n  }\n\n  set securityHandler(_) {\n    throw new Error(\"doc.securityHandler is read-only\");\n  }\n\n  get selectedAnnots() {\n    return [];\n  }\n\n  set selectedAnnots(_) {\n    throw new Error(\"doc.selectedAnnots is read-only\");\n  }\n","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/doc.js#L597-L633","documentation":"`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.","triggerScenarios":"A script writes `doc.requiresFullSave = true;`, often before calling `saveAs`. The setter throws on that line.","commonSituations":"Save-workflow scripts from desktop Acrobat; code copied from SDK samples that demonstrate save behavior; scripts unaware PDF.js has no save support.","solutions":["Remove the assignment; read the value (`var need = doc.requiresFullSave;`, false in PDF.js).","Implement save logic at the host layer — PDF.js scripting does not persist documents.","Guard legacy save scripts with try/catch."],"exampleFix":"// before\ndoc.requiresFullSave = true;\n\n// after\nvar need = doc.requiresFullSave; // false in PDF.js; not settable","handlingStrategy":"try-catch","validationCode":"const READ_ONLY_DOC_PROPS = new Set(['requiresFullSave','permStatusReady' /* ... */]);\nfunction assertsNoReadOnlyWrite(scriptSrc) {\n  for (const p of READ_ONLY_DOC_PROPS) {\n    if (new RegExp(`\\\\bdoc\\\\.${p}\\\\s*=[^=]`).test(scriptSrc)) {\n      throw new Error(`Script writes read-only property doc.${p}`);\n    }\n  }\n}\nassertsNoReadOnlyWrite(myScript);","typeGuard":"function isReadOnlyDocProp(doc, prop) {\n  const desc = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(doc), prop)\n    || Object.getOwnPropertyDescriptor(doc, prop);\n  return !!desc && !!desc.get && !desc.set;\n}\nisReadOnlyDocProp(doc, 'requiresFullSave'); // true","tryCatchPattern":"try {\n  doc.requiresFullSave = true;\n} catch (e) {\n  if (/requiresFullSave is read-only/.test(e.message)) console.warn(e.message);\n  else throw e;\n}","preventionTips":["PDF.js scripting does not persist documents; never script save-state flags.","Implement save at the host layer; treat save-state properties as read-only.","Lint and try/catch legacy save workflows."],"tags":["scripting","acrobat-js-api","doc-object","read-only","save","unsupported"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}