0
亲爱的互联网社区。itextsharp - 使用右对齐斜体文本添加到PdfPTable单元
我正在试图用斜体文本构建一行页脚单元格的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);
}
这产生了相反的结果:正常对齐(左)斜体式文本。
注意细微差别:通过将短语对象发送到单元格构造函数中,我保留对齐方式,但通过使用AddElement,我保留了字体样式。
注意:在可预见的将来,我坚持使用v.5.5.3.0。
谢谢! -S
好吧,当你这样说的时候很明显! :) 谢谢! –