私はC#とiTextSharpを使用しているので、コメントはJavaのソリューションを示しています。
私はこの問題を解決するために同様のことを実装しました。
基本的な事実は、iTextSharpがカスタムボーダーをサポートしていないことですが、PDF上に描画することができます。従って、目的は細胞の底に二本鎖を描くことである。
- 国境
- を既存の非表示は、トリックは、セルにCellEventを実施し、cellevent以内にそれが私たちに正確なを与えたことである
- ドローライン
セルの正確な位置を見つけますしたがって、我々は簡単に物を描きます。以下
public function void DrawACell_With_DOUBLELINE_BOTTOM_BORDER(Document doc, PdfWriter writer){
PdfPTable pt = new PdfPTable(new float[]{1});
Chunk c = new Chunk("A Cell with doubleline bottom border");
int padding = 3;
PdfPCell_DoubleLine cell = new PdfPCell_DoubleLine(PdfPTable pt,new Phrase(c), writer, padding);
pt.AddCell(cell);
doc.Add(pt);
}
public class PdfPCell_DoubleLine : PdfPCell
{
public PdfPCell_DoubleLine(Phrase phrase, PdfWriter writer, int padding) : base(phrase)
{
this.HorizontalAlignment = Element.ALIGN_RIGHT;
//1. hide existing border
this.Border = Rectangle.NO_BORDER;
//2. find out the exact position of the cell
this.CellEvent = new DLineCell(writer, padding);
}
public class DLineCell : IPdfPCellEvent
{
public PdfWriter writer { get; set; }
public int padding { get; set; }
public DLineCell(PdfWriter writer, int padding)
{
this.writer = writer;
this.padding = padding;
}
public void CellLayout(PdfPCell cell, iTextSharp.text.Rectangle rect, PdfContentByte[] canvases)
{
//draw line 1
PdfContentByte cb = writer.DirectContent;
cb.MoveTo(rect.GetLeft(0), rect.GetBottom(0) - padding);
cb.LineTo(rect.GetRight(0), rect.GetBottom(0) - padding);
//draw line 2
cb.MoveTo(rect.GetLeft(0), rect.GetBottom(0) - padding - 2);
cb.LineTo(rect.GetRight(0), rect.GetBottom(0) - padding - 2);
cb.Stroke();
}
}
}
http://stackoverflow.com/questions/21939280/itextsharp-multiple-lines-in-pdfpcell-one-under-another –
@VinothRaj私のC#プロジェクトで動作するコードです私はOPがテキスト行を意味するのではなく、境界線を意味すると思う。 – mkl
[http://stackoverflow.com/questions/31588087](http://stackoverflow.com/questions/31588087) – kuujinbo