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

Custom zoom script

New Here ,
Mar 29, 2012 Mar 29, 2012

I found a script by Jongware at InDesign Secrets for fitting on a page and then zooming:

app.layoutWindows[0].zoom(ZoomOptions.FIT_PAGE);

try {app.layoutWindows[0].zoomPercentage = Number(app.activeScript.name.match(/\d+/)[0]);} catch (e) {};

I modified it to fit on the spread and then zoom:

app.layoutWindows[0].zoom(ZoomOptions.FIT_SPREAD);

try {app.layoutWindows[0].zoomPercentage = Number(app.activeScript.name.match(/\d+/)[0]);} catch (e) {};

It works great for my needs if no items are selected on the spread.  However, the problem is that when a frame(s) is selected it doesn't center the spread anymore.  The center point (vertically and horizontally) becomes the center of the frame or group of frames selected.  Would anyone know how to modify this script so that it it is frame selection independant?  Thanks.

TOPICS
Scripting
4.4K
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

correct answers 1 Correct answer

LEGEND , Mar 29, 2012 Mar 29, 2012

Isn't this a problem with the original script? InDesign centers the zooming around the current selection.

You can save the selection, clear it, and then restore it afterwards. Add at the beginning (untested):

var oldsel = app.selection;

app.select(null);

and at the end:

app.select(oldsel);

Translate
LEGEND ,
Mar 29, 2012 Mar 29, 2012

Isn't this a problem with the original script? InDesign centers the zooming around the current selection.

You can save the selection, clear it, and then restore it afterwards. Add at the beginning (untested):

var oldsel = app.selection;

app.select(null);

and at the end:

app.select(oldsel);

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
New Here ,
Mar 30, 2012 Mar 30, 2012

Thank you John.  Works great.

I'll add for anyone refering to this in the future that the name of the script sets the zoom level, ie...    zoom110.jsx will zoom to 100%

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
Guest
Apr 04, 2012 Apr 04, 2012

Don't you mean zoom110.jsx will zoom to 110% ?? (not 100%?)

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
New Here ,
Apr 04, 2012 Apr 04, 2012

Thanks Tom.  That's correct.

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
Contributor ,
Nov 11, 2013 Nov 11, 2013

Hello everyone,

Can anyone help extend the script so I can do this:

For example, I have 2 document windows open (one has a spread and one is a single page). I then I select 'arrange documents.' This will tile the windows and I can use this code to center and fit the document to the window.

for (i=0; i < app.layoutWindows.length; i++){

app.layoutWindows.zoom(ZoomOptions.FIT_PAGE) + app.layoutWindows.zoom(ZoomOptions.FIT_SPREAD);

}

I would like the window with a single page to match the zoom of the spread so they are all at the same zoom level.

Many thanks in advance.

gr

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 ,
Nov 11, 2013 Nov 11, 2013

This operation doesn't make any sense:

app.layoutWindows.zoom(ZoomOptions.FIT_PAGE) + app.layoutWindows.zoom(ZoomOptions.FIT_SPREAD);

.. how can you 'add' two commands together? I think what happens is that the first command is executed (fit page), then the next command (fit spread), and then the returned values are added up. This function does not return a value, so it basically adds "undefined" to "undefined" -- but that's okay, you never ask what the sum is anyway. And you end up with 'Fit spread'.

According to my CS4, the zoom percentage is the same for PAGE as for SPREAD. Makes sense too: the window height is the same, and since both the single page and the spread are taller than the window height, they both fit vertically. If you find it's different for you, then you'll (probably) need to compare the zoom percentage of PAGE and SPREAD and then use the smallest.

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
Contributor ,
Nov 11, 2013 Nov 11, 2013
LATEST

Thanks Jongware,

I'm at the kludging level of JS and thought "+" was a "&" from Applescript ^_^

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