【发布时间】:2011-06-20 19:21:21
【问题描述】:
如何让两个单元格垂直对齐。目前,第二个单元格呈现在第一个单元格下方。第一个单元格是图像,第二个单元格是文本。这是我的代码。
private Document pdoc;
Font font99 = FontFactory.GetFont("HELVETICA", 60);
PdfPTable pdfRatingTable = new PdfPTable(2);
PdfPCell pRatCell = null;
pdfRatingTable.WidthPercentage = 100;
pdfRatingTable.SetWidths(new int[] { 75, 25 });
hImage = iTextSharp.text.Image.GetInstance(MapPath("~/Images/fyler3_Rating.jpg"));
NewWidth = 338;
MaxHeight = 18;
if (hImage.Width <= NewWidth)
{
NewWidth = hImage.Width;
}
NewHeight = hImage.Height * NewWidth / hImage.Width;
if (NewHeight > MaxHeight)
{
NewWidth = hImage.Width * MaxHeight / hImage.Height;
NewHeight = MaxHeight;
}
ratio = hImage.Width / hImage.Height;
hImage.ScaleAbsolute(NewWidth, NewHeight);
pRatCell = new PdfPCell(hImage);
pRatCell.Border = 0;
pRatCell.PaddingLeft = 20f;
pRatCell.HorizontalAlignment = Element.ALIGN_LEFT;
pdfRatingTable.AddCell(pRatCell);
pRatCell = new PdfPCell(new Phrase(new Chunk("405", font99)));
pRatCell.HorizontalAlignment = Element.ALIGN_LEFT;
pRatCell.Border = 0;
pRatCell2.VerticalAlignment = Element.ALIGN_TOP;
pdfRatingTable.AddCell(pRatCell);
pdoc.Add(pdfRatingTable);
【问题讨论】:
标签: c# itextsharp