Novacode.Table.SetWidthsPercentage C# (CSharp) Method

SetWidthsPercentage() public method

Set Table column width by prescribing percent
public SetWidthsPercentage ( float widthsPercentage, float totalWidth ) : void
widthsPercentage float column width % list
totalWidth float Total table width. Will be calculated if null sent.
return void
        public void SetWidthsPercentage(float[] widthsPercentage, float? totalWidth)
        {
            if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width
            List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width
            widthsPercentage.ToList().ForEach(pWidth => { widths.Add((pWidth * totalWidth.Value / 100) * (96 / 72)); }); // convert percentage to actual width for all values in array
            SetWidths(widths.ToArray()); // set actual column width
        }