Other PDF Issues

Use Acrobat JavaScript to Change a PDF’s Initial View

Anum MushtaqAnum Mushtaq Nov 19, 2026 868 views

Question details

Use PDF metadata to select an initial page layout and zoom with Acrobat JavaScript.

Change a PDF’s Initial View with Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF already contains metadata that should determine its initial page view when opened.
Observed behavior
The desired result is a document-level script that reads the metadata and applies the appropriate view settings.
Before you start

Open the PDF in Adobe Acrobat and check File > Properties > Description to identify the metadata field and value you want to use. Confirm that JavaScript is enabled in Acrobat’s preferences and that you can edit and save the PDF.

Solution 1Recommended

Add a metadata-based document-level script in Acrobat

Use this approach when the initial layout must change according to a PDF metadata value.

The example reads the Subject metadata field, sets zoom to 100%, and chooses SinglePage when the value is exactly single-page; otherwise, it chooses OneColumn. Replace Subject and the comparison value with the field and value used by your PDF.

The addScript method takes a script name and one script string. Use === for comparison rather than =, which assigns a value.

1
Inspect the metadata

In Acrobat, open File > Properties > Description and check the field and exact value that should control the layout.

2
Open the JavaScript console

Open Acrobat’s JavaScript console and enter: this.addScript("Initial view settings", 'var initialview = this.info.Subject;\nthis.zoom = 100;\nthis.layout = (initialview === "single-page") ? "SinglePage" : "OneColumn";');

3
Run and save the script

Execute the statement in the console, then use File > Save to save the document-level script in the PDF.

4
Test the initial view

Close and reopen the saved PDF in Acrobat. Check the zoom and layout, then test a PDF with a different metadata value if both branches are needed.

Add a metadata-based document-level script in Acrobat
Viewer behavior varies: Browser PDF viewers and other applications may ignore document JavaScript or initial-view settings. Acrobat security settings can also affect script execution.
Free Microsoft Office alternative

Read and manage PDFs alongside Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Open compatible files in one suite for an easy transition; use Acrobat when you need to create or test Acrobat-specific document JavaScript.

Open and read PDFs alongside your other documentsCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface makes it easier to move between office tasksFree, lightweight suite for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does my if statement always choose the same layout?

Check whether you used = instead of a comparison operator. For example, initialview === "single-page" compares the value, while initialview = "single-page" assigns it.

How many script strings can I pass to addScript?

Pass a script name and one script string to this.addScript. Combine the zoom and layout statements in that single string.

Where can I check the PDF metadata used by the script?

In Acrobat, open File > Properties > Description. The example uses this.info.Subject, so check the Subject field or change the script to use the appropriate metadata field.

Why doesn’t the initial view work in my browser?

Browser PDF viewers may ignore document JavaScript and initial-view settings. Close the browser view and open the saved PDF in Acrobat to test the script.

Can I automate this for multiple PDFs?

For a batch workflow in Acrobat Pro, investigate a customized Preflight fixup and an Action or Droplet. Test the workflow on representative PDFs before applying it to the full set.