David Miller Posted December 18, 2012 Share Posted December 18, 2012 Not sure how to tackle this one... We have a series of business cards where the name and job title are on the same line. The background color behind the name is black and behind the job title it is green. The gap between the name and job title is constant, but the width of the background color behind the name must change based on the length of the name. Obviously, affecting the background color width behind the title. Attached is a PDF with examples. Anyone have any suggestions? Thought about creating a series of backgrounds and change them based on the length of the name field. Maybe tables? New FP features I'm not familiar with? (The template files will probably be used in MarcomCentral.) Thanks. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 18, 2012 Share Posted December 18, 2012 Use the FusionProTextMeasure object to measure the lengths of the data fields. Then create a table with a single row and two columns, setting the columns widths based on the measurement results. Set the background color of each cell as appropriate. Quote Link to comment Share on other sites More sharing options...
step Posted December 18, 2012 Share Posted December 18, 2012 After looking at the example, it looks to me like some of the longer names (specifically Rachelle Kivanoski) are sized a bit smaller than the others. Will TextMeasure take into account whether or not the text needs to be CopyFit in the table's column? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 18, 2012 Share Posted December 18, 2012 After looking at the example, it looks to me like some of the longer names (specifically Rachelle Kivanoski) are sized a bit smaller than the others. Will TextMeasure take into account whether or not the text needs to be CopyFit in the table's column? No, it just measures the text you give it. You can always call the CopyfitLine function first to make sure it fits, though. (CopyfitLine itself utilizes FusionProTextMeasure to know if the text fits on the line.) Quote Link to comment Share on other sites More sharing options...
David Miller Posted December 20, 2012 Author Share Posted December 20, 2012 Haven't worked with tables in FusionPro before. So, I read through Dan's JavaScript Table API – The Basics and Step's post here. Was able to get a very basic version of this working, but am unable to get any copy-fitting to work. Specifically, CopyFitLine with no breaks. // Use TextMeasure to measure the length of each name var tm = new FusionProTextMeasure; tm.pointSize = "10 pt"; // set the type size tm.font = "Helvetica"; // set your typeface tm.CalculateTextExtent(Field("Name")); // Replace with your field tm.useTags = false; var tmWidth = tm.textWidth; var tableWidth = 27000 var column0Width = tmWidth + 2700 var column1Width = 150 var column2Width = tableWidth - column0Width - column1Width // Create table var myTable = new FPTable; myTable.AddColumns(column0Width, column1Width, column2Width); myTable.AddRows(1); // Declare cell formatting myTable.Rows[0].Cells[0].Margins = new FPTableMargins; myTable.Rows[0].Cells[0].Margins.Top = 60; myTable.Rows[0].Cells[0].Margins.Bottom = 60; myTable.Rows[0].Cells[0].Margins.Left = 900; myTable.Rows[0].Cells[0].Margins.Right = 1800; myTable.Rows[0].Cells[2].Margins = new FPTableMargins; myTable.Rows[0].Cells[2].Margins.Top = 60; myTable.Rows[0].Cells[2].Margins.Bottom = 60; myTable.Rows[0].Cells[2].Margins.Left = 900; myTable.Rows[0].Cells[2].Margins.Right = 900; myTable.Rows[0].Cells[0].ShadeColor="Black"; myTable.Rows[0].Cells[0].ShadePct=80; myTable.Rows[0].Cells[0].VAlign = "Middle"; myTable.Rows[0].Cells[0].HAlign = "Left"; myTable.Rows[0].Cells[0].Font="Helvetica"; myTable.Rows[0].Cells[0].TextColor="White"; myTable.Rows[0].Cells[0].PointSize=10; myTable.Rows[0].Cells[1].ShadeColor="Yellow"; myTable.Rows[0].Cells[1].ShadePct=80; myTable.Rows[0].Cells[2].ShadeColor="Green"; myTable.Rows[0].Cells[2].ShadePct=80; myTable.Rows[0].Cells[2].VAlign = "Middle"; myTable.Rows[0].Cells[2].HAlign = "Left"; myTable.Rows[0].Cells[2].Font="Helvetica"; myTable.Rows[0].Cells[2].TextColor="White"; myTable.Rows[0].Cells[2].PointSize=10; myTable.Rows[0].Cells[0].Content = CopyfitLine("", Field("Name"), "Helvetica", 10, column0Width, 2, true); myTable.Rows[0].Cells[1].Content = ""; myTable.Rows[0].Cells[2].Content = CopyfitLine("", Field("Title"), "Helvetica", 10, column2Width, 2, true); return myTable.MakeTags().replace(/^\<table/, "<table alignment=left"); // Align table in Text box I figured that the width needs to be 3.75" wide, the width of column 0 is set by the text width of the name field plus margins, column 1 is a fixed width, and column 3 fills the rest of the space. Probably will need to set a minimum and maximum width of column 0 and limit the amount of character in the title field. (Unless there is a better way?) Either way, any hints as to how I can get CopyFitLine with no breaks working with this? Thanks! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 20, 2012 Share Posted December 20, 2012 I copied and pasted your rule verbatim into the Frodo Travel Tutorial job, and changed Field("Title") to Field("Destination") on the next-to-last line, and it seems to be working fine. (Note that it works the same way if you simply set the field value in the first column, without the first call to CopyfitLine, since you're already measured that text and sized the column to hold it.) So exactly what data is causing the line to break for you, and in which column? A screenshot may be worth a thousand words here. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 20, 2012 Share Posted December 20, 2012 Ah, never mind, I downloaded the job you attached, and I see what the problem is. Actually, there are two problems. First, you need to subtract the left and right margin amounts in the cell from the column width to get the total amount of space available to set the text. Second, you need to divide the result by 100, since the table API uses units in hundredths of points, while the CopyfitLine function uses points. So the last few lines of the rule should be this: myTable.Rows[0].Cells[0].Content = Field("Name"); var Column2EffectiveWidth = column2Width - myTable.Rows[0].Cells[2].Margins.Left - myTable.Rows[0].Cells[2].Margins.Right; myTable.Rows[0].Cells[2].Content = CopyfitLine("", Field("Title"), "Helvetica", 10, Column2EffectiveWidth / 100, 2, true); return myTable.MakeTags(); Quote Link to comment Share on other sites More sharing options...
David Miller Posted December 20, 2012 Author Share Posted December 20, 2012 Sorry. I should have mentioned record 2 in the uploaded template. We seem to have lost the tutorial files since upgrading to FP VDP 8. Thanks for your quick reply. I will give it a try. -Dave Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 21, 2012 Share Posted December 21, 2012 We seem to have lost the tutorial files since upgrading to FP VDP 8. They're still there, just in a different location. You can find them through the menu in Acrobat: FusionPro -> Documentation -> Tutorials. Quote Link to comment Share on other sites More sharing options...
David Miller Posted December 21, 2012 Author Share Posted December 21, 2012 Your right again. On a Mac: Users > Shared > PTI > FusionPro > Tutorial Old habits die hard. I'm used to looking in the Applications folder. Thanks. -Dave Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 21, 2012 Share Posted December 21, 2012 On a Mac: Users > Shared > PTI > FusionPro > Tutorial Old habits die hard. I'm used to looking in the Applications folder. Right. We moved them because standard (non-admin) users don't have write access to the Applications folder. Quote Link to comment Share on other sites More sharing options...
David Miller Posted December 21, 2012 Author Share Posted December 21, 2012 Works great! Thank you Dan. -Dave 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.