4
どのようにして2つのセルを垂直に整列させるか。現在、2番目のセルは最初のセルの下にレンダリングされます。最初のセルはイメージで、2番目のセルはテキストです。ここに私のコードです。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(新しいフレーズ(新しいチャンク(これはテストです)))に置き換えました。 2番目のセルは引き続き次の行に表示されます。テーブルの幅を設定しても大丈夫ですか? – bladerunner
私はあなたが本当に次の行にあると確信しているだけでなく、(私は20ptのパッドで期待していた)Much Lowerでないことを確認するためにセルの境界線をオンにすることをお勧めします。 –
国境を設定していただきありがとうございました。最初のセルの上に次のセルに合わせるためにいくつかのパディングが必要でした。もう一度ありがとう。 – bladerunner