Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 1st, 2013, 06:20 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Indenting a second line

I have several rules in a template that is calling out to an XDF file for data. Each one of these are landing in alternating color grids with up to four pieces of text (requirements) in each text block. Each one has a bullet point so you basically have:

Quote:
- requirement 1
- requirement 2 (if there is one)
- requirement 3 (if there is one)
- requirement 4 (if there is one)
The issue is now that the text for each requirement can spill over, therefore creating:

Quote:
- requirement 1 blah blah blah
blah blah blah
What they want is if it spills to another line to indent where the text starts after the bullet on line one


so, is there a way to make it indent if the text in the XDF is so long it spills to another line?


here is the code in one of the rules for example:

Quote:
if (FusionPro.inValidation)
Rule("OnJobStart");
var myTable = new FPTable;
var MA = "";
var PLAN = "";
var PA = "";
var PAC1 = "";
var PAC2 = "";
var PAC3 = "";
var PAC4 = "";
var counter = 0;
var Plantype = "";
//myTable.AddColumns(23800, 5000, 21300, 2000);
myTable.AddColumns(20800, 5000, 24300, 2000);
myTable.AddRows(1);
myTable.Rows[0].Cells[0].ShadeColor = "PANTONE 5483 C";
myTable.Rows[0].Cells[0].ShadePct = "80";
myTable.Rows[0].Cells[0].SetBorders("Thick", "White", "Top", "Bottom");
myTable.Rows[0].Cells[0].SetBorders("Thin", "White", "Right", "Left");
myTable.Rows[0].Cells[0].Font = "Helvetica 75 Bold";
myTable.Rows[0].Cells[0].TextColor = "White";
myTable.Rows[0].Cells[0].PointSize = "11";
myTable.Rows[0].Cells[0].Margins = new FPTableMargins;
myTable.Rows[0].Cells[0].Margins.Top = 120;
myTable.Rows[0].Cells[0].Margins.Bottom = 120;
myTable.Rows[0].Cells[0].HStraddle = 3;
//myTable.Rows[0].CopyCells(0, 1,2);
myTable.Rows[0].SetContents("COMMERCIAL PLANS");

for (item=01;item<5;item++)
{

itemName="CommercialPlan" + item;
for (i = 1; i < XDF.recordCount+1; i++)
{
Plantype = XDF.GetFieldValue(i, 2);
MSA = XDF.GetFieldValue(i, 1);
PLAN = XDF.GetFieldValue(i, 5);
if ((Field("MSA") == MSA && MSA != "") && (Field(itemName) == PLAN && PLAN != "" && PLAN != "None") && (Plantype == "Commercial"))
{
counter++;

PA = XDF.GetFieldValue(i, 9);
PAC1 = XDF.GetFieldValue(i, 10);
PAC2 = XDF.GetFieldValue(i, 11);
PAC3 = XDF.GetFieldValue(i, 12);
PAC4 = XDF.GetFieldValue(i, 13);
if (PAC1 != "")
PAC1 = "- "+PAC1;
if (PAC2 != "")
PAC2 = "- "+PAC2;
if (PAC3 != "")
PAC3 = "- "+PAC3;
if (PAC4 != "")
PAC4 = "- "+PAC4;
var s = "";
s = AppendText(s, " ", PAC1);
s = AppendText(s, "<br>", PAC2);
s = AppendText(s, "<br>", PAC3);
s = AppendText(s, "<br>", PAC4);

myTable.AddRows(1);
if (item%2 == 1)
{
myTable.Rows[counter].Cells[0].ShadeColor = "PANTONE 5483 C";
myTable.Rows[counter].Cells[0].ShadePct = "20";
}
else if (item%2 == 0)
{
myTable.Rows[counter].Cells[0].ShadeColor = "Black";
myTable.Rows[counter].Cells[0].ShadePct = "10";
}
myTable.Rows[counter].Cells[0].SetBorders("Thin", "White", "Top", "Bottom", "Right", "Left");
myTable.Rows[counter].Cells[0].Font = "Calibri";
myTable.Rows[counter].Cells[0].PointSize = "10";
myTable.Rows[counter].Cells[0].TextColor = "PANTONE 2755 C";
myTable.Rows[counter].Cells[0].Margins = new FPTableMargins;
myTable.Rows[counter].Cells[0].Margins.Top = 10;
myTable.Rows[counter].Cells[0].Margins.Bottom = 30;
myTable.Rows[counter].CopyCells(0, 1,2);
myTable.Rows[counter].Cells[3].Margins = new FPTableMargins;
myTable.Rows[counter].Cells[3].Margins.Top = 10;
myTable.Rows[counter].Cells[3].Margins.Bottom = 30;
myTable.Rows[counter].Cells[2].PointSize = "8";
myTable.Rows[counter].Cells[3].PointSize = "8";
myTable.Rows[counter].SetContents(Field(itemName) , PA, s, "&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;"); //these crazy spaces are to keep the spacing consistent
myTable.Rows[counter].Cells[0].HAlign = "Left";
myTable.Rows[counter].Cells[0].VAlign = "Middle";
myTable.Rows[counter].Cells[1].HAlign = "Center";
myTable.Rows[counter].Cells[1].VAlign = "Middle";
myTable.Rows[counter].Cells[2].HAlign = "Left";
myTable.Rows[counter].Cells[2].VAlign = "Middle";
myTable.Rows[counter].Cells[3].VAlign = "Middle";
}
}
}

if (counter > 0)
return myTable.MakeTags();
else return "";
Reply With Quote
  #2  
Old February 1st, 2013, 09:41 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Indenting a second line

You can format the text inside a <p> tag for hanging indents. Here's a sample using the tab and lindent attributes:

Code:
'<p tabstops="0;1800,Left,,;" lindent=1800>' + "-" + '<t>' + textvariable + '</p>';
Reply With Quote
  #3  
Old February 1st, 2013, 09:58 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Re: Indenting a second line

Quote:
Originally Posted by ThomasLewis View Post
You can format the text inside a <p> tag for hanging indents. Here's a sample using the tab and lindent attributes:

Code:
'<p tabstops="0;1800,Left,,;" lindent=1800>' + "-" + '<t>' + textvariable + '</p>';
Thank you!!!
Reply With Quote
  #4  
Old February 4th, 2013, 06:25 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Re: Indenting a second line

The weird problem I am running into is that code is somehow changing the spacing on the rows on the table and not keeping it consistent... thoughts? It's actually making the rows shrink...

The only modification to the original code was the addition of your code like this:

Quote:
if (PAC1 != "")
PAC1 = '<p tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC1 + '</p>';
if (PAC2 != "")
PAC2 = '<p tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC2 + '</p>';
if (PAC3 != "")
PAC3 = '<p tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC3 + '</p>';
if (PAC4 != "")
PAC4 = '<p tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC4 + '</p>';
any help is GREATLY appreciated, I'm confused on how it's doing this
Reply With Quote
  #5  
Old February 4th, 2013, 08:14 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Indenting a second line

What do you mean by making the rows shrink? The leading or the column width? A screenshot would be helpful.
Reply With Quote
  #6  
Old February 5th, 2013, 05:15 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Re: Indenting a second line

Quote:
Originally Posted by ThomasLewis View Post
What do you mean by making the rows shrink? The leading or the column width? A screenshot would be helpful.
Sorry, I attached a before (for before adding the extra code) and an after (after I added the additional code). I photoshopped out info on the left and the right 9except the bullets) due to NDA reasons, but you can see how they change height instead of stayin the dame height, regardless of the amount of information in the right hand column.

Thanks so much for your help!
Attached Images
File Type: jpg after.jpg (53.6 KB, 13 views)
File Type: jpg before.jpg (53.4 KB, 12 views)
Reply With Quote
  #7  
Old February 5th, 2013, 07:05 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Indenting a second line

This looks like a leading issue. You could try turning on "Use Legacy Line Leading" (it's in the Variable Text Editor, Paragraph, Global Settings). Sometime that just fixes everything, sometimes causes other issues though.

Another thing I would do is open up the TagsRefGuid.pdf manual. On page 42 it covers all the Paragraph attributes. You may need to adjust the leadbefore and leadafter. If you try this, I believe the documentation is off about it being in tenths, it seems to actually be in hundredths like lindent is.
Reply With Quote
  #8  
Old February 5th, 2013, 09:19 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Re: Indenting a second line

Quote:
Originally Posted by ThomasLewis View Post
This looks like a leading issue. You could try turning on "Use Legacy Line Leading" (it's in the Variable Text Editor, Paragraph, Global Settings). Sometime that just fixes everything, sometimes causes other issues though.

Another thing I would do is open up the TagsRefGuid.pdf manual. On page 42 it covers all the Paragraph attributes. You may need to adjust the leadbefore and leadafter. If you try this, I believe the documentation is off about it being in tenths, it seems to actually be in hundredths like lindent is.
Thanks, I'll look at the manual, legacy line leading did nothing
Reply With Quote
  #9  
Old February 5th, 2013, 11:26 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Indenting a second line

Quote:
Originally Posted by n2_space View Post
Sorry, I attached a before (for before adding the extra code) and an after (after I added the additional code). I photoshopped out info on the left and the right 9except the bullets) due to NDA reasons, but you can see how they change height instead of stayin the dame height, regardless of the amount of information in the right hand column.
It's hard to know exactly what's going on without seeing the whole job, including the paragraph settings in the text frame where you're calling out the rule, as well as the data which drives the whole thing (or at least some dummy data), and other rules and functions that are being invoked.

That said, you might want to try using "soft" returns, with <br> tags, instead of starting a whole new paragraph with a <p> tag for each item.

In fact, it looks like you're already outputting <br> tags between each line, on top of <p> tags, in these lines:
Code:
s = AppendText(s, " ", PAC1);
s = AppendText(s, "<br>", PAC2);
s = AppendText(s, "<br>", PAC3);
s = AppendText(s, "<br>", PAC4);
Although I don't know what your "AppendText" function does. Presumably it appends the <br> tag only if the other parameter is non-empty. (Again, it's hard to know what a rule is doing without the context of the rest of the job.)

Anyway, it's no wonder the spacing is changing, with both <br> and <p> tags in effect. You want to choose one or the other.

The simplest way to have the <p> tag attributes take effect without actually starting a new paragraph is to add the "br=false" attribute. So the lines could be like this:
Code:
PAC1 = '<p br=false tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC1 + '</p>';
But, I would just output the <p> tag once to set the paragraph up and then stick with <br> tags. The current paragraph style remains in effect, even when a new line starts with <br>. Also, there's no ending </p> tag in FusionPro; the <p> tag implies that the current paragraph is ending since a new one is beginning. So that part of the rule could simply be:
Code:
if (PAC1 != "")
PAC1 = '<p br=false tabstops="0;1250,Left,,;" lindent=1250>' + "•" + '<t>' + PAC1;
if (PAC2 != "")
PAC2 = "<br>" + "•" + '<t>' + PAC2;
if (PAC3 != "")
PAC3 = "<br>" + "•" + '<t>' + PAC3;
if (PAC4 != "")
PAC4 = "<br>" + "•" + '<t>' + PAC4;
Of course, you don't really need to do any of that at all, since you already have a function AppendText which can figure out whether each item is empty or not, and prepend it with some other text. So you can let that function do all of this for you, by changing those other lines like so:
Code:
s = AppendText(s, '<p br=false tabstops="0;1250,Left,,;" lindent=1250>•<t>' , PAC1);
s = AppendText(s, "<br>•<t>", PAC2);
s = AppendText(s, "<br>•<t>", PAC3);
s = AppendText(s, "<br>•<t>", PAC4);
Or, equivalently:
Code:
var s = '<p br=false tabstops="0;1250,Left,,;" lindent=1250>•<t>';
s += [PAC1, PAC2, PAC3, PAC4].filter(String).join("<br>•<t>");
That last line says, "Make an array of these four items, remove empty elements, and join them into a single string, putting "<br>•<t>" in between each item."
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #10  
Old February 6th, 2013, 04:51 AM
n2_space n2_space is offline
Regular Contributor
 
Join Date: Jul 2011
Posts: 53
Default Re: Indenting a second line

Quote:
Originally Posted by Dan Korn View Post
<snip to not make this post so long>
Ya, I'm pretty confused Here is the original rule:

Quote:
if (FusionPro.inValidation)
Rule("OnJobStart");
var myTable = new FPTable;
var MA = "";
var PLAN = "";
var PA = "";
var PAC1 = "";
var PAC2 = "";
var PAC3 = "";
var PAC4 = "";
var counter = 0;
var Plantype = "";
//myTable.AddColumns(23800, 5000, 21300, 2000);
myTable.AddColumns(18550, 5200, 26350, 2000);
myTable.AddRows(1);
myTable.Rows[0].Cells[0].ShadeColor = "PANTONE 5483 C";
myTable.Rows[0].Cells[0].ShadePct = "80";
myTable.Rows[0].Cells[0].SetBorders("Thick", "White", "Top", "Bottom");
myTable.Rows[0].Cells[0].SetBorders("Thin", "White", "Right", "Left");
myTable.Rows[0].Cells[0].Font = "Helvetica 75 Bold";
myTable.Rows[0].Cells[0].TextColor = "White";
myTable.Rows[0].Cells[0].PointSize = "11";
myTable.Rows[0].Cells[0].Margins = new FPTableMargins;
myTable.Rows[0].Cells[0].Margins.Top = 120;
myTable.Rows[0].Cells[0].Margins.Bottom = 120;
myTable.Rows[0].Cells[0].HStraddle = 3;
//myTable.Rows[0].CopyCells(0, 1,2);
myTable.Rows[0].SetContents("COMMERCIAL PLANS");

for (item=01;item<5;item++)
{

itemName="CommercialPlan" + item;
for (i = 1; i < XDF.recordCount+1; i++)
{
Plantype = XDF.GetFieldValue(i, 2);
MSA = XDF.GetFieldValue(i, 1);
PLAN = XDF.GetFieldValue(i, 5);
if ((Field("MSA") == MSA && MSA != "") && (Field(itemName) == PLAN && PLAN != "" && PLAN != "None") && (Plantype == "Commercial"))
{
counter++;

PA = XDF.GetFieldValue(i, 9);
PAC1 = XDF.GetFieldValue(i, 10);
PAC2 = XDF.GetFieldValue(i, 11);
PAC3 = XDF.GetFieldValue(i, 12);
PAC4 = XDF.GetFieldValue(i, 13);
if (PAC1 != "")
PAC1 = "• "+PAC1;
if (PAC2 != "")
PAC2 = "• "+PAC2;
if (PAC3 != "")
PAC3 = "• "+PAC3;
if (PAC4 != "")
PAC4 = "• "+PAC4;
var s = "";
s = AppendText(s, " ", PAC1);
s = AppendText(s, "<br>", PAC2);
s = AppendText(s, "<br>", PAC3);
s = AppendText(s, "<br>", PAC4);

myTable.AddRows(1);
if (item%2 == 1)
{
myTable.Rows[counter].Cells[0].ShadeColor = "PANTONE 5483 C";
myTable.Rows[counter].Cells[0].ShadePct = "20";
}
else if (item%2 == 0)
{
myTable.Rows[counter].Cells[0].ShadeColor = "Black";
myTable.Rows[counter].Cells[0].ShadePct = "10";
}
myTable.Rows[counter].Cells[0].SetBorders("Thin", "White", "Top", "Bottom", "Right", "Left");
myTable.Rows[counter].Cells[0].Font = "Calibri";
myTable.Rows[counter].Cells[0].PointSize = "10";
myTable.Rows[counter].Cells[0].TextColor = "PANTONE 2755 C";
myTable.Rows[counter].Cells[0].Margins = new FPTableMargins;
myTable.Rows[counter].Cells[0].Margins.Top = 10;
myTable.Rows[counter].Cells[0].Margins.Bottom = 30;
myTable.Rows[counter].CopyCells(0, 1,2);
myTable.Rows[counter].Cells[3].Margins = new FPTableMargins;
myTable.Rows[counter].Cells[3].Margins.Top = 10;
myTable.Rows[counter].Cells[3].Margins.Bottom = 30;
myTable.Rows[counter].Cells[2].PointSize = "8";
myTable.Rows[counter].Cells[3].PointSize = "8";
myTable.Rows[counter].SetContents(Field(itemName) , PA, s, "&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;"); //these crazy spaces are to keep the spacing consistent
myTable.Rows[counter].Cells[0].HAlign = "Left";
myTable.Rows[counter].Cells[0].VAlign = "Middle";
myTable.Rows[counter].Cells[1].HAlign = "Center";
myTable.Rows[counter].Cells[1].VAlign = "Middle";
myTable.Rows[counter].Cells[2].HAlign = "Left";
myTable.Rows[counter].Cells[2].VAlign = "Middle";
myTable.Rows[counter].Cells[3].VAlign = "Middle";
}
}
}

if (counter > 0)
return myTable.MakeTags();
else return "";
The idea is that any text in PAC1 ( or 2, or 3, or 4) that is so long it flows to the second line, is to indent it. The problem is any solution I have tried to work in that indents it causes the rows created to change size (see attached before.jpg and after.jpg ... this has dummy data in it), the lident alone in the code someone else showed me makes it do this, as with any other code I tried... so I'm rather confused.
Attached Images
File Type: jpg before.jpg (84.9 KB, 11 views)
File Type: jpg after.jpg (82.1 KB, 11 views)

Last edited by n2_space; February 6th, 2013 at 04:53 AM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:23 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.