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

[018] Table + Overset Text in Cell! …

LEGEND ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

Hi Scripters,

Really dubitative! By contrariety, this code desperately refuses to work!! 

var myDoc = app.activeDocument,

myStories = myDoc.stories,

myTables = myStories.everyItem().tables.everyItem().getElements();

var T = myTables.length,

t, C, c;

delete_Overset();

function delete_Overset() {   

    for ( t = 0; t < T; t++ ) {

        var myCells = myTables.cells.everyItem().getElements();

        C = myCells.length;

        for ( c = 0; c < C; c++) {

            myOverflow = myCells.overflows;

            while ( check_Overflow ( myOverflow ) == true ) {

                myCells.paragraphs[0].desiredGlyphScaling -= 1;

                myCells.paragraphs[0].desiredWordSpacing -= 1;

            }

            function check_Overflow ( myCellStory ) {

                if ( myCellStory == true )

                return true;

                return false;

            }

        }

    }

}

Thanks for your help!

(^/) 

TOPICS
Scripting

Views

1.9K

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
Mentor ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Hi Obi,

You cant set a desiredXXX value without relation to minimumXXX value.

But even if you modify both - you set your preferences for Adobe Paragraph Composer rather than kill cell's overset.

Wrong way

Jarek

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Hi Jarek,

The para style "Justification" settings are:

Capture d’écran 2017-08-01 à 12.20.04.png

After the script, the para settings becomes:

Capture d’écran 2017-08-01 à 12.19.46.png

Normally, in my sample [on the [only one] overset cell of the table], the script would have to stop at this moment:

Capture d’écran 2017-08-01 à 12.26.35.png

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
Mentor ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Hi,

Would have to stop cause there is a space enough to fit?

Maybe it need to be recomposed? I am not sure if Adobe Composer works 'on the fly' while script' job.

Jarek

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Jarek [ Hi Jongware!  ],

This seems to work but not sure it's the more "orthodox" way to fix it! …

var myDoc = app.activeDocument,

myStories = myDoc.stories,

myCells = myStories.everyItem().tables.everyItem().cells.everyItem().getElements();

var C = myCells.length, c;

delete_Overset();

function delete_Overset() {   

    for ( c = 0; c < C; c++) {

        var myOverflow = myCells.overflows;

        while ( check_Overflow ( myOverflow ) == true ) {

            try {

                myCells.paragraphs[0].desiredGlyphScaling -= 1;

                myCells.paragraphs[0].desiredWordSpacing -= 1;

                myCells.recompose();

                var myOverflow = myCells.overflows;

                check_Overflow ( myOverflow );

            } catch(e){}          

        }

        continue;

           

        function check_Overflow ( myCellStory ) {

            if ( myCellStory == true ) return true;

            return false;

        }

    }

}

At the beginning, I've 2 Tables with 3 oversets:

Capture d’écran 2017-08-01 à 14.42.25.png

Result after Script: 3 different "Justification" settings [could play with tracking/scaling too]:

Capture d’écran 2017-08-01 à 14.43.13.png

Capture d’écran 2017-08-01 à 14.43.34.png

Capture d’écran 2017-08-01 à 14.43.52.png

I will really appreciate your comments! 

(^/)

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Obi-1, I believe Jarek is right because I have had similar problems with manipulating tables. You have to imagine what happens in the background: a script is running in one thread, and in another one InDesign is promoting the changes into the actual document. The odd recompose() forces the script to wait while the typesetter is catching up.

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Jongware,

Could you develop? Too hard to understand for me! 

(^/)

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
People's Champ ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Hi,

Undependantly of composer's concerns, just to give the snippet an end :

var main = function() {

var doc = app.properties.activeDocument,

cells, n, nCell, para1, newGlyphScaling, newWordSpacing;

if ( !doc ) return;

cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();

n = cells.length;

while ( n-- ) {

nCell  = cells;

while ( nCell.overflows ) {

para1 = nCell.paragraphs[0];

newGlyphScaling = para1.desiredGlyphScaling-1;

newWordSpacing = para1.desiredWordSpacing-1;

if ( newWordSpacing<50 || newWordSpacing<0 ) break;

para1.properties = {

minimumGlyphScaling : (newGlyphScaling<para1.minimumGlyphScaling)? newGlyphScaling : para1.minimumGlyphScaling,

desiredGlyphScaling : newGlyphScaling,

minimumWordSpacing : (newWordSpacing<para1.minimumWordSpacing)? newWordSpacing : para1.minimumWordSpacing,

desiredWordSpacing : newWordSpacing

}

};

}

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Loïc,

Still not!

This one works:

var main = function() {

   

    var doc = app.properties.activeDocument, 

    cells, n, nCell, myOverflow, para1, newGlyphScaling, newWordSpacing; 

     

    if ( !doc ) return; 

     

    cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements(); 

    n = cells.length; 

     

    while ( n-- ) { 

        nCell  = cells,

        myOverflow = nCell.overflows;

        while ( myOverflow ) { 

            para1 = nCell.paragraphs[0]; 

            newGlyphScaling = para1.desiredGlyphScaling-1; 

            newWordSpacing = para1.desiredWordSpacing-1; 

             

            if ( newWordSpacing<50 || newWordSpacing<0 ) break; 

             

            para1.properties = { 

            minimumGlyphScaling : (newGlyphScaling<para1.minimumGlyphScaling)? newGlyphScaling : para1.minimumGlyphScaling, 

            desiredGlyphScaling : newGlyphScaling, 

            minimumWordSpacing : (newWordSpacing<para1.minimumWordSpacing)? newWordSpacing : para1.minimumWordSpacing, 

            desiredWordSpacing : newWordSpacing 

            }

   

        nCell.recompose();

        var myOverflow = nCell.overflows;

        }

    } 

 

var u; 

 

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" ); 

(^/)

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
People's Champ ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Yes i realized after i did forget to recompose the paragraph but you get the idea

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
People's Champ ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Hi Obi,

There could be so many issues here but a wild guess would be that using -= 1 in your case doesn't really help. The -= operator helps modifying numerical value but imho that wouldn't work when it comes to assigning a new property value. Or rather you may change the value of desiredGlyphScaling but not the property itself.

Here is a possible approach:

var main = function() {

var doc = app.properties.activeDocument,

cells, n, nCell, para1;

if ( !doc ) return;

cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();

n = cells.length;

while ( n-- ) {

nCell  = cells;

if ( nCell.overflows ) {

para1 = nCell.paragraphs[0];

var newGlyphScaling = para1.desiredGlyphScaling;

var newWordSpacing = para1.desiredWordSpacing;

para1.properties = {

minimumGlyphScaling : (newGlyphScaling-1<para1.minimumGlyphScaling)? newGlyphScaling-1 : para1.minimumGlyphScaling,

desiredGlyphScaling : newGlyphScaling-1,

desiredWordSpacing : newWordSpacing-1

}

};

}

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Thanks a lot, Loïc,

Always nice to have another approach and other kinds of writing. Especially for my learning. 

Something is missing in your code:

In the "if ( nCell.overflows ) { … }", you need to check if, after the first treatment, the cell is always or not "overflow"!

Capture d’écran 2017-08-01 à 21.38.24.png

Capture d’écran 2017-08-01 à 21.37.45.png

If you can correct this part, it would be cool!  Thanks in advance! 

(^/)

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
People's Champ ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

Just replace if by while. A bit risky tough.

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 ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

That doesn't work!

(^/)

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 ,
Aug 19, 2017 Aug 19, 2017

Copy link to clipboard

Copied

LATEST

Hi

Why not just change the characters horizontal scale instead of paragraph justification properties?

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