parallax/jsPDF · error · Error
Layout mode must be one of continuous, single, twoleft, twor
Error message
Layout mode must be one of continuous, single, twoleft, tworight. "{layout}" is not recognized. What it means
`setLayoutMode` (src/jspdf.js:942) sets the viewer's page layout. The allowed values (plus undefined/null) are `continuous`, `single`, `twoleft`, `tworight`, and `two` — case-sensitive. It throws at src/jspdf.js:953 for anything else. These map to the PDF spec's PageLayout entry (e.g. TwoColumnLeft → twoleft).
Source
Thrown at src/jspdf.js:954
API.__private__.getPageMode = function() {
return pageMode;
};
var layoutMode; // default: 'continuous';
var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {
var validLayoutModes = [
undefined,
null,
"continuous",
"single",
"twoleft",
"tworight",
"two"
];
if (validLayoutModes.indexOf(layout) == -1) {
throw new Error(
'Layout mode must be one of continuous, single, twoleft, tworight. "' +
layout +
'" is not recognized.'
);
}
layoutMode = layout;
});
API.__private__.getLayoutMode = function() {
return layoutMode;
};
/**
* Set the display mode options of the page like zoom and layout.
*
* @name setDisplayMode
* @memberof jsPDF#
* @functionView on GitHub (pinned to a3930ce03a)
Solutions
- Use jsPDF's aliases exactly: `'continuous'`, `'single'`, `'twoleft'`, `'tworight'`, `'two'`.
- Map spec/viewer vocabulary to these aliases in a config layer.
- For default, pass undefined/null or omit the call.
Example fix
// before
doc.setLayoutMode('TwoColumnLeft'); // spec name, throws
// after
doc.setLayoutMode('twoleft'); Defensive patterns
Strategy: validation
Validate before calling
var LAYOUT_MODES = ['continuous','single','twoleft','tworight','two'];
function safeLayoutMode(m) {
return LAYOUT_MODES.indexOf(m) !== -1 ? m : undefined;
}
var lm = safeLayoutMode(userLayout);
if (lm) doc.internal.__private__.setLayoutMode(lm); Type guard
function isValidLayoutMode(m) {
return m == null || ['continuous','single','twoleft','tworight','two'].indexOf(m) !== -1;
} Try / catch
try {
doc.internal.__private__.setLayoutMode(layout);
} catch (e) {
if (/Layout mode must be/.test(e.message)) {
doc.internal.__private__.setLayoutMode('continuous'); // safe default
} else throw e;
} Prevention
- Use jsPDF's aliases, not the raw PDF-spec names.
- Map spec/viewer vocabulary to the alias set in config.
- Use undefined/null for the default rather than guessing a token.
When it happens
Trigger: `doc.setLayoutMode('onepage')`; `'TwoColumnLeft'` (the spec name, not jsPDF's alias); `'scroll'`; `'continuous-scroll'`; any lowercase/typo variant of the allowed set.
Common situations: Using raw PDF-spec names (TwoColumnLeft/TwoPageRight) instead of jsPDF's aliases; viewer-specific layout strings; case typos.
Related errors
- zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%
- Page mode must be one of UseNone, UseOutlines, UseThumbs, or
- Invalid unit: {unit}
- Invalid format: ${format}
- Invalid arguments passed to PubSub.subscribe (jsPDF-module)
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/52e1556403473c91.
Report an issue: GitHub.