亲爱的互联网社区 .
我正在尝试使用带斜体文本的一行页脚单元格构建一个itextsharp PdfPTable,我希望对像量值这样的东西进行正确对齐 .
要么我做错了,要么设置对齐和样式是互斥的 .
private void AddCellFooterRightAlign(PdfPTable pdfPTable, string text)
{
var phrase = new Phrase(text)
{
Font = FontFactory.GetFont("Arial", Font.DEFAULTSIZE, Font.ITALIC),
};
var pdfPCell = new PdfPCell(phrase)
{
HorizontalAlignment = Element.ALIGN_RIGHT,
};
pdfPTable.AddCell(pdfPCell);
}
这会产生一个具有右对齐,正常样式文本的单元格 .
private void AddCellFooterRightAlign(PdfPTable pdfPTable, string text)
{
var phrase = new Phrase(text)
{
Font = FontFactory.GetFont("Arial", Font.DEFAULTSIZE, Font.ITALIC),
};
var pdfPCell = new PdfPCell()
{
HorizontalAlignment = Element.ALIGN_RIGHT,
};
pdfPCell.AddElement(phrase);
pdfPTable.AddCell(pdfPCell);
}
这产生相反的结果:正常对齐(左),斜体样式的文本 .
注意细微差别:通过将Phrase-object发送到Cell构造函数中,我保留了对齐,但是通过使用AddElement,我保留了字体样式 .
注意:在可预见的将来,我坚持使用v.5.5.3.0 .
谢谢! -S