我用大块尝试大胆的我的字体。但特别的是,我的标签,但在addcell下一个DataReader中写的。
这是我如何试图对我的DataReader内格式化我的标签
table.AddCell(phrase.Add(新组块(测试,normalFont))+ DR [0]的ToString());这是声明短语和字体类型:
VAR normalFont = FontFactory.GetFont(FontFactory.HELVETICA,12);VAR短语=新词();这是正在显示的内容:
但是之前,我试图格式化我的标签这是怎么看起来像
这是我只需直接添加一个标签到我的 table.AddCell
table.AddCell(DR [0]的ToString());解决方案
您传递
phrase.Add(新组块(测试,normalFont))+ DR [0]的ToString()到 table.AddCell 。过载 Phrase.Add 这里使用被声明为
public虚拟新布尔添加(IElement元)
的(CF Phrase.cs )的
因此, phrase.Add(新组块(测试,normalFont))计算结果为布尔值真正你有
真+ DR [0]的ToString()现在布尔被转换为字符串本身:
真+ DR [0]的ToString()在你的情况 D R [0]的ToString()似乎包含管理员。所以:
真+管理员从今往后:
Trueadmin和,因为这字符串传递给 table.AddCell ,你得到你所看到的。
相反,你可能想要做的线沿线的东西:
phrase.Add(新组块(测试,normalFont));phrase.Add(DR [0]的ToString());table.AddCell(短语);I'm trying to bold my font by using chunk. But the special thing is that my label is written under the addcell within a datareader.
This is how i attempt to format my label within my datareader
table.AddCell(phrase.Add(new Chunk("test:", normalFont)) + dr[0].ToString());This is the declaration to phrase and font type:
var normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 12); var phrase = new Phrase();And this is what is being displayed:
However before i attempt to format my label this is how it will look like
This is where i just directly add a label into my table.AddCell
table.AddCell(dr[0].ToString());解决方案
You pass
phrase.Add(new Chunk("test:", normalFont)) + dr[0].ToString()to table.AddCell. The overload of Phrase.Add used here is declared as
public virtual new bool Add(IElement element)
(cf. Phrase.cs)
Thus, phrase.Add(new Chunk("test:", normalFont)) evaluates to the boolean value true and you have
true + dr[0].ToString()Now the boolean is converted to a string itself:
"True" + dr[0].ToString()In your case dr[0].ToString() seems to contain "admin". So:
"True" + "admin"Henceforth:
"Trueadmin"And as this string is passed to table.AddCell, you get what you see.
Instead you might want to do something along the lines of:
phrase.Add(new Chunk("test:", normalFont)); phrase.Add(dr[0].ToString()); table.AddCell(phrase);
更多推荐
使用大块时则返回true iTextSharp的
发布评论