2013-06-11 1 views
0

itextpdf를 사용하여 셀의 테두리 4 가지 색상을 설정하고 싶습니다. 아래 코드를 사용하면 작동하지 않습니다. 제발 도와주세요. 이것을 해결하십시오.자바에서 itextpdf를 사용하여 표 셀의 테두리에 다른 색상을 설정하는 방법

private static PdfPTable insertCell(PdfPTable table, String text, int align, int colspan, Font font){ 

     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); 
     cell.setHorizontalAlignment(align); 
     cell.setVerticalAlignment(Element.ALIGN_MIDDLE);   
     cell.setColspan(colspan); 

     cell.setBackgroundColor(new BaseColor(hex2Rgb(color)));    
     cell.setBorderColorTop(BaseColor.BLUE); 
     cell.setBorderWidthTop(1f); 
     cell.setBorder(Rectangle.TOP); 
     cell.setBorderColorRight(BaseColor.ORANGE); 
     cell.setBorderWidthRight(1f); 
    cell.setBorder(Rectangle.RIGHT); 
     cell.setBorderColorBottom(BaseColor.RED); 
     cell.setBorderWidthBottom(1f); 
     cell.setBorder(Rectangle.BOTTOM); 
     cell.setBorderColorLeft(BaseColor.GREEN); 
     cell.setBorderWidthLeft(1f); 
     cell.setBorder(Rectangle.LEFT); 

     cell.setMinimumHeight(25f); 
     //add the call to the table 
     table.addCell(cell); 

     return table; 
     } 

답변

0

왜 같은 셀에 다른 테두리를 설정 했습니까? 이전에 설정된 색상이 제거됩니다. 테두리 색상 만 설정하면됩니다. 모두 제거

cell.setBorder(Rectangle.Something); 

가끔씩 있습니다. 당신은 특정 테두리 ... 덕분에 다음 입력을 설정하고 작동 이제 색상을

+0

을 설정 한 후 color.But가 국경을 재설정하지 않는 설정하려면

... :) – user2210071

+0

당신은 환영 친구입니다 –

+0

왼쪽의 오른쪽 기호도 클릭하여 답을 수락 할 수 있습니다. D –