Hi @uniq1, here is a quick script for it. See if it works for you. First put your cursor somewhere in the paragraph where you want to split and run script.
- Mark
/**
* @file Indent Split Text Frame.js
*
* Place cursor in text and script will split
* into two text frames, the second one indented
* up until the next margin column position.
*
* @author m1b
* @version 2024-12-23
* @discussion https://community.adobe.com/t5/indesign-discussions/adjusting-the-frame-width-on-a-page-in-flowing-text/m-p/15052834
*/
function main() {
var settings = {
addFrameBreakCharacter: false,
overlap: 0,
}
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
const OVERLAP = settings.overlap,
TOLERANCE = 0.01;
var doc = app.activeDocument,
item = doc.selection[0];
if (!item || !item.isValid)
return alert('Please place text cursor into your text and try again.');
if (
!item.hasOwnProperty('paragraphs')
|| !item.hasOwnProperty('parentTextFrames')
)
return alert('Please place your cursor into text frame and try again.');
var frame = item.parentTextFrames[0],
oldFrameBounds = frame.geometricBounds.slice(),
newFrameBounds = oldFrameBounds.slice(),
page = frame.parentPage;
if (!page.isValid)
return alert('Text Frame is no on a page.');
// the place where the frame will split
var splitHeight = item.paragraphs[0].characters[0].baseline - item.paragraphs[0].characters[0].ascent;
oldFrameBounds[2] = splitHeight + OVERLAP;
newFrameBounds[0] = splitHeight;
if (page.marginPreferences.columnsPositions.length <= 2)
return alert('This page has no margin columns.');
var x,
i,
columnFound;
if (PageSideOptions.RIGHT_HAND === page.side) {
// loop over the column positions, right to left
for (i = page.marginPreferences.columnsPositions.length - 3; i >= 0; i = i - 2) {
x = page.bounds[1]
+ page.marginPreferences.left
+ page.marginPreferences.columnsPositions[i];
if (x + TOLERANCE < frame.geometricBounds[3]) {
newFrameBounds[3] = x;
columnFound = true;
break;
}
}
}
else {
// loop over the column positions, left to right
for (i = 2; i <= page.marginPreferences.columnsPositions.length; i = i + 2) {
x = page.bounds[1]
+ (doc.documentPreferences.facingPages ? page.marginPreferences.right : page.marginPreferences.left)
+ page.marginPreferences.columnsPositions[i];
if (x - TOLERANCE > frame.geometricBounds[1]) {
newFrameBounds[1] = x;
columnFound = true;
break;
}
}
}
if (!columnFound)
// no columns available
return;
if (settings.addFrameBreakCharacter)
// insert a frame break
item.paragraphs[0].insertionPoints[0].contents = SpecialCharacters.FRAME_BREAK;
var newFrame = page.textFrames.add({ geometricBounds: newFrameBounds });
frame.geometricBounds = oldFrameBounds;
frame.nextTextFrame = newFrame;
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Indent Split Text Frame');
Edit 2024-12-22: added handling of right-hand pages, as per comment below.
Edit 2024-12-23: fixed bug in handling left-hand facing page, as per comment below.