geeool Posted September 20, 2019 Share Posted September 20, 2019 Hi, I have a business card where my client wants to use a carrot '>' symbol between the label and the phone number (see attached screen capture for reference). I decided to use a table for laying out the numbers because the top number will sometimes have an extension, so it needs to float. As I'm building my table and testing it, I'm finding that the carrot '>' symbol won't display. I've tried escaping it, but that hasn't worked. var office = 'O '+'/\(>\)/ '+' '+Rule("OfficePhoneRULE")+' Ext.'+Field("Ext.");Full table code below. Any suggestions? var table = new FPTable; var NoR = 3// NoR = number of rows (one less than actual) // Setting the table width of the columns table.AddColumns(6000, 1000, 10000); table.AddRows(4); // Adds the number of rows to the table. for(a=0;a<=NoR;a++) // Counter for building the rows (rows 0 thru 3) { for(b=0;b<1;b++) // Counter for building the cells (cell 0 ) { table.Rows[a].Cells[b].SetBorders("Thin", "Red", "Top", "Bottom", "Left", "Right"); // Adds red line around table cell table.Rows[a].Cells[b].Margins = new FPTableMargins; // This needs to be set every time the margins change table.Rows[a].Cells[b].Margins.Top = 55; // I had to have a larger Top Margin to make the text look centered between the top and bottom borders table.Rows[a].Cells[b].Margins.Bottom = 55; table.Rows[a].Cells[b].Margins.Left = 200; table.Rows[a].Cells[b].Margins.Right = 200; table.Rows[a].Cells[b].Font = "Knockout HTF31-JuniorMiddlewt"; // This sets the font for the first cell, the second is set at the text frame. table.Rows[a].Cells[b].TextColor = "Black"; // This sets the font for the first cell, the second is set at the text frame. } for(c=1;c<2;c++) // Counter for building the cells (cell 1) { table.Rows[a].Cells[c].SetBorders("Thin", "Red", "Top", "Bottom", "Left", "Right"); // Adds red line around table cell table.Rows[a].Cells[c].Margins = new FPTableMargins; // This needs to be set every time the margins change table.Rows[a].Cells[c].Margins.Top = 55; // I had to have a larger Top Margin to make the text look centered between the top and bottom borders table.Rows[a].Cells[c].Margins.Bottom = 55; table.Rows[a].Cells[c].Margins.Left = 200; table.Rows[a].Cells[c].Margins.Right = 200; } for(d=2;d<3;d++) // Counter for building the cells (cell 2) { table.Rows[a].Cells[d].SetBorders("Thin", "Red", "Top", "Bottom", "Left", "Right"); // Adds red line around table cell table.Rows[a].Cells[d].Margins = new FPTableMargins; // This needs to be set every time the margins change table.Rows[a].Cells[d].Margins.Top = 55; // I had to have a larger Top Margin to make the text look centered between the top and bottom borders table.Rows[a].Cells[d].Margins.Bottom = 55; table.Rows[a].Cells[d].Margins.Left = 200; table.Rows[a].Cells[d].Margins.Right = 200; } } for(i=0;i<=4;i++) { //var prep_field_num = i+1; //var prep_field = 'Instruction'+prep_field_num; var ext = Field("Ext."); var office = 'O '+'/\(>\)/ '+' '+Rule("OfficePhoneRULE")+' Ext.'+Field("Ext."); var store = Field("S"); var mobile = Field("M"); var fax = Field("F"); if (ext != "") { table.Rows[0].Cells[0].Margins = new FPTableMargins; // This needs to be set every time the margins change table.Rows[0].Cells[0].Margins.Top = 65; // I had to have a larger Top Margin to make the text look centered between the top and bottom borders table.Rows[0].Cells[0].Margins.Bottom = 40; table.Rows[0].Cells[0].Margins.Left = 200; table.Rows[0].Cells[0].Margins.Right = 200; table.Rows[0].Cells[0].Font = "Knockout HTF31-JuniorMiddlewt"; table.Rows[0].Cells[0].PointSize= "8"; table.Rows[0].Cells[0].HStraddle = 3; table.Rows[0].Cells[0].Content = office; } if (store != "") { // if field contains *h2* it will be a headline table.Rows[1].Cells[1].Margins = new FPTableMargins; // This needs to be set every time the margins change table.Rows[1].Cells[1].Margins.Top = 65; // I had to have a larger Top Margin to make the text look centered between the top and bottom borders table.Rows[1].Cells[1].Margins.Bottom = 40; table.Rows[1].Cells[1].Margins.Left = 200; table.Rows[1].Cells[1].Margins.Right = 200; table.Rows[1].Cells[1].Font = "Knockout HTF31-JuniorMiddlewt"; table.Rows[1].Cells[1].PointSize= "8"; table.Rows[1].Cells[1].Content = store; //removing the *h2* in front of the field content } else { // When an empty field is encountered, break loop and build table break; } } table = table.MakeTags(); // This is required return table; // This is required Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 20, 2019 Share Posted September 20, 2019 As you can see if you click Validate in the rule, the table that's being returned is a bunch of HTML/XML-like tagged markup, so that means you have to follow tagged markup guidelines for certain characters which have special meanings, such as angle brackets <> to denote a tag, single- and double-quotes, and ampersands. You could use entities such as < to represent such characters literally in tagged markup, but that can get tricky. Fortunately, there's a function that can do all the necessary entity replacements for you, called TaggedTextFromRaw. So you can just do this: var office = TaggedTextFromRaw('O > ' + Rule("OfficePhoneRULE") + ' Ext.' + Field("Ext.")); Quote Link to comment Share on other sites More sharing options...
geeool Posted September 23, 2019 Author Share Posted September 23, 2019 Thanks Dan, that worked! 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.