Determine current layout mode

Q: How can I determine the current LayoutMode set?

A: PSPDFKit.ViewState#layoutMode has three possible values. SINGLE, DOUBLE or AUTO. You can query the current value from the ViewState at any time.

In the case of PSPDFKit.LayoutMode.AUTO, you can query the DOM to determine if a single page or two pages are being rendered per spread.

const firstSpread = instance.contentDocument.querySelector(".PSPDFKit-Spread");
const count = firstSpread.querySelectorAll(".PSPDFKit-Page").length;

This has been tested on PSPDFKit for Web 2021.5.2.