セルの任意位置に直線を引きたい!とか,2重線を引きたい!!とか
丸描きたい!!!とか,いろいろ,Bitmap系の小細工をやりたい場合
たとえば,こんな感じで,下線を引きたいとか?(Borderプロパティあたりでもこれぐらいなら実現できますけど:汗)
IPdfPCellEventインターフェースの継承クラスを作って,
CellLayout()メソッドを定義してやればよろしい感じ
ソースはこんな感じにて (セル内に丸を描きたい場合のソースはこちら)
- //Cell描画イベントクラス
- private class _add_event_MidasiLineYoko : IPdfPCellEvent {
- public void CellLayout( PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
- {
- PdfContentByte cb = canvases[PdfPTable.TEXTCANVAS];
- cb.SetLineWidth(1.5f);
- cb.MoveTo(position.Left, position.Bottom - 3);
- cb.LineTo(position.Right, position.Bottom - 3);
- cb.Stroke();
- //直線だけじゃなく,丸でも,☆でも,Bitmapでも描画できまする(Bitmapだけは試してない:汗)
- }
- }
- cell.HorizontalAlignment = Element.ALIGN_LEFT ;
- cell.BackgroundColor = BaseColor.WHITE;
- cell.VerticalAlignment = Element.ALIGN_MIDDLE;
- cell.FixedHeight = 22f;
- cell.Border = Rectangle.NO_BORDER;
- cell.CellEvent = line; // <--Cell描画イベントにインスタンスをセット
- tbl.AddCell(pcell);