oleooo Posted August 29, 2011 Share Posted August 29, 2011 Is there a way to create a table rule that sets the columns based on the text length put in a field. I am pretty new to this but here is the code I am working with. var textFirstColumn= Field("2 Column Address 1") .content var textSecondColumn=Field("2 Column Address2") .content var textThirdColumn=Field("4 c Address") .content var textFourthColumn=Field("4c Address 2") .content var targetFrameName = "Address"; var maxColumnWidthInches = 4.5; var GutterWidthInches = 0.2; if (FusionPro.inValidation) textFirstColumn = "This only works in composition."; var tm = new FusionProTextMeasure; tm.CalculateTextExtent(textFirstColumn); tm.CalculateTextExtent(textSecondColumn); tm.CalculateTextExtent(textThirdColumn); tm.CalculateTextExtent(textFourthColumn); if (tm.messages) ReportError("Text Measurement error: " + tm.messages); var FrameWidth = FindTextFrame(targetFrameName).GetSettableTextWidth(); var FirstColumnWidth = Math.min(tm.textWidth, maxColumnWidthInches * 2700); var SecondColumnWidth = Math.min(tm.textWidth, maxColumnWidthInches * 2700); var ThirdColumnWidth = Math.min(tm.textWidth, maxColumnWidthInches * 2700); var FourthColumnWidth = Math.min(tm.textWidth, maxColumnWidthInches * 2700); var GutterWidth = GutterWidthInches * 45000; var myTable = new FPTable; myTable.AddColumns(FirstColumnWidth, GutterWidth, SecondColumnWidth, ThirdColumnWidth, FourthColumnWidth,FirstColumnWidth-SecondColumnWidth-ThirdColumnWidth-FourthColumnWidth); myTable.AddRows(4); //table.Rows[0].Cells[0].SetBorders("Thin", "Black", "Top", "Bottom", "Left", "Right"); var CellMargins = new FPTableMargins; CellMargins.Top = 0; CellMargins.Bottom = 0; CellMargins.Left = 0; CellMargins.Right = 0; myTable.Rows[0].SetContents(Field("2 Column Address 1"), Field("2 Column Address2"), "textSecondColumn", "textSecondColumn"); myTable.Rows[1].SetContents("textFirstColumn", "textSecondColumn", "textSecondColumn", "textSecondColumn"); myTable.Rows[2].SetContents("textFirstColumn", "textSecondColumn", "textSecondColumn", "textSecondColumn"); myTable.Rows[3].SetContents("textFirstColumn", "textSecondColumn", "textSecondColumn", "textSecondColumn"); return myTable.MakeTags(); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.