MeasureString with IText

坚强是说给别人听的谎言 提交于 2019-12-24 13:48:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!