Skip to main content
dublove
Legend
Jul 31, 2025 5:09 AM UTC
Answered

Is there a script for adding reference lines to columns?

When there are many columns, dragging them can be a bit troublesome.
I want to automatically generate column lines.

 

rob day
rob dayCorrect answer
Community Expert
Aug 21, 2025 3:08 PM UTC

I Got it.
Need to set:
app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

But,I don't know how to add reference lines that extend beyond the page.


But,I don't know how to add reference lines that extend beyond the page.

 

See my first reply. You would have to get an existing guide or set a new guide—this makes a new guide that extends onto the pasteboard

 

//active page
var pg = app.activeWindow.activePage
var l = app.activeDocument.layers
//add a horizonal guide at 2 inches to the top layer of the active page
pg.guides.add(l[0], {orientation:HorizontalOrVertical.horizontal, fitToPage:false, location:"2in"});

7 replies

rob day
Community Expert
Community Expert
Jul 31, 2025 1:15 PM UTC

You can get column positions and add guides like this:

 

//page 1
var pg = app.activeDocument.pages[0]
//the page’s column postions as a array
var ca = pg.marginPreferences.columnsPositions;
//the left margin position
var lm = pg.marginPreferences.left
//add vertical guides at each column position
for (var i = 0; i < ca.length; i++){
    pg.guides.add(app.activeDocument.layers[0], {orientation:HorizontalOrVertical.vertical,location:ca[i]+lm});
};

 

Translate
dublove
dubloveAuthor
Legend
Jul 31, 2025 3:12 PM UTC

I want to add it to the current page or the home page.
Do I have to select an object to get parentPage?

Is there a currentSelectPage function?

 

 

Translate
rob day
Community Expert
Community Expert
Jul 31, 2025 4:11 PM UTC

You can get the active page with this:

 

var pg = app.activeWindow.activePage
Translate
Mike Witherell
Community Expert
Community Expert
Jul 31, 2025 12:30 PM UTC

Layout > Margins and Columns will generate/adjust them quickly.

and if you want to add Guides over the margins and columns, then...

Layout > Create Guides

Translate
Mike Witherell