Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用IText测量_C#_Itextsharp - Fatal编程技术网

C# 用IText测量

C# 用IText测量,c#,itextsharp,C#,Itextsharp,我希望我的列的宽度是自动大小,但我知道这是不可能的,所以我尝试使用函数MeasureString,但没有成功 这是我的密码: 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(); 我知道我需要一个对象来设置函数Measur

我希望我的列的宽度是自动大小,但我知道这是不可能的,所以我尝试使用函数
MeasureString
,但没有成功

这是我的密码:

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();

我知道我需要一个对象来设置函数
MeasureString
,但我不知道是哪个对象。

iTextSharp.text.Font.BaseFont
的实例上调用
GetWidthPoint(string text,float fontSize)
将返回该特定字体的给定字符串的宽度