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

Automate view

Engaged ,
Dec 16, 2019 Dec 16, 2019

Does anyone know of a way to automate switching to a particular page, at a particular zoom, at a particular location. I have thousands of similar documents and sometimes it would be nice to be able to just hit a keystroke that opened at a particular view of, for example, the index at a particular zoom and place (always p.3 for many of my docs).

 

 

TOPICS
Scripting
969
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

Community Expert , Dec 17, 2019 Dec 17, 2019

Hi zimbop,

let's tackle the particular location issue for the zoom.

 

My idea is to use a unique object in the document, e.g. a rectangle with a unique name, that a script can select and zoom to. Let's say the name of that zoom item should be ZoomCenter.

 

Best draw out a rectangle on the page you want to zoom to. Could be any size.

Rename the rectangle in the Layers panel to ZoomCenter.

 

The script code below will identify it by its name, selects it and zooms to it. Then it will be deselected.

...
Translate
Community Expert ,
Dec 16, 2019 Dec 16, 2019

What is the output format?

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
Engaged ,
Dec 16, 2019 Dec 16, 2019

Not output > Screen. Literally, the view. Quickly setting up a bunch of documents that are all set to view at page 4 at a particular zoom in a particular place.

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 ,
Dec 16, 2019 Dec 16, 2019

Within InDesign, Command/Control J takes you to the page you select and there are various zoom commands, such as Command/Control 0 to Fit Page to Window.

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
Engaged ,
Dec 16, 2019 Dec 16, 2019

Thanks Derek! I can't believe I didn't know such a simple keystroke. That will certainly help toward a quickeys/macro solution to this issue (in the absense of better "fit" commands, which are pretty basic). As is often the case with these things, not everyone needs the sort of specific options you find yourself needing! 

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 ,
Dec 16, 2019 Dec 16, 2019

You could also script the zoom and page together. This AppleScript (OSX only) would zoom into page 4 at 200%. You could edit the percentage and page number to your needs. Scripts can be assigned key commands:

 

 

tell application "Adobe InDesign CC 2018"
	set properties of active window to {zoom percentage:200, active page:page 4 of active document}
end tell

 

 

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 ,
Dec 17, 2019 Dec 17, 2019

Hi zimbop,

let's tackle the particular location issue for the zoom.

 

My idea is to use a unique object in the document, e.g. a rectangle with a unique name, that a script can select and zoom to. Let's say the name of that zoom item should be ZoomCenter.

 

Best draw out a rectangle on the page you want to zoom to. Could be any size.

Rename the rectangle in the Layers panel to ZoomCenter.

 

The script code below will identify it by its name, selects it and zooms to it. Then it will be deselected.

 

Suggestion: You could put the zoom item named ZoomCenter to an extra layer.

Even if you lock the layer the zoom item can be selected by the script.

Even if you set the layer to invisible the zoom item can be selected by the script.

Even if you lock the zoom item the script will work.

Even if you make the item invisible the script will work.

 

The code below is written in ExtendScript ( JavaScript ) and should work with all versions of InDesign after CS4.

To change the zoom percentage value just edit the number in the line:

var zoomToPercentage = 200 ;

 

If you want to use a different name for your zoom item, rename the object in the Layers panel and use exactly the same name in the code where it says:

var zoomItemName = "ZoomCenter";

 

 

How to work with ExtendScript code see e.g. here:

http://www.indiscripts.com/pages/help#hd0sb2

 

/**
* @@@BUILDINFO@@@ ZoomToSelectedObjectOnPage-using-activeSpread.jsx !Version! Tue Dec 17 2019 15:34:39 GMT+0100
*/

/*
	Written by Uwe Laubender
	Posted at Adobe InDesign Forum at:
	
	Automate view
	zimbop, Dec 16, 2019
	https://community.adobe.com/t5/indesign/automate-view/td-p/10805230
	
	What does the script do?
	It zooms to an object in the INDD document that has a unique name.
	
	The object could be anything that could be named in the Layers panel.
	A graphic frame, a text frame, a graphic line etc. pp.
	
	The object should not be grouped, anchored or nested otherwise.
	Script works with InDesign CS5 version 7 and above.
	
*/

( function()
{
	// TYPE A DIFFERENT VALUE OF ZOOM BELOW:
	var zoomToPercentage = 200 ;
	
	// IF YOU WANT TO CHANGE THE NAME OF THE OBJECT DO IT ALSO HERE:
	var zoomItemName = "ZoomCenter";
	
	
	
	// BEST DO NOT EDIT CODE BELOW.
	
	var min = 5 ;
	
	// Because of a bug we cannot zoom by script to maximum 4000%
	var max = 2000 ; 
	
	// If zoom percentage is out of range, do nothing:
	if( zoomToPercentage < min || zoomToPercentage > max ){ return };
	
	// If no document is open, do nothing:
	if( app.documents.length == 0 ){ return };
	
	var targetDoc = app.documents[0];
	var zoomItem = targetDoc.pageItems.itemByName( zoomItemName );
	
	// If there is no zoom item found, do nothing:
	if( !zoomItem.isValid ){ return };
	
	var zoomItemLockedState = zoomItem.locked ;
	var zoomItemVisibleState = zoomItem.visible ;

	var targetSpread = zoomItem.parent;

	// Make the spread of the target page the active spread:
	targetDoc.layoutWindows[0].activeSpread = targetSpread ;
	
	zoomItem.locked = false ;
	zoomItem.visible = true ;
	
	// Select the zoom item by script:
	// NOTE: Possible even if the layer of the item is locked!
	// NOTE: Possible even if the layer of the item is set to invisible!
	targetDoc.select( zoomItem );

	// Apply the zoom value:
	targetDoc.layoutWindows[0].zoomPercentage = zoomToPercentage ;
	
	// Deselect everything:
	targetDoc.select( null );
	
	// Reset the values for locked and visible to the item:
	zoomItem.locked = zoomItemLockedState ;
	zoomItem.visible = zoomItemVisibleState ;

}() )

 

Regards,
Uwe Laubender

( ACP )

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
Engaged ,
Dec 17, 2019 Dec 17, 2019

I'll have a good look at this - thanks Uwe!

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
Engaged ,
Dec 17, 2019 Dec 17, 2019

Very useful as is, thanks so much for taking the time! It would be great to be able to set focal point as centre or top left, but I'm guessing that 'top left' of the object is not addressable by script. Marking as correct answer as I'm guessing this is the closest that we can get to the hardest part of the problem stated. Thanks all.

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 ,
Dec 17, 2019 Dec 17, 2019

Hi zimbop,

of course one could add functionality to this script.

But this would require some time and effort.

A GUI and a preferences file etc. etc. And a way to record where you were coming from before executing the zoom script so that you can easily toggle.

 

For now you could do a very small rectangle as zoom item so if InDesign zooms to the center of the selection you could nearly pinpoint the center of the zoom if you like.

 

Oh. And if your screen estates allows you can open a second layout window of the same document and zoom to your favored  spot so that you have both views side by side. All without using a script at all.

 

Regards,
Uwe Laubender

( ACP )

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
Engaged ,
Dec 17, 2019 Dec 17, 2019
LATEST

Ah yes, excellent point about the smaller rectangle! Thanks so much. I'd really like to be able to create and extend smaller tasks like this with scripting myself. Very inspirational. Thanks again.

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