我有一個函數,我一直在使用一個很好的時間在java中,它從給定的字符串值數組計算單元格寬度。iText單元格寬度似乎表現不一致
它工作得很好,我最近在c#中編寫了一個函數版本,並沒有給出預期的結果(即文本被包裝成多行) - 下面顯示的java和c#代碼都非常讚賞
這是Java版本;
這是C#版本;
float[] CalculateCellWidths(String[] CellHeaders, iTextSharp.text.Font CellFont)
{
float[] CellWidths = new float[CellHeaders.Length];
for (int i = 0; i < CellHeaders.Length; i++)
{
CellWidths[i] = CellFont.GetCalculatedBaseFont(true).GetWidthPoint(CellHeaders[i], CellFont.CalculatedSize);
}
return CellWidths;
}
不用擔心 - 由於某種原因,如果你設置table.LockWidth = true,它會導致我所看到的行爲 - 所有這一切都應該是現在。 – pkfox