Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating zoom shortcut

Participant ,
Jun 30, 2025 Jun 30, 2025

How can I create a action or a key which can zoom out the document to a specific percentage (say 20%) whenever I press them?

TOPICS
Feature request , How-to , Scripting
177
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Participant ,
Jun 30, 2025 Jun 30, 2025

// Riduci lo zoom corrente del 20%

if (app.documents.length > 0) {
var doc = app.activeDocument;
var currentZoom = doc.views[0].zoom; // valore in scala (es. 1.0 = 100%)

var newZoom = currentZoom * 0.8; // riduci del 20%
doc.views[0].zoom = newZoom;

//alert("Zoom ridotto del 20%");
} else {
alert("Nessun documento aperto.");
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2025 Jun 30, 2025

That zooms from 100 to 80% on my machine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 30, 2025 Jun 30, 2025

And wasn't that the request? If you run the script 2 times it goes to 64% ....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2025 Jun 30, 2025

Maybe I misunderstood, but I think they ment to zoom to 20%.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2025 Jun 30, 2025

In case you want to set an absolute zoom level, you can use this javascript snippet to always go to 20 %:

 

// Absolute Zoom level: 20 %
if (app.activeDocument) {
    app.activeDocument.views[0].zoom = 0.2;
}

 

You can incorporate it into an action and assign a keyboard shortcut to the action.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2025 Jun 30, 2025
LATEST

That works as how I understood the question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines