Copy link to clipboard
Copied
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.
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
See screenshot, Allan. Would this solve your problem? (Object > Tex Frame Options > Auto-Sizing)
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
Copy link to clipboard
Copied
Hello Scott,
I have tried this method and it did not seem to work properly.
Thank you for trying to help!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Maybe read his post again, he want to fit text to a maximum width frame, not fit frame to the text.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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".
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.
Copy link to clipboard
Copied
Thanks for taking the time to put something together.
Doesnt seem to be working though. Maybe I am missing a step?
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now