n2_space Posted February 1, 2013 Share Posted February 1, 2013 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: - 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: - 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: 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, " <br> <br> <br> "); //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 ""; Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted February 1, 2013 Share Posted February 1, 2013 You can format the text inside a <p> tag for hanging indents. Here's a sample using the tab and lindent attributes: '<p tabstops="0;1800,Left,,;" lindent=1800>' + "-" + '<t>' + textvariable + '</p>'; Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 1, 2013 Author Share Posted February 1, 2013 You can format the text inside a <p> tag for hanging indents. Here's a sample using the tab and lindent attributes: '<p tabstops="0;1800,Left,,;" lindent=1800>' + "-" + '<t>' + textvariable + '</p>'; Thank you!!! Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 4, 2013 Author Share Posted February 4, 2013 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: 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 Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted February 4, 2013 Share Posted February 4, 2013 What do you mean by making the rows shrink? The leading or the column width? A screenshot would be helpful. Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 5, 2013 Author Share Posted February 5, 2013 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! Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted February 5, 2013 Share Posted February 5, 2013 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. Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 5, 2013 Author Share Posted February 5, 2013 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 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 5, 2013 Share Posted February 5, 2013 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: 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: 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: 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: 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: 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." Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 6, 2013 Author Share Posted February 6, 2013 (edited) <snip to not make this post so long> Ya, I'm pretty confused Here is the original rule: 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, " <br> <br> <br> "); //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. Edited February 6, 2013 by n2_space Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 6, 2013 Share Posted February 6, 2013 Ya, I'm pretty confused Here is the original rule: 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. Like I said, in order to completely analyze why you're seeing what you're seeing, I would need to run your rule myself, but it's impossible for me to do that without the rest of the job. And again, the root of the problem is that each line has both a <br> and a <p> tag at the beginning. You need one of those, not both. Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 6, 2013 Author Share Posted February 6, 2013 Like I said, in order to completely analyze why you're seeing what you're seeing, I would need to run your rule myself, but it's impossible for me to do that without the rest of the job. And again, the root of the problem is that each line has both a <br> and a <p> tag at the beginning. You need one of those, not both. ok, thanks for your help! I'm still learning a lot. I'll look into this further. Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 6, 2013 Author Share Posted February 6, 2013 Or, equivalently: 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." Each time I try this, I get: TypeError: [PAC1, PAC2, PAC3, PAC4].filter is not a function. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 6, 2013 Share Posted February 6, 2013 Each time I try this, I get: TypeError: [PAC1, PAC2, PAC3, PAC4].filter is not a function. Well, I guess I don't expect everyone to read all of my boring, lengthy signature, but all that stuff is there for a reason. Specifically, this is at the bottom of every message I post, in bold: "Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests." You're obviously using a version of FusionPro prior to 8.0, which uses an older version of the JavaScript library, which doesn't support the Array.filter function. But since you never specified what version of FusionPro you're using, I assumed you were using a recent one. Anyway, you could just use this other code instead, which, as I explicitly noted in my previous post, is equivalent to the code with the .filter function: 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, if you really want to use the Array.filter function in your older version of FusionPro, you can add this into your JavaScript Globals to make it work: if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp */) { "use strict"; if (this == null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun != "function") throw new TypeError(); var res = []; var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t) { var val = t[i]; // in case fun mutates this if (fun.call(thisp, val, i, t)) res.push(val); } } return res; }; } The code is from here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter#Compatibility Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 7, 2013 Author Share Posted February 7, 2013 Well, I guess I don't expect everyone to read all of my boring, lengthy signature, but all that stuff is there for a reason. Specifically, this is at the bottom of every message I post, in bold: "Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests." You're obviously using a version of FusionPro prior to 8.0, which uses an older version of the JavaScript library, which doesn't support the Array.filter function. But since you never specified what version of FusionPro you're using, I assumed you were using a recent one. Anyway, you could just use this other code instead, which, as I explicitly noted in my previous post, is equivalent to the code with the .filter function: 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, if you really want to use the Array.filter function in your older version of FusionPro, you can add this into your JavaScript Globals to make it work: if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp */) { "use strict"; if (this == null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun != "function") throw new TypeError(); var res = []; var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t) { var val = t[i]; // in case fun mutates this if (fun.call(thisp, val, i, t)) res.push(val); } } return res; }; } The code is from here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter#Compatibility yep, sorry... we've been slammed (and with another client, not even this), so my brain is in 50 places. I am using 7.2 in acrobat x... although I need to install FP 8, we have the license since we jsut bought the VDP producer server as well to automate some things. I'll give this a whirl then, thanks! Quote Link to comment Share on other sites More sharing options...
n2_space Posted February 13, 2013 Author Share Posted February 13, 2013 Ok, I still can't get this thing to work I've stripped some static elements of the document, just the info that is involved with dummy data, all the rules are there... this is as it was to begin with... so I am trying to figure out why many approaches to indenting the text messes up the table. Any thoughts would be greatly appreciated as I am just flat stumped Derm (3).pdfID08_sampledata.txtxdf data.txt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.