parallax/jsPDF · error · Error

Page mode must be one of UseNone, UseOutlines, UseThumbs, or

Error message

Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "{pmode}" is not recognized.

What it means

`setPageMode` (src/jspdf.js:917) sets how a PDF viewer displays the document (panels/thumbnails/fullscreen). It allows undefined/null (default) plus exactly `UseNone`, `UseOutlines`, `UseThumbs`, `FullScreen` — case-sensitive. It throws at src/jspdf.js:927 for any other value. This maps to the PDF spec's PageMode entry.

Source

Thrown at src/jspdf.js:928

  });

  API.__private__.getZoomMode = function() {
    return zoomMode;
  };

  var pageMode; // default: 'UseOutlines';
  var setPageMode = (API.__private__.setPageMode = function(pmode) {
    var validPageModes = [
      undefined,
      null,
      "UseNone",
      "UseOutlines",
      "UseThumbs",
      "FullScreen"
    ];

    if (validPageModes.indexOf(pmode) == -1) {
      throw new Error(
        'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' +
          pmode +
          '" is not recognized.'
      );
    }
    pageMode = pmode;
  });

  API.__private__.getPageMode = function() {
    return pageMode;
  };

  var layoutMode; // default: 'continuous';
  var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {
    var validLayoutModes = [
      undefined,
      null,
      "continuous",

View on GitHub (pinned to a3930ce03a)

Solutions

  1. Pass one of the exact PDF PageMode values: `'UseNone'`, `'UseOutlines'`, `'UseThumbs'`, `'FullScreen'` (note the capitalization).
  2. For the default, pass undefined/null or omit the call.
  3. Keep a constant map in your app so callers use tokens, not free strings.

Example fix

// before
 doc.setPageMode('fullscreen');

// after
 doc.setPageMode('FullScreen');
Defensive patterns

Strategy: validation

Validate before calling

var PAGE_MODES = ['UseNone','UseOutlines','UseThumbs','FullScreen'];
function safePageMode(m) {
  return PAGE_MODES.indexOf(m) !== -1 ? m : undefined;
}
var pm = safePageMode(userMode);
if (pm) doc.internal.__private__.setPageMode(pm);

Type guard

function isValidPageMode(m) {
  return m == null || ['UseNone','UseOutlines','UseThumbs','FullScreen'].indexOf(m) !== -1;
}

Try / catch

try {
  doc.internal.__private__.setPageMode(mode);
} catch (e) {
  if (/Page mode must be/.test(e.message)) {
    doc.internal.__private__.setPageMode('UseNone');  // safe default
  } else throw e;
}

Prevention

When it happens

Trigger: `doc.setPageMode('fullscreen')` (lowercase); `'useOutlines'`; `'FullPage'`; a value copied from a different library's API like `'single'` (that's a layout mode, not a page mode).

Common situations: Case mismatch from constants defined elsewhere; confusing page mode with layout mode (single/continuous); using viewer-specific terminology not in the PDF spec set.

Related errors


AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13). Data as JSON: /api/errors/4393e2cf99cff1d3. Report an issue: GitHub.