{"record":{"id":"52e1556403473c91","repo":"parallax/jsPDF","slug":"layout-mode-must-be-one-of-continuous-single-two","errorCode":null,"errorMessage":"Layout mode must be one of continuous, single, twoleft, tworight. \"{layout}\" is not recognized.","messagePattern":"Layout mode must be one of continuous, single, twoleft, tworight\\. \"(.+?)\" is not recognized\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":954,"sourceCode":"\n  API.__private__.getPageMode = function() {\n    return pageMode;\n  };\n\n  var layoutMode; // default: 'continuous';\n  var setLayoutMode = (API.__private__.setLayoutMode = function(layout) {\n    var validLayoutModes = [\n      undefined,\n      null,\n      \"continuous\",\n      \"single\",\n      \"twoleft\",\n      \"tworight\",\n      \"two\"\n    ];\n\n    if (validLayoutModes.indexOf(layout) == -1) {\n      throw new Error(\n        'Layout mode must be one of continuous, single, twoleft, tworight. \"' +\n          layout +\n          '\" is not recognized.'\n      );\n    }\n    layoutMode = layout;\n  });\n\n  API.__private__.getLayoutMode = function() {\n    return layoutMode;\n  };\n\n  /**\n   * Set the display mode options of the page like zoom and layout.\n   *\n   * @name setDisplayMode\n   * @memberof jsPDF#\n   * @function","sourceCodeStart":936,"sourceCodeEnd":972,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L936-L972","documentation":"`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).","triggerScenarios":"`doc.setLayoutMode('onepage')`; `'TwoColumnLeft'` (the spec name, not jsPDF's alias); `'scroll'`; `'continuous-scroll'`; any lowercase/typo variant of the allowed set.","commonSituations":"Using raw PDF-spec names (TwoColumnLeft/TwoPageRight) instead of jsPDF's aliases; viewer-specific layout strings; case typos.","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."],"exampleFix":"// before\n doc.setLayoutMode('TwoColumnLeft');  // spec name, throws\n\n// after\n doc.setLayoutMode('twoleft');","handlingStrategy":"validation","validationCode":"var LAYOUT_MODES = ['continuous','single','twoleft','tworight','two'];\nfunction safeLayoutMode(m) {\n  return LAYOUT_MODES.indexOf(m) !== -1 ? m : undefined;\n}\nvar lm = safeLayoutMode(userLayout);\nif (lm) doc.internal.__private__.setLayoutMode(lm);","typeGuard":"function isValidLayoutMode(m) {\n  return m == null || ['continuous','single','twoleft','tworight','two'].indexOf(m) !== -1;\n}","tryCatchPattern":"try {\n  doc.internal.__private__.setLayoutMode(layout);\n} catch (e) {\n  if (/Layout mode must be/.test(e.message)) {\n    doc.internal.__private__.setLayoutMode('continuous');  // safe default\n  } else throw e;\n}","preventionTips":["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."],"tags":["viewer","layoutmode","config","validation"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}