PDA

View Full Version : Adjust Line Leading Based on Line Count


Admin
August 22nd, 2008, 08:23 AM
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[i] != "")
{
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();

marcalew
March 12th, 2009, 10:36 AM
How do I use this to display the information?

Dan Korn
March 12th, 2009, 12:54 PM
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".