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

Script request: Create justification with text size

New Here ,
Jul 06, 2011 Jul 06, 2011

Copy link to clipboard

Copied

Hi folks,

the Adobe support hotline get me here, so I try to find a developer for my InDesign feature request.

We are currently working for a client, that uses justified text in the headlines of his advertising materials. Until now, the justification is set "by hand" while the final artwork ist created.

For the future, we want to automatize these final artwork with a special software and InDesign Server (CS4+).

The tricky part is, that the justification has not to be created by spacing between the words and letters, it has to be created by the text-size. So, the text of the headline is set in such a big size, that it looks like a justification. More text, less text-size, less text, more text-size.

loremipsum-headline.pngloremipsum-headline-2.png

Is there any way, to automatize this via a script or something else?

We would pay for a script or something else to implement this feature.

Can anyone help?

Thanks for your time and best wishes from Berlin, Germany!

Philipp

TOPICS
Scripting

Views

3.5K

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
Advisor ,
Jul 06, 2011 Jul 06, 2011

Copy link to clipboard

Copied

Hey Philipp,

Feel free to contact me: tomaxxi (at) gmail (dot) com

--

Marijan (tomaxxi)

http://tomaxxi.com

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 06, 2011 Jul 06, 2011

Copy link to clipboard

Copied

Hi,

Not sure if this helps but in the past I've done something like this:

var document = app.documents.add();
var textFrame = document.textFrames.add();
var maxTextSize = 100;
var minTextSize = 10;
var maxHorizontalScale = 200;
var minHorizontalScale = 100;
var textSize = maxTextSize;
var paragraphs = null;

textFrame.geometricBounds = [10, 10, 60, 200];
textFrame.contents = "Lorem ipsum is the best";
paragraph = textFrame.paragraphs[0];
paragraph.pointSize = textSize;

while(textFrame.overflows && textSize > minTextSize)
{
    textSize--;
    paragraph.pointSize = textSize;
}

paragraph.horizontalScale = maxHorizontalScale;

while(textFrame.overflows && paragraph.horizontalScale > minHorizontalScale)
{
    paragraph.horizontalScale--;
}

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
New Here ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

Unfortunately, this is not exact what we are looking for. The paragraphs are not justified within the text-container, and he creates a new container instead of editing an existing one.

Can you change the script for us? We will pay for a solution!

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
LEGEND ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

This might help:

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

Harbs

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 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

This might not be possible to automate in InDesign.

If you look closely to your sample, you will see the left and right sides of each line is aligned perfectly with the others, even though the size is different. That's not possible using regular scaling! There is an amount of white space at the left and right of each character (because otherwise they'd appear all touching each other), and so this space scales up with the rest of the font.

alignment.PNG

Since you cannot access the left and right sidebearings (as this space is known) per character in InDesign, you have to align each line by eye.

(More complciated, but perhaps possible: convert the text per line to outlines, test width to determine scaling percentage, then scale original text. You'd have the correct size, but you still need to align.)

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 Beginner ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

And what about 0's and B's or other round shapes? They would run over the frame's edge.

This is something that can't be done manually as well, can it?

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
New Here ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

You're right, there are some problems with letters and their spacings. I currently write a concept how it could be possible to handle this, but it will make the script more complicated...

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 Beginner ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

Something that works for me is writing down all manual action and rules, and

rewrite your English to javascript. With a small vocabulary you can try

saving your English version as applescript

2011/7/7 FlowinBeatz <forums@adobe.com>

You're right, there are some problems with letters and their spacings. I

currently write a concept how it could be possible to handle this, but it

will make the script more complicated...

>

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
New Here ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

I'm not a coder, so writing my concept in JavaScript or AppleScript is the freelancer's job 😉

The script has to be executed on InDesign Server, so AppleScript is not an option?!

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 Beginner ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

Ok. But writing down all steps you want to be automated sure would the

scripter to script what you need.

applescript would work on a mac server.

2011/7/7 FlowinBeatz <forums@adobe.com>

I'm not a coder, so writing my concept in JavaScript or AppleScript is the

freelancer's job

>

The script has to be executed on InDesign Server, so AppleScript is not

an option?!

>

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
New Here ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

It's an Unix based server, I think.

I will write down all steps and post it here, very soon!

Thanks a lot, folks!

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
LEGEND ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

InDesign Server does not run on Unix. There's only Mac and Windows versions.

Harbs

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
New Here ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

You're absolutely right. It run's on an 10.6 Xserv...

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
LEGEND ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

This might not be possible to automate in InDesign.

If you look closely to your sample, you will see the left and right sides of each line is aligned perfectly with the others, even though the size is different. That's not possible using regular scaling! There is an amount of white space at the left and right of each character (because otherwise they'd appear all touching each other), and so this space scales up with the rest of the font.

I would do this by iteratively adjusting the tracking and checking to see if that caused the text to overflow the line, and if so, backing off by one increment.

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 Beginner ,
Jul 08, 2011 Jul 08, 2011

Copy link to clipboard

Copied

(More complciated, but perhaps possible: convert the text per line to  outlines, test width to determine scaling percentage, then scale  original text. You'd have the correct size, but you still need to  align.)

This must be the only solution.

convert to outlines, and stretch until you reached textframe width. leave it as images.

To have it look really good, you can check the first and last character for cruved shaped, and add a little predescribed percent, and move the images when needed.

Having the scale just for factor to apply on original text still gives the problem of the whitespace.

I'll give it go today.

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 Beginner ,
Jul 08, 2011 Jul 08, 2011

Copy link to clipboard

Copied

var myDoc = app.activeDocument;
var myFrame = myDoc.textFrames.add({geometricBounds:[10,10,110,110]});
myFrame.contents = "LOREM\rIPSUM IS THE BEST";
myFrame.parentStory.fillColor = myDoc.swatches.item("C=100 M=0 Y=0 K=0");
myFrame.parentStory.appliedFont = "Arial";
myFrame.parentStory.pointSize = 8;
myDoc.recompose();
alert("look at me now!");
    var myFrameWidth = myFrame.geometricBounds[3]-myFrame.geometricBounds[1];
    for(myLineIndex=myFrame.lines.length-1;myLineIndex>=0;myLineIndex--){
    myLine = myFrame.lines[myLineIndex];
  
    var myLineImages = myLine.createOutlines();
    app.select(myLineImages);
    var mySel = app.selection[0];
    var myBounds = mySel.geometricBounds;
    var mySelectionWidth = myBounds[3]-myBounds[1];
    var myScalePercentage = (myFrameWidth/mySelectionWidth);
    var myLineLeading = myLine.leading;
    var myLinePointSize = myLine.pointSize;
    if(myLineLeading == 1635019116){
    myLineLeading = 1.2*myLinePointSize;
    }
    myLine.leading = myLineLeading*myScalePercentage;
    myLine.pointSize = myLinePointSize*myScalePercentage;
    var myTransformationMatrix = app.transformationMatrices.add({horizontalScaleFactor:myScalePercentage,verticalScaleFactor:myScalePercentage});
    mySel.transform(CoordinateSpaces.pasteboardCoordinates,AnchorPoint.TOP_LEFT_ANCHOR, myTransformationMatrix);
    myFrame.fit(FitOptions.FRAME_TO_CONTENT);
    }

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
LEGEND ,
Jul 10, 2011 Jul 10, 2011

Copy link to clipboard

Copied

Converting to outlines is a pretty bad solution if you want to be able to edit the text afterwards...

Harbs

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 Beginner ,
Jul 11, 2011 Jul 11, 2011

Copy link to clipboard

Copied

Goodmorning.

Store the original text in the created pageItems's label and you've tackled that one too.

var myDoc = app.activeDocument;
var myFrame = myDoc.textFrames.add({geometricBounds:[10,10,110,110]});
myFrame.contents = "LOREM\rIPSUM IS THE BEST";
myFrame.parentStory.fillColor = myDoc.swatches.item("C=100 M=0 Y=0 K=0");
myFrame.parentStory.appliedFont = "Arial";
myFrame.parentStory.pointSize = 8;
myDoc.recompose();
alert("look at me now!");
    var myFrameWidth = myFrame.geometricBounds[3]-myFrame.geometricBounds[1];
    for(myLineIndex=myFrame.lines.length-1;myLineIndex>=0;myLineIndex--){
    myLine = myFrame.lines[myLineIndex];
   var myLineContent = myLine.contents;
    var myLineImages = myLine.createOutlines();
    app.select(myLineImages);
    var mySel = app.selection[0];

    mySel.insetLabel("storedContent",myLineContent);
    var myBounds = mySel.geometricBounds;
    var mySelectionWidth = myBounds[3]-myBounds[1];
    var myScalePercentage = (myFrameWidth/mySelectionWidth);
    var myLineLeading = myLine.leading;
    var myLinePointSize = myLine.pointSize;
    if(myLineLeading == 1635019116){
    myLineLeading = 1.2*myLinePointSize;
    }
    myLine.leading = myLineLeading*myScalePercentage;
    myLine.pointSize = myLinePointSize*myScalePercentage;
     var myTransformationMatrix =  app.transformationMatrices.add({horizontalScaleFactor:myScalePercenta  ge,verticalScaleFactor:myScalePercentage});
    mySel.transform(CoordinateSpaces.pasteboardCoordinates,AnchorPoint.TO P_LEFT_ANCHOR, myTransformationMatrix);
    myFrame.fit(FitOptions.FRAME_TO_CONTENT);
    }

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
Guru ,
Jul 17, 2011 Jul 17, 2011

Copy link to clipboard

Copied

http://indesignsecrets.com/removing-space-along-left-edge.php and http://jsid.blogspot.com/2008/07/align-left-edge.html

by David Saunders show the way to script this without converting to outline.

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
New Here ,
Jul 18, 2011 Jul 18, 2011

Copy link to clipboard

Copied

Guys, you are really amazing! Thanks for the lot of solutions, you've posted!

Unfortunately, we are not able to run scripts in our project... So we have to look for a workaround, that uses built-in InDesign functionality.

The blog entry ( http://indesignsecrets.com/removing-space-along-left-edge.php and http://jsid.blogspot.com/2008/07/align-left-edge.html )

posted by Trevor was really helpful. With this How To I was able to align the first letter of the headline to the left border of the text box. So, there's just a solution needed for the right border of the box. But I think, we will handle this, too.

So, if anyone knows a way to fit the text on the right border, please feel free to post it here.

Thank you so much!

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
LEGEND ,
Jul 18, 2011 Jul 18, 2011

Copy link to clipboard

Copied

Unfortunately, we are not able to run scripts in our project... So we have to look for a workaround, that uses built-in InDesign functionality.

Why?

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
New Here ,
Jul 18, 2011 Jul 18, 2011

Copy link to clipboard

Copied

We use Censhare, a Media Asset Management Software for our project. In the communication between Censhare and InDesign Server is no way to start scripts in the server...

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
Guide ,
Jul 18, 2011 Jul 18, 2011

Copy link to clipboard

Copied

LATEST

> In the communication between Censhare and InDesign Server is no way to start scripts in the server...

Doing that all day, via menus, postprocessing during checkin or any workflow status changes. Ask Censhare for details, I only know the scripting side while those callbacks are done in Java.

Dirk

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