Skip to main content
Participating Frequently
November 17, 2022
Pregunta

How can I select objects across multiple pages and align center on each respective page in Indesign?

  • November 17, 2022
  • 5 respuestas
  • 3379 visualizaciones

Hello,

 

I'm creating a manual over 200 pages long with placed images in Indesign (version 18). I used the super handy script for that which is awesome. But now I'm trying to find out if there's a way to select all placed images and center align on each page. The worst-case scenario is manually select the image and align center and repeating that 200x. sounds egregious so hope someone has a better solution, perhaps a script that can execute and cut production time in half.

 

Your insight is most appreciated.

Thanks

sntm

Este tema ha sido cerrado para respuestas.

5 respuestas

Community Expert
November 17, 2022

Hi together,

I would say yes to Willi Adelberger's approach with an object style for position if there is only one image per page.

In case there are more one cannot use the object style, because all images on a page would share the same position. Also if you'd like to apply that object style to a group of graphic frames.

 

So a simple script could do this if the graphic frames are not positioned inside nested structures like groups.

Simply do a group of all graphic frames for every page and center the group on the page…

 

Regards,
Uwe Laubender
( Adobe Community Expert )

m1b
Community Expert
Community Expert
November 17, 2022

Hi @sntm, well here is a quick approach. - Mark

 

function main() {

    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

    var doc = app.activeDocument,
        items = doc.allGraphics;

    for (var i = 0; i < items.length; i++) {

        try {

            var item = items[i].parent,
                itemCenter = [item.geometricBounds[1] + (item.geometricBounds[3] - item.geometricBounds[1]) / 2, item.geometricBounds[0] + (item.geometricBounds[2] - item.geometricBounds[0]) / 2],
                page = item.parentPage,
                pageCenter = [page.bounds[1] + (page.bounds[3] - page.bounds[1]) / 2, page.bounds[0] + (page.bounds[2] - page.bounds[0]) / 2];

            item.move(undefined, [pageCenter[0] - itemCenter[0], 0]);

        } catch (error) { }

    }

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Center All Graphics');

 

Community Expert
November 17, 2022

@sntm said: "The worst-case scenario is manually select the image and align center and repeating that 200x. sounds egregious…"

 

Hi @sntm ,

this is faster done than writing a script for it; or looking for one on the web.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Community Expert
November 17, 2022
Willi Adelberger
Community Expert
Community Expert
November 17, 2022

When you have anchored them, the anchor paragraph style should have auto leadin and center the alignement.

If you have not anchored them, create an object style, in the section size and position options specify where you want to have the images. Apply that style to the images. You should work with object styles anyway.

m1b
Community Expert
Community Expert
November 17, 2022

I agree with @Willi Adelberger here. Objects styles are excellent for this. For example:

 

And here's a version of script that uses this approach:

function main() {

    var doc = app.activeDocument,
        items = doc.allGraphics,
        style = getByName(doc.allObjectStyles, 'Centered On Page');

    for (var i = 0; i < items.length; i++) {
        try {
            items[i].parent.appliedObjectStyle = style;
        } catch (error) { }
    }

    function getByName(styles, name) {

        for (var i = 0; i < styles.length; i++)
            if (styles[i].name == name)
                return styles[i];

    };

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Center All Graphics');

- Mark

sntmAutor
Participating Frequently
November 17, 2022

Thanks for the feedback. Leaning on the script solution but I'm not that tech savvy. How do I convert codes into jsx so I could add to Indesign script panel?

sntm