나는 이것에 대한 해답을 찾고 있었지만 좋은 지침서를 찾을 수 없다. 나는 pdf를 생성하기 위해 자바 itext를 사용하고있다. 나는 약 2 페이지를 먹는 50 개 이상의 행을 인쇄하는 테이블을 가지고있다. 목록 인쇄를 계속하기 전에 이전 페이지의 마지막 5 행을 다음 페이지로 인쇄해야합니다.다음 페이지에서 테이블의 마지막 5 행을 반복하는 방법은 무엇입니까?
Example: row 31 row 32 row 33 row 34 row 35 row 36 --end of page 1-- row 32 row 33 row 34 row 35 row 36 row 37
이 작업을 수행하는 방법에 대한 어떤 생각?
Currently it prints like this: row 35 row 36 --end of page 1-- row 37 row 38
코드 : (시작 루프에 초점 그 헤더를 신경 쓰지)
PdfPTable table = new PdfPTable(4);
table.setWidthPercentage(97);
table.setWidths(new float[] {10, 45, 25, 25});
PdfPCell c1 = new PdfPCell(new Phrase("Logo", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14)));
c1.setPadding(5);
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setVerticalAlignment(Element.ALIGN_CENTER);
c1.setBorder(0);
c1.setColspan(4);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("09/01/2013 - 09/15/2013", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setPadding(5);
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setVerticalAlignment(Element.ALIGN_CENTER);
c1.setBorder(0);
c1.setColspan(4);
c1.setPaddingBottom(20);
table.addCell(c1);
//start header
c1 = new PdfPCell(new Phrase(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setPaddingBottom(5);
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setBackgroundColor(WebColors.getRGBColor("#99CCFF"));
c1.setBorder(1);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setPaddingBottom(5);
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setBackgroundColor(WebColors.getRGBColor("#99CCFF"));
c1.setBorder(1);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Number", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setPaddingBottom(5);
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setBackgroundColor(WebColors.getRGBColor("#99CCFF"));
c1.setBorder(1);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Amount", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setPaddingBottom(5);
c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
c1.setBackgroundColor(WebColors.getRGBColor("#99CCFF"));
c1.setBorder(1);
table.addCell(c1);
//end header
//start for loop
for(int a=0; a<50; a++)
{
int border=0;
if(a%5==0)
{border=1;}
c1 = new PdfPCell(new Phrase((a+1)+"", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setBorder(border);
c1.setPaddingBottom(5);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Last Name, First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setHorizontalAlignment(Element.ALIGN_LEFT);
c1.setBorder(border);
c1.setPaddingBottom(5);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("1", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setBorder(border);
c1.setPaddingBottom(5);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("1", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)));
c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
c1.setBorder(border);
c1.setPaddingBottom(5);
table.addCell(c1);
}
//end for loop
subCatPart.add(table);
@Sandeep은 : 이미를 발견하고는 내 질문에 –
@Sandeep 추가 코드에 응답하지 않습니다. –
프로그램을 실행할 때마다 테이블의 크기가 항상 같거나 매개 변수에 따라 다릅니다. –