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

Auto-size function doesn't work on linked text boxes with Data Merge

Explorer ,
Jul 11, 2023 Jul 11, 2023

Copy link to clipboard

Copied

I have two auto-size text boxes that are linked. Data merge field A sits in the top box, data merge field B sits in bottom text box. They are separated by a Coloumn Break set right after field A. The text boxes are auto resized correctly when holding the data merge fields but after merging, the top text box doesnt resize while the lower text box does. So one text box resizes to merged copy while the other doesnt. How can i fix this?

Thanks, JK 

TOPICS
Bug , How to

Views

213

Translate

Translate

Report

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 ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

Having a hard time digitising the workflow in my brain - can you provide images or a sample doc? 

 

Sorry - my 3D engine seems to be down

Votes

Translate

Translate

Report

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
Explorer ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

Sure - herewith. thanks JK

Votes

Translate

Translate

Report

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 ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

Hi Jacques:

 

In my experience, it doesn't work that way. If two frames aren't linked, both will adjust to fit the content.

 

If two (or more) frames are linked, only the last box will adjust even though the property is enabled for both, because the overflowing text in frame 1 just flows to the next box in the series.

 

~Barb

Votes

Translate

Translate

Report

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 ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

And that holds true with your examples. The top unthreaded frames adjust, the threaded frames only adjust the last frame.

 

Do they need to be threaded?

 

~Barb

Votes

Translate

Translate

Report

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
Explorer ,
Jul 19, 2023 Jul 19, 2023

Copy link to clipboard

Copied

Morning Barb, thanks for that.

The two text boxes will need to be linked for our purposes on this side. Always two text boxes, always two data merge field entries per merged document. But the Field A and Field B entries will differ wildly in length per merged document (they will be international translations from the english original) hence the need for the auto-sizing effect. So, In the linked text boxes, just after the Field A entry, there is a Column Break Character. By my reckoning, at merge, Indesign should pull in both entries from the CSV, notice that the Field A entry and the Field B entry need to be split into their separate text boxes (due to the Column Break Character) and then resize each text box individually. Thanks JK

Votes

Translate

Translate

Report

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 ,
Jul 19, 2023 Jul 19, 2023

Copy link to clipboard

Copied

I haven't looked at the files but tables will autosize if you have size set to at least 1.058mm I think is the min

 

So a table with 2 rows would change size depending on content, in theory

Votes

Translate

Translate

Report

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
Explorer ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Thanks Eugene - we need text boxes (angled, coloured and effected).

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Can you share an example - there may or may not be a workaround.

Votes

Translate

Translate

Report

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
Explorer ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

Example attached above - the working files are proprietary. thanks.

Votes

Translate

Translate

Report

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 ,
Jul 20, 2023 Jul 20, 2023

Copy link to clipboard

Copied

So sorry for asking for that twice - I didn't realise it was already provided, problem looking on the phone.

 

So I took a look at this.

It appears it first imports the text from the data merge, which then flows the text to the next frame - which is correct, in a way.

Then it auto expands the text frames - after the import of text

But at this stage the column break has already moved ot the 2nd frame due to the import of the data merged text.

 

In light of this - I can't think of a workaround that would make InDesign reorder the order it merges then expands. It can't expand the frame to fit as the text has not been imported, when it imports the text it flows, and then expands the text.

 

You're probably right when there's a frame break character then it should treat each line of the paragraph separately and expand the frame then move to the next line/frame and treat that separately.

 

I might be able to be scripted I don't know it's way beyond what I'm capable of.
Perhaps @Peter Kahrel @m1b @rob day  or other good scripters can help here.

Votes

Translate

Translate

Report

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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

LATEST

Hi @JacquesCapeTown (and @Eugene Tyson) here's one idea. I've written a script that just expands the width of any text frame marked with the script label "expandFrame" until the first paragraph fits. It won't always work, but it should work whenever the datamerge is expecting a single line paragraph. If you find a bug, let me know.

- Mark

 

demo.gif

 

/**
 * Expands width of text frames having label "expandFrame" in
 * an attempt to fit first paragraph of text frame in one line.
 * Notes:
 * - Label can contain other text as well as "expandFrame"
 * - Does not expand frame height
 * - Does not expand wider than the page width
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/auto-size-function-doesn-t-work-on-linked-text-boxes-with-data-merge/m-p/13950905
 */
function main() {

    if (app.documents.length > 0)
        expandFrames(app.activeDocument, /\bexpandFrame\b/i);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Expand Labelled Frames');


/**
 * Expand width of all text frames
 * in `doc` with matching label, in
 * attempt to fit first paragraph.
 * @author m1b
 * @version 2023-07-25
 * @param {Document} doc - an Indesign Document.
 * @param {RegExp} matcher - the regex to test each frame's label.
 */
function expandFrames(doc, matcher) {

    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

    var autoSizeRefToAnchorPoint = {
        1651467109: AnchorPoint.BOTTOM_CENTER_ANCHOR,
        1651469413: AnchorPoint.BOTTOM_LEFT_ANCHOR,
        1651470953: AnchorPoint.BOTTOM_RIGHT_ANCHOR,
        1668183154: AnchorPoint.CENTER_ANCHOR,
        1818583909: AnchorPoint.LEFT_CENTER_ANCHOR,
        1919509349: AnchorPoint.RIGHT_CENTER_ANCHOR,
        1953456997: AnchorPoint.TOP_CENTER_ANCHOR,
        1953459301: AnchorPoint.TOP_LEFT_ANCHOR,
        1953460841: AnchorPoint.TOP_RIGHT_ANCHOR,
    };

    var frames = doc.textFrames,
        inc = 1,
        frame,
        label,
        width,
        maxWidth,
        paragraph,
        end;

    for (var i = frames.length - 1; i >= 0; i--) {

        frame = frames[i];
        label = frame.label;
        width = (frame.geometricBounds[3] - frame.geometricBounds[1]);

        if (
            !label
            || !matcher.test(label)
        )
            continue;

        anchor = autoSizeRefToAnchorPoint[Number(frame.textFramePreferences.autoSizingReferencePoint)];
        paragraph = frame.paragraphs.firstItem();
        end = paragraph.characters.lastItem();

        // maxWidth is for reality testing
        if (frame.parentPage.isValid)
            maxWidth = frame.parentPage.bounds[3] - frame.parentPage.bounds[1];
        else
            maxWidth = doc.pages.firstItem().bounds[3] - doc.pages.firstItem().bounds[1];

        while (
            frame.id !== end.parentTextFrames[0].id
            && (width += inc) <= maxWidth
        )
            // expand the frame by a bit
            frame.resize(CoordinateSpaces.PARENT_COORDINATES, anchor, ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO, [inc, 0]);

    }

};

Votes

Translate

Translate

Report

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