Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
// 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.");
}
Copy link to clipboard
Copied
That zooms from 100 to 80% on my machine.
Copy link to clipboard
Copied
And wasn't that the request? If you run the script 2 times it goes to 64% ....
Copy link to clipboard
Copied
Maybe I misunderstood, but I think they ment to zoom to 20%.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
That works as how I understood the question.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now