2014-11-07 2 views

답변

2

이를 달성하려면 cell events이 필요합니다. 내 책에 여러 가지 예를 제시했습니다. 예를 calendar.pdf를 참조하십시오 :

enter image description here

자바 코드가 백혈구를 만드는 것은 다음과 같습니다

이 코드의 C# 버전에 대한
class CellBackground implements PdfPCellEvent { 

    public void cellLayout(PdfPCell cell, Rectangle rect, 
      PdfContentByte[] canvas) { 
     PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS]; 
     cb.roundRectangle(
      rect.getLeft() + 1.5f, rect.getBottom() + 1.5f, rect.getWidth() - 3, 
      rect.getHeight() - 3, 4); 
     cb.setCMYKColorFill(0x00, 0x00, 0x00, 0x00); 
     cb.fill(); 
    } 
} 

, Where do I find the C# examples?에 가서 장을 클릭하는 예제의 Java 버전의 장에 해당합니다. 예를 들어

, PdfCalendar.cs :

class CellBackground : IPdfPCellEvent { 
    public void CellLayout(
    PdfPCell cell, Rectangle rect, PdfContentByte[] canvas 
) { 
    PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS]; 
    cb.RoundRectangle(
     rect.Left + 1.5f, 
     rect.Bottom + 1.5f, 
     rect.Width - 3, 
     rect.Height - 3, 4 
    ); 
    cb.SetCMYKColorFill(0x00, 0x00, 0x00, 0x00); 
    cb.Fill(); 
    } 
} 

는이 같은 이벤트를 사용할 수 있습니다

CellBackground cellBackground = new CellBackground(); 
cell.CellEvent = cellBackground; 

이제 CellLayout() 방법은 셀이 페이지로 렌더링되는 순간 실행됩니다.

관련 문제