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

Data Merge with Fit Text To Frame.

Community Beginner ,
May 18, 2018 May 18, 2018

I have a document with DataMerge content going onto it. There is a specific space where the "Company Name" is supposed to go. I created a text box, added the field I wanted. but the amount of characters vary from 5 - 60 characters including spaces. I need the text to resize and fit the frame properly for each record. Is there a script or something im missing that could solve this issue? I found a script that works on 1 entyry of the data, but if I click to the next entry, it oversets, or gets smaller than the box.

I have tried setting this up with GREP styles but this was ultimately unsuccessful.

12.4K
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

People's Champ , May 23, 2018 May 23, 2018

Hi Allan,

Sorry to hear the trial didn't work for you.

I'd be very happy to see what went wrong and fix it up! The script is in use by many companies, including some who have incorporated it into their automated InDesign server routines.

Please feel free to get in touch. I'm sure it's something that will not take long to fix: admin [at] id-extras.com

Thanks,.

Ariel

Translate
Community Expert ,
May 19, 2018 May 19, 2018

Hi Allan,

you definitely need a script for this.

And you would run it on the result of a data merge action.

You said you already have one. Could you post the link to it or the script code so that someone can look into it?

You also could ask the author of the script to write a special version for exactly your purposes.

Regards,
Uwe

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 Beginner ,
May 21, 2018 May 21, 2018

http://in-tools.com/article/scripts-blog/fun-with-text-fitting-in-indesign/

The script here is what was tried but did not work as well. I believe someone mentioned in a comment there on the page asking to get it to work with Data Merge but I did not see anything showing that it was re-written to work that way.

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
Advocate ,
May 19, 2018 May 19, 2018

See screenshot, Allan. Would this solve your problem? (Object > Tex Frame Options > Auto-Sizing)Text_Frame_Options.jpg

Here's a link to an article from InDesign Magazine you also might find useful: https://indesignsecrets.com/keeping-long-fields-text-line-data-merge.php

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 Beginner ,
May 21, 2018 May 21, 2018

Hello Scott,

I have tried this method and it did not seem to work properly.

Thank you for trying to help!

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 ,
May 19, 2018 May 19, 2018

create the Object Style for these fields with these settings:

Text Frame auto-size options -> Height Only (or Height & With), Anchor Point left-center, No Line Break.

Your fields will change their size from record to record due to their content size.

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 ,
May 19, 2018 May 19, 2018

Hi Anna,

that would not scale the frame, it would only change the size ( width and height ) of the frame and that would lead to overflow.

As I understand the question the text size should change together with leading to fit a frame of a distinct size.

If we had an auto-size feature for scaling it would work as you expect. Together with the automatic frame fitting option Scott is suggesting.

Regards,
Uwe

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 ,
May 19, 2018 May 19, 2018

Hi Uwe,

maybe it was my misunderstanding, but I don't see any request for leading, just for the characters amount. So I would wait for the author's response.

Actually, I hope to see the screenshot with the text boxes shown to clear the situation.

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
Explorer ,
Jan 04, 2019 Jan 04, 2019
LATEST

Maybe read his post again, he want to fit text to a maximum width frame, not fit frame to the text.

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 ,
May 19, 2018 May 19, 2018

I think the OP may have tried my "square peg round hole" technique using GREP styles to catch lines over a certain length and reduce the size if the type:

https://colecandoo.com/2012/02/18/square-pegs-now-fit-into-round-holes/

However, there are a couple of scripts that have been made available that allow text to fit a given frame, rather than expanding the frame to fit the text. One is offered free by In-Tools, the other is available for purchase from In-Extras:

http://in-tools.com/article/scripts-blog/fun-with-text-fitting-in-indesign/

http://www.id-extras.com/products/fit-text-to-frame

A similar question was also asked some time ago on the forums that may provide some assistance:

A script for adapting text to frame

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
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 Beginner ,
May 21, 2018 May 21, 2018

the ID-Extras was the only one I did not attempt. The trial was very watered down and just did not work. Because I this would be paid through the company I work for, we have not gone over if we would try it or not, and since the trial didnt seem to work at all, it doesnt seem like something we will be attempting.

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 ,
May 23, 2018 May 23, 2018

OK, I think I have a solution. First thing to do - the text frame that contains the text that needs to "autofit" - in the layers panel, name the appropriate item "fitText".

Screen Shot 2018-05-23 at 21.32.21.png

Run the Data Merge to a new ID file and then run the following script. It is based on the last link that I provided in my first post, but I've corrected some of the loops. There's some lines that could come out, but try this for now:

#target-indesign;

var document = app.activeDocument;

var items = document.allPageItems;

var textFrame = new Array;

for(i = 0; i < items.length; i++)

{

    if(items.name == "fitText")

    {

        textFrame.push(items);

    }

}

for (j = 0; j < textFrame.length; j++)

{

    var minimumHorizontalScale = 50;

    var horizontalScale = textFrame.parentStory.horizontalScale;

    var minimumPointSize = 2;

    var pointSize = textFrame.parentStory.pointSize;

    var minimumLeading = 3;

    var leading = textFrame.parentStory.leading;

    while(textFrame.overflows && horizontalScale > minimumHorizontalScale)

    {

        textFrame.parentStory.horizontalScale = horizontalScale--;

        textFrame.parentStory.pointSize = pointSize--;

       // textFrame.parentStory.leading = leading--;

    }

}

If all goes well, then only the textframes that were assigned the "fitText" name in the layers panel should have been reduced in pointsize and horizontal scale.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
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 Beginner ,
May 23, 2018 May 23, 2018

Thanks for taking the time to put something together.

Doesnt seem to be working though. Maybe I am missing a step?

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
People's Champ ,
May 23, 2018 May 23, 2018

Hi Allan,

Sorry to hear the trial didn't work for you.

I'd be very happy to see what went wrong and fix it up! The script is in use by many companies, including some who have incorporated it into their automated InDesign server routines.

Please feel free to get in touch. I'm sure it's something that will not take long to fix: admin [at] id-extras.com

Thanks,.

Ariel

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