2010-06-18 2 views
0

다음은 내 코드입니다.pdf에서 다음 페이지 시작시 동일한 머리글을 유지하는 방법

private void getActionItems(Document document, Chapter chapter, 
            Section section, Paragraph pas) { 
     List drbRefList = null; 
     try { 
      _actionService = new ActionItemImpl(); 
      _aiBean = new ActionItemData(); 
      if (_aiBean != null) { 
      _actionList = new ArrayList(); 
      LOG.info("business passed here is" + _business); 
     _actionList = _actionService.getActionItemsForPDF(_userSSOID, 
       _business, _reviewID, _connection); 
      } 
     LOG.info(" after calling getActionItemsForPDF"); 
     LOG.info("_actionList" + _actionList); 

     Table tablesh1 = new Table(1, 1); 
     float[] widthsh1 = new float[1]; 
     widthsh1[0] = ReviewConstants.MAGIC_DOTTWELVE; 
     tablesh1.setTableFitsPage(true); 
     tablesh1.setPadding(2); 
     tablesh1.setSpacing(0); 
     tablesh1.setWidth(ReviewConstants.MAGIC_ONEZEROZERO); 
     tablesh1.setWidths(widthsh1); 
     tablesh1.setBorderColor(Color.WHITE); 
     Cell hcell = new Cell(new Paragraph(ReviewConstants.S_ACTIONHEADING, 
        new Font(Font.HELVETICA, fontSize, Font.BOLD, Color.BLUE))); 
     hcell.setHeader(true); 
     tablesh1.addCell(hcell); 
     section.add(tablesh1); 
     Table actionTable = null; 
     String businessUnit = reviewData.getBusinessUnit(); 
     float[] widthac = null; 
     //Updated for Nuclear Energy Engineering Business Unit Requirement by Naveen 
     if(!"Nuclear Energy Engineering".equalsIgnoreCase(businessUnit)){ 
      actionTable = new Table(ReviewConstants.NINE,ReviewConstants.THREE); 
      widthac = new float[ReviewConstants.NINE]; 
      widthac[0] = ReviewConstants.MAGIC_DOTONE; 
      widthac[1] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[2] = ReviewConstants.MAGIC_DOTTWOZERO;  
      widthac[ReviewConstants.THREE] = ReviewConstants.MAGIC_DOTTWOZERO; 
      widthac[ReviewConstants.FOUR] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[ReviewConstants.FIVE] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[ReviewConstants.SIX] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[ReviewConstants.SEVEN] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[ReviewConstants.EIGHT] = ReviewConstants.MAGIC_DOTONEZERO; 
     }else{ 
      actionTable = new Table(ReviewConstants.SIX,ReviewConstants.THREE); 
      widthac = new float[ReviewConstants.SIX]; 
      widthac[0] = ReviewConstants.MAGIC_DOTONE; 
      widthac[1] = ReviewConstants.MAGIC_THREEZERO; 
      widthac[2] = ReviewConstants.MAGIC_THREEZERO; 
      widthac[ReviewConstants.THREE] = ReviewConstants.MAGIC_THREEZERO; 
      widthac[ReviewConstants.FOUR] = ReviewConstants.MAGIC_DOTONEZERO; 
      widthac[ReviewConstants.FIVE] = ReviewConstants.MAGIC_DOTONEZERO; 
     } 
     actionTable.setTableFitsPage(true); 
     actionTable.setPadding(2); 
     actionTable.setSpacing(0); 
     actionTable.setWidth(ReviewConstants.MAGIC_ONEZEROZERO); 
     actionTable.setWidths(widthac); 
     actionTable.setBorderWidth(1); 
     Cell accell = new Cell(new Paragraph(ReviewConstants.S_ACTIONID, 
       new Font(Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell); 

     if(!"Nuclear Energy Engineering".equalsIgnoreCase(businessUnit)){ 
      accell = new Cell(new Paragraph(ReviewConstants.PDF_RT, 
        new Font(Font.HELVETICA, fontSize, Font.BOLD))); 
      accell.setHeader(true); 
      actionTable.addCell(accell); 
     } 
     accell = new Cell(new Paragraph(ReviewConstants.S_REQA, 
       new Font(Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell);   
     accell = new Cell(new Paragraph(ReviewConstants.S_CLOSURE, 
       new Font(Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell); 

     accell = new Cell(new Paragraph(ReviewConstants.S_DISPOSITION, 
       new Font(Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell); 
     //added by santosh on 18 june 
     actionTable.endHeaders(); 
     document.add(actionTable); 

     if(!"Nuclear Energy Engineering".equalsIgnoreCase(businessUnit)){ 
      accell = new Cell(new Paragraph(ReviewConstants.S_DRB_REFERENCE, new Font(
         Font.HELVETICA, fontSize, Font.BOLD))); 
      accell.setHeader(true); 
      actionTable.addCell(accell); 
      accell = new Cell(new Paragraph(ReviewConstants.S_DEADLINE, new Font(
         Font.HELVETICA, fontSize, Font.BOLD))); 
      accell.setHeader(true); 
      actionTable.addCell(accell); 
     } 
     accell = new Cell(new Paragraph(ReviewConstants.S_OWNER, new Font(
        Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell); 
     accell = new Cell(new Paragraph(ReviewConstants.S_STATE, new Font(
       Font.HELVETICA, fontSize, Font.BOLD))); 
     accell.setHeader(true); 
     actionTable.addCell(accell); 
     int acSize = 0; 
     if (_actionList != null) { 
      acSize = _actionList.size(); 
     } 
     for (int i = 0; i < acSize; i++) { 
     _aiBean = (ActionItemData) _actionList.get(i);  
     Cell adCell = new Cell(new Paragraph(_aiBean.getActionID(), new Font(
        Font.HELVETICA, ReviewConstants.MAGIC_EIGHT))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 

     if(!"Nuclear Energy Engineering".equalsIgnoreCase(businessUnit)){ 
      if (_aiBean.getActionItemType().equals("0")) { 
      adCell = new Cell(new Paragraph("Normal", 
        new Font(Font.HELVETICA, fontSize))); 
      } else { 
       adCell = new Cell(new Paragraph("Critical", 
         new Font(Font.HELVETICA, fontSize))); 
      }  
      adCell.setHeader(false); 
      actionTable.addCell(adCell); 
     } 
     adCell = new Cell(new Paragraph(_aiBean.getRequiredAction(), 
         new Font(Font.HELVETICA, fontSize))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 
     adCell = new Cell(new Paragraph(_aiBean.getClosureCriteria(), 
         new Font(Font.HELVETICA, fontSize))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 
     String drbLink = ReviewConstants.EMPTY; 
     drbRefList = new ArrayList(); 
     if (!DRUtils.isEmpty(_aiBean.getState()) 
         && ((_aiBean.getState() 
           .equalsIgnoreCase(ReviewConstants.DRAFT_BEGUN_STATE)) 
           || (_aiBean.getState() 
             .equalsIgnoreCase(ReviewConstants.SCOPE_PROPOSED)) || (_aiBean 
           .getState() 
           .equalsIgnoreCase(ReviewConstants.RES_PROPOSED)))) { 
        drbLink = ReviewConstants.EMPTY; 
        _aiBean.setDisposition(ReviewConstants.EMPTY); 

       } else {      
        drbRefList = _actionService.getDrbRefForPDF(_aiBean.getActionSeqID(), _connection); 
        int drbRefCnt = 0; 
        if (drbRefList != null) { 
         drbRefCnt = drbRefList.size(); 
         int j = 0; 
         for (j = 0; j < drbRefCnt; j++) { 
          LOG.info("drbRefList.get(j)" 
            + drbRefList.get(j).toString()); 
          if (j < (drbRefCnt - 1)) { 
           drbLink += drbRefList.get(j).toString() 
             + ReviewConstants.COMMA_SPACE; 
          } else { 
           drbLink += drbRefList.get(j).toString(); 
          } 
         } 
        } 
       } 
     LOG.info("drbLink" + drbLink); 
     adCell = new Cell(new Paragraph(_aiBean.getDisposition(), 
       new Font(Font.HELVETICA, fontSize))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 
     //Updated for Nuclear Energy Engineering Business Unit Requirement by Naveen 
     if(!"Nuclear Energy Engineering".equalsIgnoreCase(businessUnit)){ 
      adCell = new Cell(new Paragraph(drbLink, new Font(
        Font.HELVETICA, fontSize))); 
      adCell.setHeader(false); 
      actionTable.addCell(adCell);   
      adCell = new Cell(new Paragraph(_aiBean.getDeadline(), 
          new Font(Font.HELVETICA, fontSize))); 
      adCell.setHeader(false); 
      actionTable.addCell(adCell); 
     } 
     adCell = new Cell(new Paragraph(_aiBean.getActionItemOwnerName(), 
         new Font(Font.HELVETICA, fontSize))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 
     adCell = new Cell(new Paragraph(_aiBean.getState(), 
       new Font(Font.HELVETICA, fontSize))); 
     adCell.setHeader(false); 
     actionTable.addCell(adCell); 
     //added by santosh 
     actionTable.endHeaders(); 
     document.add(actionTable); 
     // added by santosh end 
     } 

     /*Phrase headerPhrase = new Phrase(); 
     Table headTab = (Table)actionTable.getElement(0, 5); 
     headerPhrase.add(headTab); 
     HeaderFooter printHeader = new HeaderFooter(headerPhrase,false); 
     System.out.println("addHeader"); 
     document.setHeader(printHeader); 
     actionTable.setLastHeaderRow(1); 

     actionTable.endHeaders(); 
     document.add(actionTable);*/ 
     // added by santosh 
     actionTable.endHeaders(); 
     document.add(actionTable); 
     // added by santosh end 
     section.add(actionTable); 

    } catch (Exception e) { 
     LOG.error("General Exception occured", e); 
     } 
    } 
+0

Welcome to StackOverflow. 좀 더 자세한 정보를 제공하십시오. 이 코드는 무엇을 의미합니까? 문맥은 무엇입니까? 오류가 있습니까? 무슨 일 이니? 무엇을 성취하려고합니까? 사람들은 훨씬 더 기꺼이 도울 것입니다. – Jla

답변

0

내가 템플릿 디자인 & 실행 프레임 워크로 JasperReports를를 사용하는 것이 좋습니다. 그것은 두포에서 iText를 사용합니다. iReports 디자인 툴을 사용하여 이와 유사한 작업을 선언적으로 수행 할 수 있습니다.