Thread View: adobe.scripting.indesign
5 messages
5 total messages
Started by Miguel_Sanchez
Mon, 30 Mar 2009 07:36
script for a newspaper
Author: Miguel_Sanchez
Date: Mon, 30 Mar 2009 07:36
Date: Mon, 30 Mar 2009 07:36
1 lines
693 bytes
693 bytes
We are a newspaper trying to write a script that creates two lines headlines, no matter how many words are in the headline, changing the font size?, is this possible?
Re: script for a newspaper
Author: jongware
Date: Mon, 30 Mar 2009 09:04
Date: Mon, 30 Mar 2009 09:04
25 lines
1937 bytes
1937 bytes
What a fun challenge! This one took me about 3 minutes -- but it was a mental exercise. Put your text cursor in a line and double-click this script: while (app.activeDocument.selection[0].paragraphs[0].lines.length < 2) app.activeDocument.selection[0].paragraphs[0].pointSize += 1; lowerguess = app.activeDocument.selection[0].paragraphs[0].pointSize; while (app.activeDocument.selection[0].paragraphs[0].lines.length < 3) app.activeDocument.selection[0].paragraphs[0].pointSize += 1; higherguess = app.activeDocument.selection[0].paragraphs[0].pointSize; app.activeDocument.selection[0].paragraphs[0].pointSize = (lowerguess+higherguess)/2; while (app.activeDocument.selection[0].paragraphs[0].lines.length > 2) app.activeDocument.selection[0].paragraphs[0].pointSize -= 1; It first enlarges the text up to a minimum required size to make the text 2 lines. I thought that a bit ... too easy -- you'll mostly end up with a single word on the 2nd line. So, next it enlarges the text up to 3 lines. It then takes the average of the two. If it ends up being 3 lines after all (I guess that's possible), the text gets smaller again to fit. (Don't use it on a single word! I just did -- it still works, but ... it will never get to 2 lines. Ever.)
Re: script for a newspaper
Author: jongware
Date: Mon, 30 Mar 2009 09:09
Date: Mon, 30 Mar 2009 09:09
9 lines
894 bytes
894 bytes
Okay, tested some more. You get a better fit if you first enlarge to at least 3 lines, then take the previous size: while (app.activeDocument.selection[0].paragraphs[0].lines.length < 3) app.activeDocument.selection[0].paragraphs[0].pointSize += 1; app.activeDocument.selection[0].paragraphs[0].pointSize -= 1;
Re: script for a newspaper
Author: Jeremy_Bowman
Date: Mon, 30 Mar 2009 18:19
Date: Mon, 30 Mar 2009 18:19
5 lines
746 bytes
746 bytes
jongware, that is brilliant! Thank you for that snippet -- it's given me all sorts of ideas. Best wishes -- Jeremy
Re: script for a newspaper
Author: Miguel_Sanchez
Date: Tue, 31 Mar 2009 01:38
Date: Tue, 31 Mar 2009 01:38
2 lines
656 bytes
656 bytes
Thank๏ฟฝs it worked excellent and also gave me new ideas Miguel Sanchez
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads