Skip to main content
dublove
Legend
July 31, 2025
Answered

Is there a script for adding reference lines to columns?

  • July 31, 2025
  • 2 replies
  • 274 views

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

 

Correct answer rob day

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"});

2 replies

rob day
Community Expert
Community Expert
July 31, 2025

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});
};

 

dublove
dubloveAuthor
Legend
July 31, 2025

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?

 

 

rob day
Community Expert
Community Expert
July 31, 2025

You can get the active page with this:

 

var pg = app.activeWindow.activePage
Mike Witherell
Community Expert
Community Expert
July 31, 2025

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

Mike Witherell