{"record":{"id":"648c956daeac96c4","repo":"mozilla/pdf.js","slug":"app-printernames-is-read-only","errorCode":null,"errorMessage":"app.printerNames is read-only","messagePattern":"app\\.printerNames is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/app.js","lineNumber":322,"sourceCode":"\n  set plugins(_) {\n    throw new Error(\"app.plugins is read-only\");\n  }\n\n  get printColorProfiles() {\n    return [];\n  }\n\n  set printColorProfiles(_) {\n    throw new Error(\"app.printColorProfiles is read-only\");\n  }\n\n  get printerNames() {\n    return [];\n  }\n\n  set printerNames(_) {\n    throw new Error(\"app.printerNames is read-only\");\n  }\n\n  get runtimeHighlight() {\n    return this._runtimeHighlight;\n  }\n\n  set runtimeHighlight(val) {\n    this._runtimeHighlight = val;\n    /* TODO */\n  }\n\n  get runtimeHighlightColor() {\n    return this._runtimeHighlightColor;\n  }\n\n  set runtimeHighlightColor(val) {\n    if (Color._isValidColor(val)) {\n      this._runtimeHighlightColor = val;","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/app.js#L304-L340","documentation":"app.printerNames returns an empty array because PDF.js does not enumerate system printers. The list is viewer-managed and read-only; the setter throws. Assignment is rejected unconditionally.","triggerScenarios":"Any assignment app.printerNames = [...] in PDF JavaScript or caller code hits the throw at src/scripting_api/app.js:322.","commonSituations":"Scripts trying to pre-populate a print target list; print dialogs expecting a writable registry.","solutions":["Read app.printerNames only; expect [].","Use the host browser's print dialog for printer selection.","Do not attempt to push printer names from document scripts."],"exampleFix":"// before\napp.printerNames = ['Printer1'];\n// after\nconst printers = app.printerNames; // [] in pdf.js","handlingStrategy":"validation","validationCode":"// app.printerNames always returns [] in pdf.js.\nconst knownPrinters = (app) => app.printerNames;","typeGuard":"const isPrinterList = (v) => Array.isArray(v);","tryCatchPattern":"try { /* code that may assign app.printerNames */ }\ncatch (e) { if (!/printerNames is read-only/.test(e.message)) throw e; }","preventionTips":["Rely on the host browser's print dialog for printer selection.","Expect [] and do not push into it.","Treat printer enumeration as viewer-managed."],"tags":["scripting-api","read-only","print","stub"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}