mozilla/pdf.js · error · Error
app.printerNames is read-only
Error message
app.printerNames is read-only
What it means
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.
Source
Thrown at src/scripting_api/app.js:322
set plugins(_) {
throw new Error("app.plugins is read-only");
}
get printColorProfiles() {
return [];
}
set printColorProfiles(_) {
throw new Error("app.printColorProfiles is read-only");
}
get printerNames() {
return [];
}
set printerNames(_) {
throw new Error("app.printerNames is read-only");
}
get runtimeHighlight() {
return this._runtimeHighlight;
}
set runtimeHighlight(val) {
this._runtimeHighlight = val;
/* TODO */
}
get runtimeHighlightColor() {
return this._runtimeHighlightColor;
}
set runtimeHighlightColor(val) {
if (Color._isValidColor(val)) {
this._runtimeHighlightColor = val;View on GitHub (pinned to 5903d58d58)
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.
Example fix
// before app.printerNames = ['Printer1']; // after const printers = app.printerNames; // [] in pdf.js
Defensive patterns
Strategy: validation
Validate before calling
// app.printerNames always returns [] in pdf.js. const knownPrinters = (app) => app.printerNames;
Type guard
const isPrinterList = (v) => Array.isArray(v);
Try / catch
try { /* code that may assign app.printerNames */ }
catch (e) { if (!/printerNames is read-only/.test(e.message)) throw e; } Prevention
- Rely on the host browser's print dialog for printer selection.
- Expect [] and do not push into it.
- Treat printer enumeration as viewer-managed.
When it happens
Trigger: Any assignment app.printerNames = [...] in PDF JavaScript or caller code hits the throw at src/scripting_api/app.js:322.
Common situations: Scripts trying to pre-populate a print target list; print dialogs expecting a writable registry.
Related errors
- app.printColorProfiles is read-only
- app.fromPDFConverters is read-only
- app.monitors is read-only
- app.numPlugins is read-only
- app.plugins is read-only
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/648c956daeac96c4.
Report an issue: GitHub.