Initial PDF Magnification Solutions
Can initial view magnification and layout settings be set with a script? Sure they can.
“But It's Not Documented In The JavaScript Reference Guide”
As I've previously outlined in the this newsletter, sometimes you have to think outside the box to craft a solution that the "experts" say is not possible. If there's no direct script in the guide, the question is often dismissed as "not possible". Stick with me and I'll outline the process for scripting the initial view settings. But first…
About Initial View Settings
The initial view settings are located in the initial view tab of the PDF document properties that can be accessed by pressing Ctrl + d.
Page layout and Magnification only work if users who open the PDF haven't customized their preferences to override these settings. If Page layout and Magnification are set to default, the application will open with the users' preferences under Edit > Preferences (Ctrl + k) > Page Display > Default Layout and Zoom.
If initial view zoom of the PDF is set to 100%, the zoom will be 100%. If the initial view zoom of the PDF is set to default, the zoom will be Fit Width when the user sets the default zoom to Fit Width as pictured above.
User Override Exception
Users can still override both the PDF document properties zoom and layout settings, as well as their own default settings by making a selection in the Accessibility category of the preferences:
Setting Initial View Document Properties With a Script
There's no direct script to set these document properties. However…
You can write a script to add pages to a PDF from another PDF file.
You can write a script to delete pages from a PDF file.
You can write a script to save a PDF file.
Do you see where this is going?
If you add pages to a PDF it doesn't change the initial view document properties. So…
Create a one-page PDF and set the initial view settings as desired.
Save the PDF and name it Initial View Settings (for this example).
Open the PDF for which you want to change the settings.
Execute scripts that…
Open the Initial View Settings PDF.
Insert all pages of the PDF after page 1 of the initial view settings PDF.
Delete page 1 of the initial view settings PDF.
Save the initial view settings PDF with a different name. In this example it will be saved to the same directory as the original PDF with an underscore added to the file name.
Close the original PDF.
The Script
var doc1=this;//define the open PDF
var doc2=app.openDoc("/C/Documents/Initial View Settings.pdf");//Step 4
doc2.insertPages(0,doc1.path,0,doc1.numPages-1);//Step 5
doc2.deletePages(0,0);//Step 6
doc2.saveAs(doc1.path.replace(".pdf","_.pdf"));//Step 7
doc1.closeDoc(true);//Step 8
The script can be run from the console, converted to a trusted function in a folder level script and executed from a custom menu item or toolbar button, or used in an Action to change the initial view settings on an entire batch of PDFs.
If using the script in an Action change the last line to close doc2 like this:
doc2.closeDoc(true);
If you try use a script to close the document the action is operating it will throw an error. The documents operated on in actions automatically close when the script is finished. In the save operation of the action select Do Not Save Changes.
It Turns Out You Don’t Need My Script After All
While doing research for this article and testing the Action Wizard I stumbled across an operation that you can use in the Action Wizard without any scripting to get the same result. I don’t believe this exercise was a waste of time because each line of the script teaches something that you may not have already know. And one of the main takeaways here is that a solution often requires digging deeper and thinking outside the box, even when the 'experts' give you a hard NO.
Changing The Initial Settings With The Action Wizard
One of the cool things about the Acrobat Pro Action Wizard is that you can modify the open PDF, or an entire batch of PDFs. Here’s how to change the initial settings using the Action Wizard, in screenshots.
Don’t forget to add a Save step.
Next week I’ll give you my top 10 tips for streamlining your PDF workflow in 2025. Until then, Merry Christmas and a Happy New Year.