Other PDF Issues

Show Selected PDF Pages in Two-Page View with Acrobat JavaScript

Amos GikundaAmos Gikunda Nov 19, 2026 868 views

Question details

Configure a PDF to switch to a two-page view for a selected middle section while using a different layout elsewhere.

Product
Adobe Acrobat
Device & OS
not provided
Scenario
A long PDF contains a section that should be displayed in two-page view when readers reach it.
Observed behavior
The desired layout changes when a selected page opens, with a different layout used outside the section.
Before you start

Open the PDF in an Acrobat version that supports editing page actions and has JavaScript enabled. Identify the physical page where the section begins; Acrobat JavaScript uses zero-based page indexes, which may differ from printed page labels.

Solution 1Recommended

Add an Acrobat page-open action to switch layouts

Use a page-open action to request a two-page layout when a reader reaches the start of the section.

The action changes the viewer layout when the specified page opens; it does not permanently assign a separate layout to that page. Viewer support and security settings can affect whether the script runs.

1
Open the JavaScript console

Open the PDF in Acrobat and choose Tools > JavaScript > JavaScript Debugger. The available menu names can vary by Acrobat version.

2
Set the page-open action

In the console, enter: this.setPageAction(350, "Open", "this.viewState = {pageViewLayoutMode:3};");. This targets the 351st physical page because page indexes start at zero. Replace 350 with the index for your section's first page.

3
Run and save

Select the statement in the console and run it using the debugger's execution command, then choose File > Save to save the page action in the PDF.

4
Test the transition

Navigate away from the target page and open it again. Check the layout in the Acrobat versions and viewing environments your readers use.

5
Plan the return layout

If the layout must change back, add another page-open action on a page outside the section using a layout value verified for your Acrobat environment. Test forward and backward navigation and direct jumps to pages.

Add an Acrobat page-open action to switch layouts
Page actions have limits: The starting action runs only when its page opens. A reader who jumps directly to another page in the section may not trigger it, and browser PDF viewers or other apps may ignore Acrobat JavaScript.
Free Microsoft Office alternative

Read PDFs and work with Office files in WPS Office

WPS Office is a free, lightweight, easy-to-use Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing files into your workflow. It can open PDFs, but it does not fix Acrobat-specific JavaScript page actions.

Open and read PDF documents alongside your other filesWork with Microsoft Office formats including DOCX, XLSX, and PPTXUse a familiar interface for an easier transition from Microsoft OfficeAccess free, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does the script use 350 for page 351?

Acrobat JavaScript page indexes start at zero, so index 350 refers to the 351st physical page. Check the physical page position rather than relying only on a printed page label.

Will the layout automatically switch back after the section?

No. The example only requests a layout change when the target page opens. Add and test a separate page-open action outside the section if you need to request a different layout.

What happens if a reader jumps into the middle of the section?

The action on the section's first page may not run if that page is skipped. Test direct navigation and consider where additional page actions are needed.

Will this JavaScript work in every PDF viewer?

No. Support for Acrobat JavaScript and page actions varies, and security settings can block scripts. Test the saved PDF in the Acrobat versions and other viewers your audience uses.