问题
I want my columns' width be auto size, but I know this is impossible, so I try to use with the function MeasureString
without success.
Here is my code:
Document doc = new Document(PageSize.A4, 20, 20, 72, 72);
doc.Open();
PdfPTable t=new PdfPTable(2);
//Here I want to know the size of the column.
.
.
.
doc.Close();
I know I need an object to set the function MeasureString
on it, but I don't know which object.
回答1:
Calling GetWidthPoint(string text, float fontSize)
on an instance of iTextSharp.text.Font.BaseFont
will return the width of a given string for that particular font.
来源:https://stackoverflow.com/questions/15765623/measurestring-with-itext