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

How to automatically add horizontal line between images

Participant ,
Jan 20, 2023 Jan 20, 2023

I have columns of placed graphics that I would like to add a horizontal line between, much like adding a vertical line between columns using Text Frame Options or the Object Style Optons dialog.

 

I have looked for a script with no luck and I can't seem to figure out if object styles will apply a horizontal line only between objects.

Any ideas would be greatly appreciated.

TOPICS
EPUB , How to , Import and export , Print , Scripting , UXP Scripting
1.2K
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 ,
Jan 20, 2023 Jan 20, 2023

I'm not sure this can be done with any ID feature other than drawing a rule under each frame... which might be scriptable. The only features to add either a rule above/below, or a border that's zero on three sides, is in Paragraph Styles, so I am not sure there's anything to leverage there, either — it would have to be a script to draw a rule of X dimensions.

 

But maybe I'm missing something that would make it easier.

 

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 ,
Jan 20, 2023 Jan 20, 2023

You could use paragraph rules if the images are placed as anchored objects...

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 ,
Jan 20, 2023 Jan 20, 2023

I thought of that, but it's only a half-step of "automation" with a fair amount of layout effort required.

 

There are any number of approaches to get IMAGE-LINE-IMAGE. But all those I can think of require it to be a largely manual process, with or without a little help from things such as paragraph and object styles.

 

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 ,
Jan 20, 2023 Jan 20, 2023

You could find an anchored object insertion, then add a new paragraph with a paragraph rule style, with F/C

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 ,
Jan 20, 2023 Jan 20, 2023

Or add an underline to the object's containing pstyle. 

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 ,
Jan 20, 2023 Jan 20, 2023

Are the placed graphics anchored in a text flow, or standalone?

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
Participant ,
Jan 20, 2023 Jan 20, 2023

At present all items are standalone.

 

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 ,
Jan 20, 2023 Jan 20, 2023

Something like this could work. 

var d = app.activeDocument;
var allgs = d.allGraphics;
var i = allgs.length;
var os = d.objectStyles.itemByName("LineObj");
var offset = 3;
var r, gb, l, p;
while(i--) {
    p = allgs[i].parent;
    gb = p.geometricBounds;
    l = p.graphicLines.add(undefined, undefined, undefined, {appliedObjectStyle: os});
    l.geometricBounds = [gb[2] + offset, gb[1], gb[2] + offset, gb[3]];
}

 

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 ,
Jan 21, 2023 Jan 21, 2023

I have named my object style "LineObj" and I've selected the 5 placed images that I have applied the object style to, but when I run the script nothing occurs. Any hints or direction you can impart is greatly appreciated.

 

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 ,
Jan 21, 2023 Jan 21, 2023
LATEST

The object style is for the line object. If you need a way to target specific frames, then give them a different object style, and run this:

 

var d = app.activeDocument;
var allgs = d.allGraphics;
var i = allgs.length;
var os = d.objectStyles.itemByName("LineObj");
var offset = 3;
var r, gb, l, p;
while(i--) {
    p = allgs[i].parent;
    if (p.appliedObjectStyle.name !== "YourOtherName") { continue; } 
    gb = p.geometricBounds;
    l = p.graphicLines.add(undefined, undefined, undefined, {appliedObjectStyle: os});
    l.geometricBounds = [gb[2] + offset, gb[1], gb[2] + offset, gb[3]];
}

 

Check your layers panel for the image rectangles, and see if there is a line object attached. 

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
LEGEND ,
Jan 20, 2023 Jan 20, 2023

You could set up a table to contain the images, and set borders only on the strokes between frames.

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 ,
Jan 20, 2023 Jan 20, 2023

Given the subsequent issues of getting tables to flow across pages, I'd say the better solution is something attached to the anchor paragraph style. If the existing work doesn't use anchored frames, it will take some time to go through and anchor each to a specific paragraph style... but once that's done, it will be easy to experiment with that style to achieve the desired effect. I'd suggst Rule Below is the right approach, and for bottom (of page, or stack) images, a secondary style that has no rule below.

 

But pretty much every good solution has to start with the image frames cleanly anchored to a specific para style, and a good object style definition wouldn't hurt.

 

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 ,
Jan 20, 2023 Jan 20, 2023

"You could set up a table to contain the images, and set borders only on the strokes between frames."

I thought the same. I did a test now creating a 1x1 table with border only on the bottom and it worked well, but the whole idea of it is a bit unwieldy. Might be time for a feature request to add such borders to Object Styles!!

Screen Shot 2023-01-20 at 2.22.07 PM.png

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