4
어떻게하면 두 개의 셀을 수직으로 정렬 할 수 있습니까? 현재 두 번째 셀은 첫 번째 셀 아래에 렌더링됩니다. 첫 번째 셀은 이미지이고 두 번째 셀은 텍스트입니다. 여기 내 코드가있다. 이미지가 테이블의 셀 (플러스 오히려 관대 한 패딩)의 최대 폭보다 넓은처럼 다음 셀이 다음 행에 나타나도록itextsharp pdfpcell 수직 정렬 문제
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);
안녕하세요. 이미지를 약간 작게 조정했는데 오른쪽 셀이 여전히 다음 행에있는 것으로 보입니다. 심지어 나는 pRatCell = new PdfPCell (새로운 Phrase (새로운 Chunk ("This is a test")))로 이미지를 대체했습니다. 두 번째 셀은 여전히 다음 행에 나타납니다. 테이블 너비가 맞습니까? – bladerunner
나는 당신이 셀 경계선을 켜기 만하면 정말로 다음 줄에 있고, 훨씬 더 낮을 것 같지 않다. (나는 20pt 패드로 기대한다). –
국경을 설정해 주셔서 감사합니다. 첫 번째 셀의 맨 위에 다음 패딩을 맞추기 위해 약간의 패딩이 필요했습니다. 다시 한번 감사합니다. – bladerunner