Skip to main content
Known Participant
February 12, 2014
Question

A script for adapting text to frame

  • February 12, 2014
  • 1 reply
  • 2629 views

Hi all,

We are using InDesignCC for creating PDF files online.

This hapens with XML output. And on demand our customers can put variabel fields in en can generate a pdf to view the results.

Online it looks something like this:

This is the problem:

A textbox in InDesign have a fixed length. But the customers can give in a large text for this field. Larger than the tekstbox it self.

Now, default, InDesign sets the given text on to 2 lines.

Is there a script to be attached on a textbox that horizontaly scales the text to fit the textbox?

I hope someone can help.

thx

This topic has been closed for replies.

1 reply

2i_Geert
Participating Frequently
February 13, 2014

Hi,

Does this work:

var document = app.activeDocument

// Give your text item the name "fitText" (in InDesign, double click on the item in the layer panel)

var textFrame = document.textFrames.itemByName("fitText");

var minimumHorizontalScale = 50;

var horizontalScale = textFrame.parentStory.horizontalScale;

while(textFrame.overflows && horizontalScale > minimumHorizontalScale)

{

    textFrame.parentStory.horizontalScale = horizontalScale--;

}

StyleMAuthor
Known Participant
February 26, 2014

Hi,

According to our programmer this should work.

Put we have an issue. Is it possible and how: to execute this script automaticly when a file is opend and the file contains  text item with the name "fittext". Do you know if this is possible?

Also, i have just manualy test the script you wrote and got this error:

it's in Dutch:

Object is niet geldig = Object is not valid

Regel =Line

Bron=Source

tnx

2i_Geert
Participating Frequently
February 26, 2014

Hi,

Did you use the exact same name "fitText" in the InDesign document (mind the capital "T")?