2009-09-24

Force Redraw Adobe InDesign

An Adobe InDesign or Adobe InCopy user can press the key combination:
shift F5
to force redraw or update the display of the screen. This is good for removing screen artifacts or screen trash when the video display can't keep up with the user's changes. That won't help panels or palettes that aren't displaying correctly, but it does update the page(s) being displayed.
Some scripts can also make changes that the display cannot keep up with. For example, I was writing a script to alter the position of guides on a page and I thought it wasn't working. In reality, Adobe InDesign just didn't bother to redraw the screen to show the new position.
This function will force Adobe InDesign to redraw the screen by rapidly changing the view mode.


function forceRedraw () {
//-------------------------------------------------------------------------
//-- F O R C E R E D R A W
//-------------------------------------------------------------------------
//-- Generic: Yes for Adobe InDesign
//-------------------------------------------------------------------------
//-- Purpose: To force Adobe InDesign to redraw the screen when it
//-- won't on its own accord. In the GUI the user can press the
//-- Shift F5
//-- key combination to force a redraw, the the script interface
//-- doesn't have a similar function. This works to solve this for
//-- when a script alter's the document but the window doesn't
//-- properly indicate the change.
//-------------------------------------------------------------------------
//-- Arguments: None.
//-------------------------------------------------------------------------
//-- Calls: Nothing.
//-------------------------------------------------------------------------
//-- Returns: Nothing
//-------------------------------------------------------------------------
//-- Sample Use:
//-- forceRedraw() ;
//-------------------------------------------------------------------------
//-- Written: 2009.09.22 by Jon S. Winters of electronic publishing support
//-- eps@electronicpublishingsupport.com
//-------------------------------------------------------------------------
//-- Store and then clear the redraw preferences
var originalRedraw = app.scriptPreferences.enableRedraw ;
app.scriptPreferences.enableRedraw = false ;

//-- Store the original view setting. The view setting will be changed
//-- to force the redraw to happen.
var originalView = app.activeWindow.viewDisplaySetting ;
//-- If the view is anything but Optimized, switch to optimized. This is
//-- the view the greeks the display. It is FAST.
if ( originalView != ViewDisplaySettings.OPTIMIZED ) {
app.activeWindow.viewDisplaySetting = ViewDisplaySettings.OPTIMIZED ;
}
//-- Otherwise switch to Typical as it is the second fastest.
else{
app.activeWindow.viewDisplaySetting = ViewDisplaySettings.TYPICAL ;
}
//-- Return the window as it was found.
app.activeWindow.viewDisplaySetting = originalView ;

//-- Restablish the redraw settings
app.scriptPreferences.enableRedraw = originalRedraw ;
return ;
}
//

2 comments:

  1. Nice, Used this to speed up a Script i run to layout a catalog, and a mainly text listing of our books.

    Works like a charm. Cuts the script run time in half.


    I put the 1st half of your script at the top (didn't use it as a function) then the last part at the bottom, to return ReDraw and View back to original.

    We are using WoodWing SmartCatalog plug-in, and a script they developed.

    Thanks!

    ReplyDelete