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
好吧,當你這樣說的時候很明顯! :) 謝謝! –