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

  1. Read app.printColorProfiles only; expect [].
  2. Configure color profiles through the host print pipeline, not the scripting API.
  3. 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

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


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