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

Adjusting the frame width on a page in flowing text

Participant ,
Dec 21, 2024 Dec 21, 2024

Hi guys, 

Indesign has a flowing text and every time the frame needs to be reduced by a third of the left and right page. For example, after running the script, can it perform this reduction process from the point where I click with the mouse to the end of the page? (Note: Sometimes the opposite is needed. I need to spread the text all the way to the end of the page)

before.jpgafter.jpg

TOPICS
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

correct answers 1 Correct answer

Community Expert , Dec 22, 2024 Dec 22, 2024

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-flo
...
Translate
Community Expert ,
Dec 22, 2024 Dec 22, 2024

Is it not possible to add the text frames on the Parent Pages in this configuration and then reflow the text? 

 

Why is a script needed? What's your issue here, I'm not sure I fully understand what issue you're facing.

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 ,
Dec 22, 2024 Dec 22, 2024

Hi @Eugene Tyson 

Many times I have to use the same process in different situations. Thanks...

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 ,
Dec 22, 2024 Dec 22, 2024

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.

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 ,
Dec 22, 2024 Dec 22, 2024

Hi @m1b thank you very much

I want to do this. But sometimes this four-column page structure happens. It would be perfect if it was right aligned on even pages and left aligned on odd pages.

 

B1.jpgB2.jpg

 

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 ,
Dec 22, 2024 Dec 22, 2024

I've updated the script.

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 ,
Dec 22, 2024 Dec 22, 2024

Hi @m1b

Thank you very much. There is only a small problem with the even numbered page.

c1.jpg

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 ,
Dec 22, 2024 Dec 22, 2024

Yes! You found a bug. Fixed now and I've update the script above. - Mark

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 ,
Dec 22, 2024 Dec 22, 2024

@m1b

 

Tip: instead of creating a new TextFrame and just applying bounds - duplicate original one, clear contents, modify bounds - even by just modifying specific ones - then link together.

 

This way - you will preserve ALL formatting - incl. applied ObjectStyle and overrides - of the original TextFrame. 

 

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 ,
Dec 22, 2024 Dec 22, 2024

Good idea Robert. I decided not to, mainly because of text insets and the possible complexities.

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 ,
Dec 22, 2024 Dec 22, 2024
quote

Good idea Robert. I decided not to, mainly because of text insets and the possible complexities.


By @m1b

 

Not sure what do you mean by "complexities"?

 

And insets and the rest are very important - as they control how text will flow in this new TextFrame.

 

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
Guide ,
Dec 23, 2024 Dec 23, 2024

Just a question: if footnotes?

 

(^/)  The Jedi

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 ,
Dec 23, 2024 Dec 23, 2024
quote

Just a question: if footnotes?


By @FRIdNGE

 

Can you be more precise to which post you are replying?

 

Or just a wrong thread?

 

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
Guide ,
Dec 23, 2024 Dec 23, 2024

Just include footnotes in the layout and see the result!

 

(^/)

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 ,
Dec 23, 2024 Dec 23, 2024
LATEST
quote

Just include footnotes in the layout and see the result!

 

By @FRIdNGE

 

??? 

 

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 ,
Dec 22, 2024 Dec 22, 2024

@uniq1

 

Do you want to do this only by putting cursor in the specific place - or by selecting ParaStyle and automaticaly reformat whole Story / Document?

 

And when / why switching from 3x columns to 4x columns should happen? Or you want to decide each time? 

 

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 ,
Dec 22, 2024 Dec 22, 2024

Hi @Robert at ID-Tasker 

I want to intervene manually. It should be from where the cursor is. Thanks

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 ,
Dec 22, 2024 Dec 22, 2024
quote

Hi @Robert at ID-Tasker 

I want to intervene manually. It should be from where the cursor is. Thanks


By @uniq1

 

Do you work on a PC and are you open to a paid solution? 

 

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 ,
Dec 22, 2024 Dec 22, 2024

After reading all exchanges, it still seems to me that this need could be better handled by one or more Parent pages that have a split frame and guidelines for quick adjustment of either's width. Apply the page (with perhaps two or more configurations to choose from), adjust the frame heights, snap the narrow frame to the correct guideline... done. Given that manual adjustment is necessary, a script to do the first steps on the fly would gain little.

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