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!
(^/)
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
Copy link to clipboard
Copied
Hi Jarek,
The para style "Justification" settings are:
After the script, the para settings becomes:
Normally, in my sample [on the [only one] overset cell of the table], the script would have to stop at this moment:
Why?
(^/)
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
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:
Result after Script: 3 different "Justification" settings [could play with tracking/scaling too]:
I will really appreciate your comments!
(^/)
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.
Copy link to clipboard
Copied
Jongware,
Could you develop? Too hard to understand for me!
(^/)
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" );
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" );
(^/)
Copy link to clipboard
Copied
Yes i realized after i did forget to recompose the paragraph but you get the idea
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" );
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"!
If you can correct this part, it would be cool! Thanks in advance!
(^/)
Copy link to clipboard
Copied
Just replace if by while. A bit risky tough.
Copy link to clipboard
Copied
That doesn't work!
(^/)
Copy link to clipboard
Copied
Hi
Why not just change the characters horizontal scale instead of paragraph justification properties?