iTextSharp的:这对齐属性在PdfPCell使用? [英] iTextSharp: which alignment properties are used in a PdfPCell?

查看:1018
本文介绍了iTextSharp的:这对齐属性在PdfPCell使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用单元格对齐所以它的工作原理:

When I use the alignment of the cell so it works:

PdfPCell cell1 = new PdfPCell(new Phrase("Text" , Font));
cell1.HorizontalAlignment = 2;



但一旦调整不工作:

But once the alignment does not work:

PdfPCell cell1 = new PdfPCell();
cell1.AddElement(new Phrase("Text 1", Font));
cell1.AddElement(new Phrase("Text 2", Font));
cell1.HorizontalAlignment = 2;



原因?

The reason?

推荐答案

您混淆的文本模式的用的复合模式

在第一个代码段,你的的文本模式的。这意味着该单元格的内容被认为是仅仅文本和电池的性能得到遵守,而加至被忽略小区中的元素的属性

In the first code snippet, you work in text mode. This means that the content of the cell is considered to be text only and the properties of the cell are respected, whereas the properties of the elements added to the cell are ignored.

在第二个代码片段,你的复合模式<工作/ em>的。一个单元开关的复合模式的使用的addElement()方法的时刻。在这种情况下,电池的性能将被忽略。而是该元素的属性使用

In the second code snippet, you work in composite mode. A cell switches to composite mode the moment you use the AddElement() method. In this case, the properties of the cell are ignored. Instead the properties of the elements is used.

有关实例:在文本模式下,单元格的内容只能有一种类型的取向的。在混合模式下,你可以有一个左对齐一个段落,即中心的段落,那就是右对齐一个段落,都在同一个小区。

For instance: in text mode, the content of the cell can only have one type of alignment. In composite mode, you can have a paragraph that is left aligned, a paragraph that is centered, and a paragraph that is right aligned, all in the same cell.

这篇关于iTextSharp的:这对齐属性在PdfPCell使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆