2016-12-12 1 views
1

에 나는 iText를 7 대형 테이블을 처리하는 가장 좋은 방법은 내가 다른 내부 테이블이 http://developers.itextpdf.com/examples/tables/clone-large-tables중첩 큰 테이블은 itext7

에 설명되어 있음을 보았다. 큰 테이블이 내부 테이블이라면 어떨까요?

Table outTable = new Table(new float[]{1f},true); 

Cell cellHeader1 = new Cell(); 
cellHeader1.add(new Paragraph("Header 1").addStyle(style)); 
outTable.addHeaderCell(cellHeader1); 

document.add(outTable); 

for (int i=0; i<smallArray.size();i++) { 
    Table innerTable = new Table(new float[]{0.5f,0.5f},true); 
    Cell cellHeader2 = new Cell(1,2); 
    cellHeader2.add(new Paragraph("Header 2").addStyle(style)); 
    innerTable.addHeaderCell(cellHeader2); 

    Cell cellInnerTable = new Cell(); 
    cellInnerTable.add(innerTable); 
    outTable.addCell(cellInnerTable); 

    for(int j=0;j<bigArray.size();j++){ 
     //add cells to innerTable; 
     if (j%20==0){ 
      innerTable.flush(); (1) 
      outTable.flush(); (2) 
     } 
    } 

    innerTable.complete(); (1) 
} 
outTable.complete(); 

(2)이 플러시는 메모리 문제를 해결하지 못합니다.

(1)이 줄은 document가 null이므로 Table 객체에서 539 행의 NullPointerException을 반환합니다. outTable의 부모는 문서이므로 'flush'메서드는 데이터를 문서로 플러시하지만 innerTable의 부모는 문서가 아닌 outTable입니다. 내부 테이블을 outTable 및 outTable에 문서로 플러시하는 방법이 있습니까?

문서를 innerTable로 설정하면 NullPointerException이 발생하지 않습니다. innerTable.setDocument (document);

이제는 innerTable이 outTable이 아닌 문서로 플러시되고 기묘한 일을하기 때문에 제대로 작동하지 않습니다.

대단히 감사합니다!

답변

0

큰 테이블은 Document에 직접 추가 할 경우에만 지원됩니다. 내부 대형 테이블은 지원되지 않으며 가까운 미래에 내부 대형 테이블에 대한 지원을 추가 할 계획이 없습니다.

+0

. 고맙습니다! – antzo

0

보십시오 :

유감이다
for(int j=0;j<bigArray.size();j++){ 
    //add cells to innerTable; 
    if (j%20==0){ 
     Cell cellContent = new Cell(1,2).add(innerTable); 
     outTable.addCell(cellContent); 
     innerTable.flushContent(); // API says is internal but is public and works OK 
     outTable.flush(); 
    } 
}