Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. I've highlighted in red the errors that I see. I realize that it's probably a typo, but there shouldn't be a period after the semicolon on line one. That will definitely keep your rule from returning correctly. Like the width of the text, the width and height of the graphic are measured in 100ths of a point. So setting the height to "1" and multiplying it by 100 will result in an image that is 1 point (1/72 inch) tall. As a matter of fact, if you want the height of the graphic to scale proportionally, just don't even specify a height. The last issue is that you should be using a "graphic" tag to return the graphic. Try this: var field = Field("First"); var graphic = 'fish.jpg'; var font = { face: "Proxima-Nova", size: 18 }; var tags = '<span font="' + font.face + '" pointsize="' + font.size + '">'; field = tags + field + '</span>'; function getTextWidth(input){ var tm = new FusionProTextMeasure; tm.useTags = true; tm.CalculateTextExtent(input); return tm.textWidth; } return field + '<br><graphic file="' + graphic + '" width="' + getTextWidth(field) + '">'; Keep in mind that a short name like "AJ" might result in the graphic being barely visible. I'd suggest setting a minimum width for the graphic so that it's visible: var field = '<span font="Proxima-Nova" pointsize="18">' + Field("First") + '</span>'; var graphic = 'fish.jpg'; var minWidth = 7200; // 72 points, 1 inch var [width] = [minWidth, getTextWidth(field)].sort(function(s,p){return p-s}); return field + '<br><graphic file="' + graphic + '" width="' + width + '">'; function getTextWidth(input){ var tm = new FusionProTextMeasure; tm.useTags = true; tm.CalculateTextExtent(input); return tm.textWidth; } The above will set a minimum width of 1 inch. If the text is wider than an inch, the graphic will be the same size as the text.
  2. Use the "ToUpper" function to convert the address to uppercase. Then use a regex similar the the one below to replace any digit followed by "ST", "TH", "RD", or "ND" with the matched digit and the superscripted matched letters. return ToUpper(Field('Street')).replace(/(\d)(ST|TH|RD|ND)/g, '$1<superscript>$2</superscript>');
  3. You could just put all of your fields into the cell of a table with a border on the top and bottom of it: var content = [ Field('Full Name'), Field('Title Line 1'), Field('Title Line 2'), Field('Email Address') ].filter(String).join('<br>'); if (!content) return ''; var table = new FPTable(); table.AddColumn(13600); var row = table.AddRow(); var cell = row.Cells[0]; cell.VAlign = 'Middle'; cell.HAlign = 'Center'; cell.SetBorders('Thin', 'PANTONE 350 U', 'Top', 'Bottom'); cell.Content = content; return table.MakeTags();
  4. Sorry, I misunderstood what you were going for. Now I understand that you want a top row with 3 columns and the bottom row to have 2 columns if there are 5 populated fields. The only potential issue I see with having 4 columns and joining the second and third cell on the top row is that the resulting cell will be wider than the other two cells on the top row. Instead of determining the number of columns upfront like I initially suggested, why not create a 6 column table and variably set the straddle (the width of the cell) based on how many elements are in a particular row? This is how I would do that: var fields = [Field("Location 1"), Field("Location 2"), Field("Location 3"), Field("Location 4"), Field("Location 5"), Field("Location 6")].filter(String); var myTable = new FPTable(); myTable.AddColumns(5388,5388,5388,5388,5388,5388); var cols = Math.ceil((fields.length/2)%2) ? 3 : 2; while(fields.length) { var row = myTable.AddRow(); fields.splice(0, cols).forEach(function(s,p,a){ var span = 6/a.length; var cell = row.Cells[p*span]; cell.HAlign = 'Center'; cell.HStraddle = span; row.Cells[p*span].Content = s; }); } return myTable.MakeTags(); I would suggest looking into the CopyfitLine function for that. Since you'll already know the size of the cell based on how many cells it's straddling (5388*span), you'll be able to set up copyfitting for each particular row.
  5. Oh, gotcha. I was basing my answer off of the image you posted in your second post. That being said, it doesn't sound like you're describing a 4 column table to me. It sounds like a 2 column table wherein the cell in the last row spans both columns. If that's what you want to do, then you don't need the code to add the blank space before the last element in arrays with a length of 5. It sounds to me like you can also modify the line for determining the number of columns to say "if the length of the array of populated fields is evenly divisible by 3 ( fields.length % 3 ), then make a 3 column table – otherwise make a two column table". Then when you're making your table just add a line that straddles the last cell of a row. That way, if one field is populated it will straddle 2 columns giving the appearance of 1 column. The same will be true for a scenario where 5 fields are populated. Revised code below: var fields = [Field("Location 1"), Field("Location 2"), Field("Location 3"), Field("Location 4"), Field("Location 5"), Field("Location 6")].filter(String); // Determine the number of columns [color="red"]var cols = fields.length % 3 ? 2 : 3;[/color] var tableWidth = 32328; var myTable = new FPTable(); for (var i=0; i<cols; i++) myTable.AddColumn(tableWidth/cols); while(fields.length) { var row = myTable.AddRow(); for (var i=0; i<cols; i++) { var cell = row.Cells[i]; cell.HAlign = 'Center'; cell.Content = fields.shift(); [color="Red"] if (!fields.length) cell.HStraddle = 2; // Straddle 2 columns on the last element.[/color] } } return myTable.MakeTags();
  6. While you are correct in saying that "adding a row doesn't need to be a var," there is nothing wrong with assigning it to a variable. The "AddRow" function actually returns the newly created row object so, assigning it to a variable can make things a little easier to read as opposed to writing "myTable.Rows[0]." But either syntax is completely fine, I just wanted to make that distinction. I think the way you want to achieve this is by determining how many fields you have populated and using that information to determine how many columns you'll need. The first part is easy. You can put all of your fields into an array and use the 'filter' method to remove any fields that are empty: var fields = [ Field("Location 1"), Field("Location 2"), Field("Location 3"), Field("Location 4"), Field("Location 5"), Field("Location 6") ].filter(String); The nice thing about this method is that it doesn't rely on the fields being populated in a particular order. For example, if only "Location 1" and "Location 5" were populated, the array would be reduced to ["Location 1", "Location 5"] which would generate a 2 column table. From there, you'll be able to tell how many fields are populated by accessing the 'length' property on the 'fields' array. One thing we'll need to do, though, is insert a "blank" before the last element if the array length is 5 which can be done using the 'splice' method. Then we're ready to figure out how many columns we need: // Insert blank to push last element into the 3rd cell if (fields.length == 5) fields.splice(4, 0, ' '); // Determine the number of columns var cols = fields.length == 1 ? 1 : fields.length % 3 ? 2 : 3; You can determine the number of columns (the 'cols' variable) a number of ways. I chose to use a ternary conditional but you could write it as a switch statement if you wanted to: switch (fields.length) { case 1: var cols = 1; break; case 2: case 4: var cols = 2; break; default: var cols = 3; } From there, determine the width each column should be (based on the number of columns needed) and create the table and columns: var myTable = new FPTable(); var tableWidth = 32328; for (var i=0; i<cols; i++) myTable.AddColumn(tableWidth/cols); Now that the table has the appropriate number of columns, all we have to do is add the content for each row: while(fields.length) { var row = myTable.AddRow(); for (var i=0; i<cols; i++) { var cell = row.Cells[i]; cell.HAlign = 'Center'; cell.Content = fields.shift(); } } So all together it looks like this: var fields = [Field("Location 1"), Field("Location 2"), Field("Location 3"), Field("Location 4"), Field("Location 5"), Field("Location 6")].filter(String); // Insert blank to push last element into the 3rd cell if (fields.length == 5) fields.splice(4, 0, ' '); // Determine the number of columns var cols = fields.length == 1 ? 1 : fields.length % 3 ? 2 : 3; var tableWidth = 32328; // Create table & add columns var myTable = new FPTable(); for (var i=0; i<cols; i++) myTable.AddColumn(tableWidth/cols); while(fields.length) { var row = myTable.AddRow(); for (var i=0; i<cols; i++) { var cell = row.Cells[i]; cell.HAlign = 'Center'; cell.Content = fields.shift(); } } return myTable.MakeTags();
  7. No, you aren't able to change the crop marks to a specific color nor can you specify a thickness. That being said, if you add the spot color to your FusionPro template (FusionPro > Advanced > Colors) - making sure you've toggled "Spot color" when adding it, and leave "Use Black Color for Crop Marks" unchecked when composing, the crop marks should print in Registration. Which means the separation for your job's spot color would have crop marks on it.
  8. Sure, you could do it that way. But consider the following: var field = "The Arnolds' house is Texas-travelers' \"most frequented\" establishment."; return field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w)/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’").replace(/(\w)'/g, "$1’"); In the case of two plural possessive words in the same sentence, the single quotes are replaced first so you'd want to make sure you performed that replacement before a pair of single quotes. Or you could modify your existing regexp to include: field = field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w[color="Red"]*[/color])/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’"); Previously, that particular regexp was looking for a word character (\w) followed by an apostrophe (') followed by a word character in order to consider it a replaceable match. Adding the asterisk (*) modifies the search pattern to be: a word character followed by an apostrophe followed by 0 or more word characters. Not sure what you mean by that. The code matches single/double quotes followed by anything that's not a single/double quote and replaces it with smart single/double quotes. Spaces are included in the list of characters that aren't single/double quotes so I wouldn't think there would be any issue converting something like the following:
  9. My guess is that the rule is replacing the quotes in your tags with smart quotes as well and FP is having difficulty parsing them. You can add this to your code to change any smart quotes in your tags back to normal quotes: var field = Field("Your Field"); field = field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w)/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’"); [color="Red"](field.match(/<[^>]+>/g) || []) .filter(function(tag) { return /[“”‘’]/.test(tag); }) .forEach(function(find) { var replace = find.replace(/[‘’]/g, "'").replace(/[“”]/g,'"'); field = field.replace(find, replace); });[/color] return field;
  10. Oh okay, well it sounds like you'd be able to do that with only this line of code: return Left(Field("No_Only"), 3).split('').join('<p>'); Just keep in mind that the "Left" function literally grabs the first 3 characters in a string so if your field happens to start with 2 spaces (" stephen"), the result will be 2 empty lines and an "s". If you want to prevent that from happening you can do so using the "LTrim" function to remove extra spaces from the beginning of the string: return Left(LTrim(Field("No_Only")), 3).split('').join('<p>');
  11. I'm not sure I understand what you're trying to do. Maybe you could post an image of what you're trying to achieve? I can tell you, though, that the "Left" function only takes two arguments – the string and the number of characters to return. So, to return the 3 leftmost characters, your function would merely be: var str = 'Stephen'; return [color="Red"]Left(str, 3);[/color] // returns 'Ste' No third argument needed. I can't tell what you're trying to achieve here. Are you just trying to separate every character with a paragraph tag? You could do that like so: return Field("No_Only").split('').join('<p>');
  12. Is using "Wingdings 2" an option?
  13. Is that the only place within your template that you're using Wingdings? I've occasionally run into an issue with certain fonts where they don't display correctly when referenced by a rule – I believe that Wingdings is one of the ones I've had issues with in the past. The way I've gotten it to work is to include the font elsewhere in the template. You can do this by using it in a text frame (as you've already discovered) or by creating a "Formatted Text Resource." You could even select "start new paragraph," insert the tab after it, highlight the tab and set the font/color, and change your code to: var outstr='', item='', itemName=''; var bullet = Resource("Your Formatted Text Resource Name"); for (item=1; item<11; item++) { if (Field("OpList" + item).length > 0) outstr += bullet.content + Field("OpList" + item); }
  14. Like this: return FusionPro.Composition.inputRecordNumber;
  15. Okay, I decided to test. I'm not going to attach the template because it's version 9 so it won't be any use to you on version 7 but I've attached the output and the imposition file. Here's how my template is set up: It is 18 pages. Page 1 is an orange page that says "Front," Page 2 is the corresponding orange page that says "Back" (admittedly the orange came out a little darker than PANTONE 165 but I digress), Page 3 is a purple page that says "Front" and so on and so forth. Because I'm lazy, I didn't go into FusionPro > Manage Pages > Page Usage and set all of the pages to "unused," instead I modified the code to turn on the pages that correspond to each record and turn off the pages that don't. I've highlighted that code in green below. If you've already set all of your pages to "Unused" then the change isn't necessary – though it won't hurt anything. On each page, I have a text frame that returns a text rule called "Sequence." In the example I attached, I created 30 of each record (rather than 600). That will give me a stack height of 5 cards (front and back) so I've adjusted the imposition file accordingly. Here are the rules I used: OnJobStart FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.startRecordNumber = 1; FusionPro.Composition.endRecordNumber = 9; OnRecordStart var pg = 1 var pages = []; while (pg<18) pages.push([pg++,pg++]); [color="YellowGreen"]pages.forEach(function(s,p) { FusionPro.Composition.SetBodyPageUsage(s[0], p == FusionPro.Composition.inputRecordNumber-1); FusionPro.Composition.SetBodyPageUsage(s[1], p == FusionPro.Composition.inputRecordNumber-1); });[/color] FusionPro.Composition.repeatRecordCount = 30; // Change to 600 and set your stack height to 100 in the imposition file Sequence (text rule) return FusionPro.Composition.repeatRecordNumber; forum_help.zip
  16. My apologies, I didn't realize you were using FP7.2. Try this: // This assumes that the first and second page of // your template are the front and back of the // first version of artwork respectively. var pg = 1 var pages = []; while (pg<18) pages.push([pg++,pg++]); FusionPro.Composition.repeatRecordCount = 600; [color="Red"]var page = pages[FusionPro.Composition.inputRecordNumber-1]; FusionPro.Composition.SetBodyPageUsage(page[0], true); FusionPro.Composition.SetBodyPageUsage(page[1], true);[/color]
  17. I could be wrong but it sounds like you just want to repeat each page 600 times (pulling the sequence number from FusionPro.Composition.repeatRecordNumber) and set your stack height to 100 instead of infinite. Are you using a data file to determine which artwork to pull in? If you're using a 9 record data file you would set your OnRecordStart rule up like this: // This assumes that the first and second page of // your template are the front and back of the // first version of artwork repectively. var pg = 1 var pages = []; while (pg<18) pages.push([pg++,pg++]); FusionPro.Composition.repeatRecordCount = 600; var [front, back] = pages[FusionPro.Composition.inputRecordNumber-1]; FusionPro.Composition.SetBodyPageUsage(front, true); FusionPro.Composition.SetBodyPageUsage(back, true); Then your sequence number rule would look like this: return FusionPro.Composition.repeatRecordNumber; If you aren't using a data file, you'd have to add this OnJobStart rule: FusionPro.Composition.composeAllRecords = false; FusionPro.Composition.startRecordNumber = 1; FusionPro.Composition.endRecordNumber = 9; I think that should work for what you're trying to accomplish. I will admit, though, that I haven't tested it.
  18. The function that I wrote relies on TextMeasure to determine whether or not the extra page is needed. I don't think that tables work with TextMeasure. I'm also not sure how the height of two linked text frames is interpreted by the "GetSettableTextHeight" function. There may be ways around that but for your table, I think you'd be safe in counting your rows and if it exceeds a certain amount, you'll know that the table is going to activate the overflow page. So for example, let's say you determine that you can fit 50 records onto page 3 before needing to add a fourth page. You can add a global variable to your job (recs) and make a few minor tweaks to your code: Table: if(FusionPro.inValidation) Rule("OnJobStart"); var border='<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">'; var myTable = '<table margins="left:30;right:0;bottom:30;top:30" columns=6 ShadeStyle="By:Row;First:1,Green,10;Next:1, white,0"><column width=4200><column width=3200><column width=14000><column width=1800><column width=2500><column width=4000>'; myTable += '<row type="header"><p br=false cellalignment=middle quad=C><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Date<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">SKU<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Description<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Tax<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">QTY<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Retail Item Price';//in row tag margins="left:50;right:50;top:50;bottom:50" //myTable += '<rulings top:thin,black;>'; [color="Red"]rows = 0; [/color]var numRecsExtDF = externalTable.recordCount; var prevStore = ''; for(var i=1; i <= numRecsExtDF; i++) { if (externalTable.GetFieldValue(i, 'MdbId') == Field("CID")) { [color="red"]rows++;[/color] var store = externalTable.GetFieldValue(i, 'StoreCode'); if(store != prevStore) { myTable += '<row><cell shading="Gray,50" hstraddle="6" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C><b>' + "STORE # " + externalTable.GetFieldValue(i, 'StoreCode') + '</b>';//goes before <b> <p br=false quad=C cellalignment=middle> prevStore = store; } myTable += '<row><p br=false cellalignment=middle quad=C><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">' + externalTable.GetFieldValue(i, 'TransactionDate');//in cell tag margins="left:0;right:0;top:0;bottom:0" myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ externalTable.GetFieldValue(i, 'SkuCode');//in cell tag margins="left:0;right:0" myTable += '<cell margins="left:300" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=L>'+ externalTable.GetFieldValue(i, 'SkuDescription');//goes after <cell> <p br=false quad=L> in cell tag margins="left:300;right:300" if(externalTable.GetFieldValue(i, 'IsTaxExempted') == "1") { myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ "Y";//goes after <cell> <p br=false quad=C> in cell tag margins="left:0;right:0" } else { myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ "N";//goes after <cell> <p br=false quad=C> in cell tag margins="left:0;right:0" } myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">'+ externalTable.GetFieldValue(i, 'UnitsSold')//in cell tag margins="left:0;right:0" myTable += '<cell margins="right:100;" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=R>'+ externalTable.GetFieldValue(i, 'NetSalesAmt')//in cell tag margins="left:0;right:300" } } myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black" shading="White,100" hstraddle="6">'+"Total Non-taxable Purchases (Tax=N)........$"+Field("Total Non Taxable Purchases");//goes after <cell> <p br=false quad=R> myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black" shading="White,100" hstraddle="6">'+"Total Taxable Purchases (Tax=Y)........$"+Field("Total Taxable Purchases");//goes after <cell> <p br=false quad=R> myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black;Bottom:Thin,Black" shading="White,100" hstraddle="6">'+"Total Purchases (not including sales tax)........$"+Field("Total Purchases");//goes after <cell> <p br=false quad=R> myTable += '</table>'; return myTable; OnRecordStart: Rule('Table'); FusionPro.Composition.SetBodyPageUsage('ExtraPage', rows < 50); Of course with FP9, you can easily find all of the external data records that match the "CID" field by using the "findRecords" function which makes it a little easier: if(FusionPro.inValidation) Rule("OnJobStart"); var border='<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">'; var myTable = '<table margins="left:30;right:0;bottom:30;top:30" columns=6 ShadeStyle="By:Row;First:1,Green,10;Next:1, white,0"><column width=4200><column width=3200><column width=14000><column width=1800><column width=2500><column width=4000>'; myTable += '<row type="header"><p br=false cellalignment=middle quad=C><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Date<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">SKU<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Description<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Tax<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">QTY<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">Retail Item Price';//in row tag margins="left:50;right:50;top:50;bottom:50" var prevStore = ''; [color="red"]var recs = externalTable.FindRecords('MdbId', Field("CID")); rows = recs.length;[/color] for ([color="red"]var i in recs[/color]) { [color="red"]var rec = recs[i];[/color] var store = externalTable.GetFieldValue(rec, 'StoreCode'); if(store != prevStore) { myTable += '<row><cell shading="Gray,50" hstraddle="6" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C><b>' + "STORE # " + externalTable.GetFieldValue(rec, 'StoreCode') + '</b>';//goes before <b> <p br=false quad=C cellalignment=middle> prevStore = store; } myTable += '<row><p br=false cellalignment=middle quad=C><cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">' + externalTable.GetFieldValue(rec, 'TransactionDate');//in cell tag margins="left:0;right:0;top:0;bottom:0" myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ externalTable.GetFieldValue(rec, 'SkuCode');//in cell tag margins="left:0;right:0" myTable += '<cell margins="left:300" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=L>'+ externalTable.GetFieldValue(rec, 'SkuDescription');//goes after <cell> <p br=false quad=L> in cell tag margins="left:300;right:300" if(externalTable.GetFieldValue(rec, 'IsTaxExempted') == "1") { myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ "Y";//goes after <cell> <p br=false quad=C> in cell tag margins="left:0;right:0" } else { myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=C>'+ "N";//goes after <cell> <p br=false quad=C> in cell tag margins="left:0;right:0" } myTable += '<cell rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black">'+ externalTable.GetFieldValue(rec, 'UnitsSold')//in cell tag margins="left:0;right:0" myTable += '<cell margins="right:100;" rulings="Top:Thin,Black;Bottom:Thin,Black;Left:Thin,Black;Right:Thin,Black"><p br=false quad=R>'+ externalTable.GetFieldValue(rec, 'NetSalesAmt')//in cell tag margins="left:0;right:300" } myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black" shading="White,100" hstraddle="6">'+"Total Non-taxable Purchases (Tax=N)........$"+Field("Total Non Taxable Purchases");//goes after <cell> <p br=false quad=R> myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black" shading="White,100" hstraddle="6">'+"Total Taxable Purchases (Tax=Y)........$"+Field("Total Taxable Purchases");//goes after <cell> <p br=false quad=R> myTable += '<row><cell rulings="Right:Thin,Black;Left:Thin,Black;Bottom:Thin,Black" shading="White,100" hstraddle="6">'+"Total Purchases (not including sales tax)........$"+Field("Total Purchases");//goes after <cell> <p br=false quad=R> myTable += '</table>'; return myTable;
  19. Can you supply the MultipleCustomerExternal.txt file? Preferably with a record or two that causes the issues you're mentioning in this thread?
  20. That is difficult to say for certain but as you mentioned, The categories are different and the values of those categories are different. So I believe part of it to be because of the way FP is trying to copyfit those unique flows of text. Additionally, I believe the bigger culprit to be the fact that you have "Use legacy line leading" enabled in your global paragraph settings (Paragraph... > Global Settings...). I honestly am not sure what that setting controls but in my experience its status is usually to blame for any wild shifts in leading in a template. If you don't need it, I'd recommend turning it off to see if that helps. In your code you only apply a leading tag to the "Agriculture Total" line. You never close that leading tag so if the "Agriculture Total" is present in the legend, the leading is applied to all line items. What you're seeing in that particular graph is the auto-leading (120% font size) being applied in the absence of an absolute leading. // ... if(Field("Agriculture Total") != "0") { pieLegend += colors[counter]+'<z newsize="12">[color="Red"]<leading newsize=80>[/color]'+"♦ "+'<z newsize ="7"><color name=Black>'+"Agriculture Total - $"+Field("Agriculture Total")+'<br>'; counter--; } if(Field("Clothing Total") != "0") { pieLegend += colors[counter]+'<z newsize="12">'+"♦ "+'<z newsize ="7"><color name=Black>'+"Clothing Total - $"+Field("Clothing Total")+'<br>'; counter-- } // ... That's a page layout tag. I can't say I'm familiar with it, personally, but I don't think that's the tag you want to be using for this. The paragraph tag has the same attribute and will allow you to work within the context of the paragraph. Again, it's hard to say. I would refer you to my answer to your first question. I have seen legacy line leading cause this issue before. I hope you aren't OCD because I'm answering this one out of sequential order. As I mentioned before, I believe you want to use the paragraph tag (<p>) in lieu of the page tag so I would remove the "Even Columns" rule (page tag) all together. Though putting it at the end would likely cause some copyfitting issues. I'm not sure if I've mentioned this yet or not, but I first turn off legacy line leading.Then I would remove the "Even columns" rule. Then, if you want to adjust the leading, I'd do it in the paragraph settings of the text editor – an absolute leading of 8pt is the equivalent to the leading you're setting with tags in your code. Speaking of your code, with every addition of a legend key, you append a break tag (<br>). There's nothing wrong with that, you just want to clean up that string before you return it so that you don't have unnecessary carriage returns taking up space in your text flow when it comes time to copy fit or balance the columns. You can clean that up pretty simply by just removing any break tag at the end of the string: return pieLegend[color="red"].replace(/<br>$/,'')[/color]; I think you can save yourself a lot of repetition by putting your field names into an array, using the map method to tag them if the field is not equal to 0, and using the filter method to remove any empty keys. From there you have an array with all of your populated keys tagged appropriately which you can use to determine how many fields you'll need in each column by dividing the length in half and using Math.ceil to round up. Once you know where to split the array, you can use the splice method to get two arrays (left/right column), joining the elements of each with a break tag and finally joining the two columns with a paragraph tag that forces the second column into position: var marker = '♦'; var colors = ["Green", "Orange", "Blue", "Pink", "Yellow", "SeaFoam", "Red", "Lavender", "Magenta", "Tan"]; var legend = [ "Agriculture Total", "Clothing Total", "Hardware Total", "Livestock/Pet Total", "Seasonal Total", "Special Order", "Toy/Gift", "Fencing/Equip", "Truck/Trailer", "Misc Total" ] .map(function (field) { return StringToNumber(Field(field)) ? '<span pointsize="12" color="' + colors.shift() + '">' + marker + '</span> ' + field.replace(' Total', '') + ' Total - $' + Field(field) : ''; }) .filter(String); var left = legend.splice(0, Math.ceil(legend.length / 2)); return [ left, legend ] .map(function(s) { return s.join('<br>'); }) .filter(String) .join('<p verticalstart=topofcolumn>'); Or the more compact version of the same code: var marker = '♦'; var colors = ["Green", "Orange", "Blue", "Pink", "Yellow", "SeaFoam", "Red", "Lavender", "Magenta", "Tan"]; var legend = ["Agriculture Total", "Clothing Total", "Hardware Total", "Livestock/Pet Total", "Seasonal Total", "Special Order", "Toy/Gift", "Fencing/Equip", "Truck/Trailer", "Misc Total"].map(function (field) { return StringToNumber(Field(field)) ? '<span pointsize="12" color="' + colors.shift() + '">' + marker + '</span> ' + field.replace(' Total', '') + ' Total - $' + Field(field) : '';}).filter(String).join('<br>'); var left = legend.splice(0, Math.ceil(legend.length / 2)); return [ left, legend ].map(function(s) { return s.join('<br>'); }).filter(String).join('<p verticalstart=topofcolumn>');
  21. This will give you an array of dates between 8/2 and 12/30 without Sundays and Mondays but I'm not really clear on what you're intending to do with it from there: var start = new Date('8/2/2016'); var end = new Date('12/30/2017'); var dates = []; // Array to hold all the dates // Push the current date into the 'dates' array // and increment the date until we've reached the end while (start <= end) { dates.push(new Date(start)) start.setDate(start.getDate()+1); } return dates // Remove dates the fall on Sunday or Monday .filter(function(date) { return date.getDay() > 1; }) // Format the dates .map(function(date) { return FormatDate(date, 'ld lm d yyyy'); }) // Join the array with break tags .join('<br>\n');
  22. Ryan can you collect your job and post it to the forum? It would be easier to help you that way.
  23. I don't think you can superscript graphic files. You could, however, put your content in a table with two columns. The left column could be set to the width of your check box graphic and the right column could have a width of the remaining width of the text frame. Both cells in the row would be given a vertical alignment of "middle" so that the check box floats in the middle of the text. This would also give you a little more flexibility if you wanted to adjust the spacing between the checkbox and the text – you could just make the checkbox column wider. var checkbox = Resource('Check Box'); var txt = Field('Your field'); var checkboxWidth = 3000; // in 1/100 pts -> 7200 = 1" var frameWidth = FusionPro.inValidation ? 14400 : GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name)); var table = new FPTable(); table.AddColumns(checkboxWidth, frameWidth-checkboxWidth); var row = table.AddRow(); var cell = row.Cells[0] cell.VAlign = 'Middle'; row.CopyCells(0,1); row.SetContents(checkbox, txt); return table.MakeTags(); "Re-evaluate this rule for every text flow" and "Treat strings as tagged text" need to be checked in the rule editor. You'll also need to name your text frame. On the other hand, if you set the width of the text frame yourself (in 100th's of a point), you don't need to name the frame or select "Re-evaluate this rule for every text flow": var checkbox = Resource('Check Box'); var txt = Field('Your field'); var checkboxWidth = 3000; // in 1/100 pts -> 7200 = 1" var frameWidth = 14400; // 14400 = 2" var table = new FPTable(); table.AddColumns(checkboxWidth, frameWidth-checkboxWidth); var row = table.AddRow(); var cell = row.Cells[0] cell.VAlign = 'Middle'; row.CopyCells(0,1); row.SetContents(checkbox, txt); return table.MakeTags();
  24. Here's a post that has an example of what Don's referring to: http://forums.pti.com/showpost.php?p=11530&postcount=3
×
×
  • Create New...