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

Script or utility that sets or recalls view options in multiple documents

Engaged ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

I'm wondering if there are any scripts or tricks available for the following scenario. I've tried googling but haven't found anything – of course that could mean I'm just not using the right search terms.

 

I often have 10 to 15 documents open at a time, all relatively similar but distinct, discrete documents. When I want to do large scale editing across them all, I have to go to each one, put them in 'normal mode', choose whether or not to show baselines, text threads, ruler, grids etc. etc.

 

In an ideal world, I could set up my chosen 'view style' in one document, and apply that to every open document with a script – has anyone written anything like that? Or perhaps, is there anything that offers recall of a 'view setup template' so you can recall a specific set of options without having to go through 5 or 6 shortcuts for each open document?

TOPICS
How to , Scripting

Views

103

Translate

Translate

Report

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 ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

Hi @MrZZY, I wrote this script a while ago to do a similar thing to what you want. Perhaps you can try it out and modify it to suit your exact needs? The idea is that you set one document's view how you want it and run the script, and it will try to set all the other open document's views to match the "master" view. See how you go.

- Mark

 

app.doScript(synchronizeAllActiveViews, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Do Script');


/**
 * Attempts to synchronize active views of all documents.
 * (Sets all document views to match the active view.)
 * @author m1b
 * @version 2022-01-07
 */
function synchronizeAllActiveViews() {

    var masterDoc = app.activeDocument;
    var docs = app.documents;

    // first center and zoom master document
    // (because Indesign doesn't let me move the view!)
    var zoom = masterDoc.layoutWindows[0].zoomPercentage;
    masterDoc.layoutWindows[0].transformReferencePoint = AnchorPoint.CENTER_ANCHOR;
    masterDoc.layoutWindows[0].zoom(ZoomOptions.FIT_PAGE);
    masterDoc.layoutWindows[0].zoomPercentage = zoom;

    // apply to each open document
    for (var i = 0; i < docs.length; i++)
        if (docs[i] != masterDoc)
            applyView(docs[i], masterDoc);

};

/**
 * Apply a `masterDoc`s view to `doc`.
 * @author m1b
 * @version 2022-01-07
 * @param {Document} doc - the target view Document.
 * @param {Document} masterDoc - the source view Document.
 */
function applyView(doc, masterDoc) {

    var view = doc.layoutWindows[0],
        masterView = masterDoc.layoutWindows[0],
        guidePrefs = doc.guidePreferences,
        masterGuidePrefs = masterDoc.guidePreferences;

    view.activePage = doc.pages.itemByName(masterView.activePage.name);
    view.overprintPreview = masterView.overprintPreview;
    view.screenMode = masterView.screenMode;
    view.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;
    view.viewDisplaySetting = masterView.viewDisplaySetting;
    view.zoom(ZoomOptions.FIT_PAGE);
    view.zoomPercentage = masterView.zoomPercentage;

    guidePrefs.guidesShown = masterGuidePrefs.guidesShown;
    guidePrefs.guidesLocked = masterGuidePrefs.guidesLocked;
    guidePrefs.guidesInBack = masterGuidePrefs.guidesInBack;

};

Votes

Translate

Translate

Report

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 ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

LATEST

Thanks so much for this, this almost does exactly what I was asking and is very instructive. From the upvotes, and the fact that you've written something so close to my original description, it's something in need of a wider solution that could be adapted easily for everyone.

I'm going to try, as you suggested, to adapt this!

Votes

Translate

Translate

Report

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