Skip to main content
Lordrhavin
Inspiring
June 10, 2026
Question

AutoSizingTypeEnum... how to use?

  • June 10, 2026
  • 1 reply
  • 10 views

I have this simple script that fills a blank page with textframes:

 

function makeLorem(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
if (i>0 && Math.floor(Math.random() * 6) < 2)
result += " ";
else
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}

function getFrameContext() {
fc = {};
fc.doc = app.activeDocument;
fc.margins = fc.doc.pages[0].marginPreferences;
fc.w_idx = 0;
fc.h_pos = fc.margins.top;
fc.h_size = 0;
fc.addTextFrame = function(t) {
var productFrame = this.doc.textFrames.add();
productFrame.geometricBounds = [
this.h_pos,
this.margins.left + this.margins.columnsPositions[this.w_idx*2],
this.h_pos+20,
this.margins.left + this.margins.columnsPositions[this.w_idx*2+1]
];
productFrame.properties =
{
strokeWidth : 0,
fillColor : "None",
contents : t + ": "+ makeLorem(Math.floor(Math.random() * 200)+50),
autoSizingType: AutoSizingTypeEnum.HEIGHT_ONLY,
autoSizingReferencePoint: AutoSizingReferenceEnum.TOP_CENTER_POINT
};
productFrame.fit(FitOptions.APPLY_FRAME_FITTING_OPTIONS);
this.h_size = 20;
this.w_idx += 1;
if (this.w_idx >= this.margins.columnCount) {
this.w_idx = 0;
this.h_pos += this.h_size;
this.h_size = 0;
}
return productFrame;
};
return fc;
};

function main() {
var frameContext = getFrameContext();
for (var i=0; i<8; i++) {
frameContext.addTextFrame(i);
}
};

app.doScript(main,ScriptLanguage.JAVASCRIPT,[],UndoModes.ENTIRE_SCRIPT,'Insert-Frame-Test');

How can I get the autosizing to work? What I need to do...:

 

  • create a Textframe (works)
  • put it into the correct column and vertical offset (will work as soon as I figure out the next step)
  • have it set it’s height to fit the content
  • measure the height to get the h-position of the next text-frame.

Frame-fitting is set to AutoSizingTypeEnum.HEIGHT_ONLY but InDesign ignores that.

    1 reply

    rob day
    Community Expert
    Community Expert
    June 10, 2026

    Frame-fitting is set to AutoSizingTypeEnum.HEIGHT_ONLY but InDesign ignores that.

     

    Hi ​@Lordrhavin , Are you using the latest InDesign version? Seems like this is the same problem as your early post where ID 2025 and earlier does not include AutoSizingTypeEnum.HEIGHT_ONLY in its API: