使用大块时则返回true iTextSharp的

编程入门 行业动态 更新时间:2024-10-26 21:32:02
本文介绍了使用大块时则返回true iTextSharp的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我用大块尝试大胆的我的字体。但特别的是,我的标签,但在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的

本文发布于:2023-11-24 10:01:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时则   true   iTextSharp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!