Quantcast

Getting high CPU utilization

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting high CPU utilization

rajasekhar
This post has NOT been accepted by the mailing list yet.
Hi,
I am using ITextPdf 5.4.3 to generate pdf reports.  I am getting high cpu utilization when the PdfTables/PdfCells are added to the document using Itext.  I do have lot of tables to be added to my document.  Below is the sample code to create a table and added to document.  I am calling this method in a loop. Pls help me in resolving this issue.


  private PdfPTable getBatchDetails(BatchSummary batchSummary, String companyCode, String batchIdStr, int accessLevel, NumberFormat nf) throws Exception {
    System.out.println("INside getBatchDetails returns pdfTable");
      PdfPTable detailTable = new PdfPTable(14);
      detailTable.setWidthPercentage(100);
      detailTable.getDefaultCell().setBorder(0);
      detailTable.getDefaultCell().setPadding(0);
      detailTable.setExtendLastRow(false);
     
      PdfPTable subTable = new PdfPTable(9);
      subTable.setWidthPercentage(100);
      subTable.getDefaultCell().setBorder(0);
      subTable.getDefaultCell().setPadding(0);
      subTable.setExtendLastRow(false);
     
      detailTable.addCell(iTextUtil.getCell(1,"Batch ID:", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,payDataBatchSummary.getBatchId(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getWhiteCell(12));
      detailTable.addCell(iTextUtil.getWhiteCell(14));      
     
      //CommonDataPersistence commonDataPersistence = PersistenceImplFactory.getCommonDataPersistence();
     
      for ( Iterator it = payDataBatchSummary.getPayDataSummaryDataList().iterator(); it.hasNext(); ) {
        PayDataSummaryData summaryData = ( PayDataSummaryData ) it.next();
        Employee employee = summaryData.getEmployee();
        detailTable.addCell(iTextUtil.getCell(1,employee.getFileNbr(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
        detailTable.addCell(iTextUtil.getCell(1,employee.getName(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),-1f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
        detailTable.addCell(iTextUtil.getCell(1,summaryData.getPayNumber(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));

        subTable.addCell(iTextUtil.getCell(1,"RateType", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
        subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalRegularHours() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
        subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalOTHours() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
        subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalOtherHours() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
        subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalHours() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
        if(accessLevel != AccessControl.TEMP_ACCESS_LEVEL){
                subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalRegularEarnings() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalOTEarnings() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalOtherEarnings() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalEarnings() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
        }else{
        subTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                subTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
     
        }
        detailTable.addCell(iTextUtil.getTableCellWithBorder(subTable,9,iTextUtil.black,0,0));
        subTable = new PdfPTable(9);
       
     detailTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalDeductionAmount() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
     detailTable.addCell(iTextUtil.getCell(1,nf.format( summaryData.getTotalMemoAmount() ), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
     }
     
      detailTable.addCell(iTextUtil.getWhiteCell(14));
      detailTable.addCell(iTextUtil.getCell(3,"SUBTOTALS FOR BATCH ID:", iTextUtil.getFont(FontFactory.HELVETICA,8,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(11,payDataBatchSummary.getBatchId(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
     
      detailTable.addCell(iTextUtil.getCell(2,"Records:", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(2,payDataBatchSummary.getTotalRecords(), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalRegularHours()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalOTHours()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalOtherHours()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalHours()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      if(accessLevel != AccessControl.TEMP_ACCESS_LEVEL){
                detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalRegularEarnings()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalOTEarnings()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalOtherEarnings()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
                detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalEarnings()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      }else{
      detailTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
             detailTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
             detailTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
             detailTable.addCell(iTextUtil.getCell(1,"***", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));

      }
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalDeductionAmount()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
      detailTable.addCell(iTextUtil.getCell(1,nf.format(payDataBatchSummary.getTotalMemoAmount()), iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_RIGHT,PdfPCell.ALIGN_MIDDLE));
     
      detailTable.addCell(iTextUtil.getWhiteCell(14));
      detailTable.addCell(iTextUtil.getBlackCell(14, .50f));
      detailTable.addCell(iTextUtil.getWhiteCell(14));
      detailTable.addCell(iTextUtil.getWhiteCell(14));
      detailTable.addCell(iTextUtil.getWhiteCell(14));

     return detailTable;
    }
 
    private PdfPTable getOtherTotalDetails (HashMap otherHours, HashMap otherEarnings, HashMap adjDed, HashMap memos, NumberFormat nf, int accessLevel) {
    //System.out.println("Inside GetOtherTotalDetails returns pdfTable");
        PdfPTable mainTable = new PdfPTable(8);
        mainTable.setWidthPercentage(100);
        mainTable.getDefaultCell().setBorder(0);
        mainTable.getDefaultCell().setPadding(0);
        mainTable.setExtendLastRow(false);
        PdfPTable hoursSplitTable = new PdfPTable(2);    
        PdfPTable earningsSplitTable = new PdfPTable(2);
        PdfPTable dedsSplitTable = new PdfPTable(2);
        PdfPTable memosSplitTable = new PdfPTable(2);
       
        mainTable.addCell(iTextUtil.getCell(8,"Other Totals", iTextUtil.getFont(FontFactory.HELVETICA,8,iTextUtil.black),12f,iTextUtil.white,null,false,PdfPCell.ALIGN_LEFT,PdfPCell.ALIGN_MIDDLE));
        mainTable.addCell(iTextUtil.getWhiteCell(14));
        mainTable.addCell(iTextUtil.getWhiteCell(14));      
        hoursSplitTable.addCell(iTextUtil.getCell(2,"OTHER HOURS", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),10f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_TOP));
        earningsSplitTable.addCell(iTextUtil.getCell(2,"OTHER EARNINGS", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),10f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_TOP));
        dedsSplitTable.addCell(iTextUtil.getCell(2,"ADJUST DEDUCTIONS", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),10f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_TOP));
        memosSplitTable.addCell(iTextUtil.getCell(2,"MEMOS", iTextUtil.getFont(FontFactory.HELVETICA,6,iTextUtil.black),10f,iTextUtil.white,null,false,PdfPCell.ALIGN_CENTER,PdfPCell.ALIGN_TOP));
        addOtherTotals(hoursSplitTable, otherHours, nf, earningCodes, accessLevel, "H");
        addOtherTotals(earningsSplitTable, otherEarnings, nf, earningCodes, accessLevel, "E");  
        addOtherTotals(dedsSplitTable, adjDed, nf, dedCodes, accessLevel, "D");  
        addOtherTotals(memosSplitTable, memos, nf, memoCodes, accessLevel, "M");
        PdfPCell p;
        p =iTextUtil.getTableCellWithBorder(hoursSplitTable,2,iTextUtil.black,0,0);
        p.setVerticalAlignment( PdfPCell.ALIGN_TOP);
        mainTable.addCell(p);
        p =iTextUtil.getTableCellWithBorder(earningsSplitTable,2,iTextUtil.black,0,0);
        p.setVerticalAlignment( PdfPCell.ALIGN_TOP);
        mainTable.addCell(p);
        p =iTextUtil.getTableCellWithBorder(dedsSplitTable,2,iTextUtil.black,0,0);
        p.setVerticalAlignment( PdfPCell.ALIGN_TOP);
        mainTable.addCell(p);
        p =iTextUtil.getTableCellWithBorder(memosSplitTable,2,iTextUtil.black,0,0);
        p.setVerticalAlignment( PdfPCell.ALIGN_TOP);
        mainTable.addCell(p);
        mainTable.addCell(iTextUtil.getWhiteCell(8));
        mainTable.addCell(iTextUtil.getBlackCell(8, .50f));
        mainTable.addCell(iTextUtil.getWhiteCell(8));
        return mainTable;
    }  

Regards,
Naga
Loading...