mozilla/pdf.js · error · Error
app.printColorProfiles is read-only
Error message
app.printColorProfiles is read-only
What it means
app.printColorProfiles returns an empty array (PDF.js does not enumerate color profiles). It is a viewer-managed property, so the setter throws. Assignment is rejected unconditionally.
Source
Thrown at src/scripting_api/app.js:314
set platform(_) {
throw new Error("app.platform is read-only");
}
get plugins() {
return [];
}
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 */
}View on GitHub (pinned to 5903d58d58)
Solutions
- Read app.printColorProfiles only; expect [].
- Configure color profiles through the host print pipeline, not the scripting API.
- Feature-detect before attempting print-color-profile logic.
Example fix
// before app.printColorProfiles = [profile]; // after const profiles = app.printColorProfiles; // [] in pdf.js
Defensive patterns
Strategy: validation
Validate before calling
// app.printColorProfiles always returns [] in pdf.js. const hasProfiles = (app) => app.printColorProfiles.length > 0;
Type guard
const isProfileList = (v) => Array.isArray(v);
Try / catch
try { /* code that may assign app.printColorProfiles */ }
catch (e) { if (!/printColorProfiles is read-only/.test(e.message)) throw e; } Prevention
- Configure ICC profiles at the host print layer.
- Expect [] and feature-detect before print-profile logic.
- Never assign to print-related read-only properties.
When it happens
Trigger: Any assignment app.printColorProfiles = [...] in PDF JavaScript or caller code hits the throw at src/scripting_api/app.js:314.
Common situations: Print workflows trying to inject ICC profile lists; authors assuming undefined/empty implies writable.
Related errors
- app.printerNames 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/fcc51d9d4890b9e9.
Report an issue: GitHub.