Jump to content

Adjust Line Leading Based on Line Count


Admin1676454018

Recommended Posts

Copy and paste everything below this line:

 

// This rule counts the number of lines and, if the line count is greater than 10, decrease the leading

// To use this rule, ensure you check the box "Treat returned strings as tagged text.

 

 

function FormatLeadingByLineCount()

{

// first combine fields that are on the same line

// for checking empty lines below

var nameLine = Field("FirstName")+Field("LastName");

var cszLine = Field("City")+Field("State")+Field("Zip")+Field("Country");

linesArray =

[

nameLine, Field("Title1"), Field("Title2"), Field("Title3"),

Field("Address1"), Field("Address2"), cszLine,

Field("Phone1"), Field("Fax1"), Field("Phone2"),

Field("Email"), Field("www")

];

var linesCount = 0;

for (var i = 0 ; i < linesArray.length ; i++)

{

if (linesArray != "")

{

linesCount++;

}

}

 

if (linesCount > 10)

{

return '<para style="(no style)" quad="C" leading="35" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="2" kerning="true" hyphenate="true" skipifempty="false"><tracking newsize="0.000000"></para>';

}

else

{

return '<para style="(no style)" quad="C" leading="70" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="2" kerning="true" hyphenate="true" skipifempty="false"><tracking newsize="0.000000"></para>';

}

}

return FormatLeadingByLineCount();

Link to comment
Share on other sites

  • 6 months later...
Hmm, I'm not sure where this example came from. It seems difficult to customize it for a specific job. I think it's probably simpler to just turn on copyfit for the frame (from the Text Frame Properties palette, click "Overflow", and then "Adjust text to fit"), then go into your OnCopyfit Callback rule, and change "text" in the first line of the rule to "leading".
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...