List of usage examples for com.itextpdf.text Rectangle BOTTOM
int BOTTOM
To view the source code for com.itextpdf.text Rectangle BOTTOM.
Click Source Link
Rectangle
. From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java
License:Apache License
/** * header ? footer /*from www.ja v a2 s . c o m*/ */ public void onEndPage(PdfWriter writer, Document document) { if (titleFlag) return; Font font = new Font(bfKorean, 9); PdfPTable hTable = new PdfPTable(1); PdfPTable ftable = new PdfPTable(3); try { hTable.setWidths(new int[] { 100 }); hTable.setTotalWidth(500); hTable.setLockedWidth(true); hTable.getDefaultCell().setFixedHeight(15); hTable.getDefaultCell().setBorder(Rectangle.BOTTOM); hTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); hTable.addCell(new Phrase(MessageUtil.getMessage("pdf.message.header.title"), font)); hTable.writeSelectedRows(0, -1, 50, 803, writer.getDirectContent()); ftable.setWidths(new int[] { 100, 100, 100 }); ftable.setTotalWidth(500); ftable.setLockedWidth(true); ftable.getDefaultCell().setBorder(Rectangle.TOP); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); ftable.addCell(new Phrase(MessageUtil.getMessage("pdf.message.footer.left"), font)); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); if (pagingFlag) ftable.addCell(new Phrase( MessageUtil.getMessage("pdf.message.footer.center", String.valueOf(writer.getPageNumber())), font)); else ftable.addCell(""); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); ftable.addCell(new Phrase(String.valueOf(new SimpleDateFormat("yyyy/MM/dd").format(new Date())), font)); ftable.writeSelectedRows(0, -1, 50, 55, writer.getDirectContent()); } catch (Exception de) { throw new ExceptionConverter(de); } }
From source file:com.automaster.autoview.server.servlet.TableHeader.java
/** * Adds a header to every page//w w w .j ava 2 s . co m * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage( * com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document) */ public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try { table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(header); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Pgina %d de", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } catch (DocumentException de) { throw new ExceptionConverter(de); } }
From source file:com.deadormi.servlet.CreaPdfServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w. j a va2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url = request.getQueryString(); Integer gruppo_id = Integer.parseInt(url.substring(url.indexOf("=") + 1, url.length())); List<Utente> iscritti = null; List<Post> posts = null; Gruppo gruppo = null; Utente utente = null; String imageUrl = null; String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); try { iscritti = UtenteController.getUserByGroupId(request, gruppo_id); gruppo = GruppoController.getGruppoById(request, gruppo_id); } catch (SQLException ex) { log.error(ex); } // step 1: creation of a document-object Document document = new Document(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); String incipit = "Report del " + CurrentDate.getCurrentDate() + "\n"; Paragraph pIncipit = new Paragraph(incipit, FontFactory.getFont(FontFactory.HELVETICA, 14, BaseColor.BLACK)); pIncipit.setAlignment(Element.ALIGN_CENTER); pIncipit.setSpacingAfter(10); document.add(pIncipit); String title = "Gruppo " + gruppo.getNome(); Paragraph pTitle = new Paragraph(title, FontFactory.getFont(FontFactory.HELVETICA, 18, BaseColor.BLUE)); pTitle.setAlignment(Element.ALIGN_CENTER); pTitle.setSpacingAfter(40); document.add(pTitle); PdfPCell labelNome = new PdfPCell(new Paragraph("Nome utente")); PdfPCell labelNumPost = new PdfPCell(new Paragraph("Num. post")); PdfPCell labelData = new PdfPCell(new Paragraph("Data ultimo post")); labelNome.setBorder(Rectangle.NO_BORDER); labelNumPost.setBorder(Rectangle.NO_BORDER); labelData.setBorder(Rectangle.NO_BORDER); for (int i = 0; i < iscritti.size(); i++) { utente = iscritti.get(i); try { posts = PostController.getPostByGruppoIdAndUserId(request, gruppo_id, utente.getId_utente()); } catch (SQLException ex) { Logger.getLogger(CreaPdfServlet.class.getName()).log(Level.SEVERE, null, ex); } if (utente.getNome_avatar() != null) { imageUrl = baseUrl + request.getContextPath() + AVATAR_RESOURCE_PATH + "/" + utente.getId_utente() + "_" + utente.getNome_avatar(); ; } else { imageUrl = baseUrl + request.getContextPath() + "/res/images/user_avatar.png"; } Image image = Image.getInstance(new URL(imageUrl)); image.scaleToFit(50, 50); PdfPTable table = new PdfPTable(3); PdfPCell cellAvatar = new PdfPCell(image); cellAvatar.setHorizontalAlignment(Element.ALIGN_CENTER); cellAvatar.setBorder(Rectangle.NO_BORDER); cellAvatar.setRowspan(3); PdfPCell cellNome = new PdfPCell(new Paragraph(utente.getUsername() + "")); cellNome.setBorder(Rectangle.NO_BORDER); PdfPCell cellNumPost = new PdfPCell(new Paragraph(posts.size() + "")); cellNumPost.setBorder(Rectangle.NO_BORDER); //L'ultimo sempre il piu recente siccome la query ORDER BY data_creazione PdfPCell cellData; if (posts.size() != 0) { cellData = new PdfPCell(new Paragraph(posts.get(posts.size() - 1).getData_creazione())); } else { cellData = new PdfPCell(new Paragraph("N/A")); } cellData.setBorder(Rectangle.NO_BORDER); PdfPCell cellVoidBottom = new PdfPCell(new Paragraph(" ")); cellVoidBottom.setBorder(Rectangle.BOTTOM); cellVoidBottom.setPaddingBottom(10); cellVoidBottom.setColspan(3); PdfPCell cellVoidTop = new PdfPCell(new Paragraph(" ")); cellVoidTop.setBorder(Rectangle.NO_BORDER); cellVoidTop.setPaddingTop(10); cellVoidTop.setColspan(3); table.addCell(cellVoidTop); table.addCell(cellAvatar); table.addCell(labelNome); table.addCell(cellNome); table.addCell(labelNumPost); table.addCell(cellNumPost); table.addCell(labelData); table.addCell(cellData); table.addCell(cellVoidBottom); document.add(table); } document.close(); response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "inline; filename=ahahah.pdf"); OutputStream os = response.getOutputStream(); baos.writeTo(os); os.flush(); os.close(); } catch (DocumentException ex) { Logger.getLogger(CreaPdfServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.hris.payroll.reports.AdvancesReportPdf.java
public AdvancesReportPdf(int branchId, Date payrollDate, String reportType) { this.branchId = branchId; this.payrollDate = payrollDate; this.reportType = reportType; Document document = null;/*from w w w. j av a 2 s . com*/ Rectangle pageSize = new Rectangle(318, 825); try { document = new Document(PageSize.A4.rotate(), 37, 37, 37, 37); PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open(); int tradeId = cs.getTradeIdByBranchId(branchId); int corporateId = cs.getCorporateIdByTradeId(tradeId); Paragraph reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase(cs.getCorporateById(corporateId).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Trade: " + cs.getTradeById(tradeId).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Branch: " + cs.getBranchById(getBranchId()).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Advances Type: " + getReportType(), content)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Payroll Period: " + CommonUtil.changeDateFormat( ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()).getPayrollDate().toString()), content)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Cut-off Date: " + CommonUtil.changeDateFormat(ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()) .getAttendancePeriodFrom().toString()) + " - " + CommonUtil.changeDateFormat(ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()) .getAttendancePeriodTo().toString()), content)); document.add(reportHeader); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); PdfPTable table = new PdfPTable(3); // table.setWidthPercentage(100); table.setTotalWidth(new float[] { 180, 120, 300 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase("EMPLOYEE", boldFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("AMOUNT", boldFont)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("PARTICULARS", boldFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); String middlename; double grandTotalAmount = 0; double subTotalAmount; int prCounter = 0; int advancesCounter; for (PayrollRegister pr : ps.findByBranch(getBranchId(), getPayrollDate())) { if (pr.getMiddlename().isEmpty() || pr.getMiddlename() == null) { middlename = ""; } else { middlename = pr.getMiddlename().toUpperCase(); } String employee = pr.getLastname().toUpperCase() + ", " + pr.getFirstname().toUpperCase() + " " + middlename; subTotalAmount = 0; advancesCounter = 0; for (Advances a : as.findByPayroll(pr.getPayrollId(), getReportType())) { cellLabel = new PdfPCell(); parLabel = new Paragraph(); if (advancesCounter == 0) { parLabel.add(new Phrase(employee, content)); } else { parLabel.add(new Phrase("", content)); } parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.NO_BORDER); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase(CommonUtil.formatNumValue(a.getAmount()), content)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); subTotalAmount = subTotalAmount + a.getAmount(); advancesCounter++; if (advancesCounter == as.findByPayroll(pr.getPayrollId(), getReportType()).size()) { cellLabel.setBorder(Rectangle.BOTTOM); } else { cellLabel.setBorder(Rectangle.NO_BORDER); } table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase(a.getParticulars(), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.NO_BORDER); table.addCell(cellLabel); } if (subTotalAmount != 0) { subTotal(table, subTotalAmount); } grandTotalAmount = grandTotalAmount + subTotalAmount; prCounter++; } grandTotal(table, grandTotalAmount); document.add(table); } catch (DocumentException ex) { Logger.getLogger(AdvancesReportPdf.class.getName()).log(Level.SEVERE, null, ex); } finally { document.close(); } }
From source file:com.hris.payroll.reports.AdvancesReportPdf.java
private void subTotal(PdfPTable table, double subTotalAmount) { PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel);// www .j a v a 2 s . co m cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase( "SUB TOTAL: " + CommonUtil.formatNumValue(CommonUtil.roundOffToTwoDecimalPlaces(subTotalAmount)), content)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); }
From source file:com.hris.payroll.reports.AdvancesReportPdf.java
private void grandTotal(PdfPTable table, double grandTotalAmount) { // PdfPCell cellLabel = new PdfPCell(); // Paragraph parLabel = new Paragraph(); // parLabel.add(new Phrase("", content)); // parLabel.setAlignment(Element.ALIGN_LEFT); // cellLabel.addElement(parLabel); // cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); // cellLabel.setBorder(Rectangle.BOTTOM); // cellLabel.setPaddingBottom(10); // table.addCell(cellLabel); PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase( "GRAND TOTAL: " + CommonUtil.formatNumValue(CommonUtil.roundOffToTwoDecimalPlaces(grandTotalAmount)), content));// w w w . ja va2 s . c o m parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setColspan(2); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); }
From source file:com.hris.payroll.reports.AdvancesSummaryReportPdf.java
public AdvancesSummaryReportPdf(int branchId, Date payrollDate) { this.branchId = branchId; this.payrollDate = payrollDate; Document document = null;//from ww w.j a v a 2 s .com Rectangle pageSize = new Rectangle(318, 825); try { document = new Document(PageSize.A4.rotate(), 37, 37, 37, 37); PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open(); int tradeId = cs.getTradeIdByBranchId(branchId); int corporateId = cs.getCorporateIdByTradeId(tradeId); Paragraph reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase(cs.getCorporateById(corporateId).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Trade: " + cs.getTradeById(tradeId).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Branch: " + cs.getBranchById(getBranchId()).toUpperCase(), header)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Advances Summary", content)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Payroll Period: " + CommonUtil.changeDateFormat( ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()).getPayrollDate().toString()), content)); document.add(reportHeader); reportHeader = new Paragraph(); reportHeader.setAlignment(Element.ALIGN_LEFT); reportHeader.add(new Phrase("Cut-off Date: " + CommonUtil.changeDateFormat(ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()) .getAttendancePeriodFrom().toString()) + " - " + CommonUtil.changeDateFormat(ps.findPayrollRegisterByBranch(getBranchId(), getPayrollDate()) .getAttendancePeriodTo().toString()), content)); document.add(reportHeader); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); PdfPTable table = new PdfPTable(4); // table.setWidthPercentage(100); table.setTotalWidth(new float[] { 180, 120, 130, 300 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase("EMPLOYEE", boldFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("AMOUNT", boldFont)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("ADVANCES TYPE", boldFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("PARTICULARS", boldFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); String middlename; double grandTotalAmount = 0; double subTotalAmount; int prCounter = 0; int advancesCounter; for (PayrollRegister pr : ps.findByBranch(getBranchId(), getPayrollDate())) { if (pr.getMiddlename().isEmpty() || pr.getMiddlename() == null) { middlename = ""; } else { middlename = pr.getMiddlename().toUpperCase(); } String employee = pr.getLastname().toUpperCase() + ", " + pr.getFirstname().toUpperCase() + " " + middlename; subTotalAmount = 0; advancesCounter = 0; for (Advances a : as.findByPayroll(pr.getPayrollId())) { cellLabel = new PdfPCell(); parLabel = new Paragraph(); if (advancesCounter == 0) { parLabel.add(new Phrase(employee, content)); } else { parLabel.add(new Phrase("", content)); } parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.NO_BORDER); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase(CommonUtil.formatNumValue(a.getAmount()), content)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); subTotalAmount = subTotalAmount + a.getAmount(); advancesCounter++; if (advancesCounter == as.findByPayroll(pr.getPayrollId()).size()) { cellLabel.setBorder(Rectangle.BOTTOM); } else { cellLabel.setBorder(Rectangle.NO_BORDER); } table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase(a.getAdvanceType(), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.NO_BORDER); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase(a.getParticulars(), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.NO_BORDER); table.addCell(cellLabel); } if (subTotalAmount != 0) { subTotal(table, subTotalAmount); } grandTotalAmount = grandTotalAmount + subTotalAmount; prCounter++; } grandTotal(table, grandTotalAmount); document.add(table); } catch (DocumentException ex) { Logger.getLogger(AdvancesReportPdf.class.getName()).log(Level.SEVERE, null, ex); } finally { document.close(); } }
From source file:com.hris.payroll.reports.AdvancesSummaryReportPdf.java
private void subTotal(PdfPTable table, double subTotalAmount) { PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel);/* w w w . j av a 2 s . c om*/ cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase( "SUB TOTAL: " + CommonUtil.formatNumValue(CommonUtil.roundOffToTwoDecimalPlaces(subTotalAmount)), content)); parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); }
From source file:com.hris.payroll.reports.AdvancesSummaryReportPdf.java
private void grandTotal(PdfPTable table, double grandTotalAmount) { // PdfPCell cellLabel = new PdfPCell(); // Paragraph parLabel = new Paragraph(); // parLabel.add(new Phrase("", content)); // parLabel.setAlignment(Element.ALIGN_LEFT); // cellLabel.addElement(parLabel); // cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); // cellLabel.setBorder(Rectangle.BOTTOM); // cellLabel.setPaddingBottom(10); // table.addCell(cellLabel); PdfPCell cellLabel = new PdfPCell(); Paragraph parLabel = new Paragraph(); parLabel.add(new Phrase( "GRAND TOTAL: " + CommonUtil.formatNumValue(CommonUtil.roundOffToTwoDecimalPlaces(grandTotalAmount)), content));// w w w .j av a 2 s . com parLabel.setAlignment(Element.ALIGN_RIGHT); cellLabel.addElement(parLabel); cellLabel.setColspan(2); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setPaddingLeft(20); cellLabel.setVerticalAlignment(Element.ALIGN_MIDDLE); cellLabel.setBorder(Rectangle.BOTTOM); cellLabel.setPaddingBottom(10); table.addCell(cellLabel); }
From source file:com.hris.payroll.reports.PayslipReportPDF.java
private PdfPTable leftColumnTable(PayrollRegister pr, Date payrollDate) throws DocumentException { PdfPTable table = new PdfPTable(3); table.setTotalWidth(new float[] { 120, 20, 103 }); table.setWidthPercentage(100);//from w ww .j a v a2 s.c o m table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setLockedWidth(true); PdfPCell cellTitle = new PdfPCell(); cellTitle.setColspan(3); Paragraph parTitle = new Paragraph(); parTitle.add(new Phrase("Payslip: ", header)); parTitle.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(parTitle); cellTitle.setBorder(cellBorder); table.addCell(cellTitle); PdfPCell cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); Paragraph parLabel = new Paragraph(); parLabel.add( new Phrase("Payroll Date: " + CommonUtil.convertDateFormat(getPayrollDate().toString()), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // Paragraph parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(getPayrollDate().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); parLabel.add( new Phrase( "Cut-off Date: " + CommonUtil.changeDateFormat(pr.getAttendancePeriodFrom().toString()) + " - " + CommonUtil.changeDateFormat(pr.getAttendancePeriodTo().toString()), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // Paragraph parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(pr.getAttendancePeriodFrom().toString())+" - "+CommonUtil.convertDateFormat(pr.getAttendancePeriodFrom().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); String middlename; if (pr.getMiddlename() == null || pr.getMiddlename().isEmpty()) { middlename = " "; } else { middlename = String.valueOf(pr.getMiddlename().toUpperCase().charAt(0)) + ". "; } String name = pr.getLastname().toUpperCase() + ", " + pr.getFirstname().toUpperCase() + " " + middlename; parLabel.add(new Phrase("Employee Name: " + name, content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // cellValue = new PdfPCell(); //// cellValue.setUseAscender(true); // parValue = new Paragraph(); // parValue.add(new Phrase(pr.getLastname().toUpperCase()+", "+pr.getFirstname().toUpperCase()+" "+pr.getMiddlename().toUpperCase().charAt(0)+".", employeeName)); //// parValue.add(new Phrase("NAME", content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); String position = (ephs.findByEmployee(pr.getEmployeeId()).getPosition() == null) ? "N/A" : ephs.findByEmployee(pr.getEmployeeId()).getPosition().toUpperCase(); parLabel.add(new Phrase("POSITION: " + position, smallerFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(new Date().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("Monthly/Daily Rate: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); Paragraph parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getRate()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("Half-month Rate: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getHalfMonthSalary()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Overtime: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getOvertimePay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Holiday Premium: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double premium = (pr.getLegalHolidayPay() + pr.getSpecialHolidayPay()) - (pr.getTotalLatesHolidayDeduction() + pr.getTotalUndertimeHolidayDeduction()); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(premium)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Working Day-off: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getWorkingDayOffPay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Night Differential: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getNightDifferential())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Absences/Lates/Undertime: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double alu = pr.getAbsences() + pr.getTotalLatesDeduction() + pr.getTotalUndertimeDeduction(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(alu)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("GROSS PAY: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getGrossPay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Allowances: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("COLA: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getColaAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Meal Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getMealAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("AFL: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getAllowanceForLiquidation()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Transportation Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); cellLabel.setColspan(2); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getTransportationAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Housing Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getOtherAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Communications Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getCommunicationAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL PAY: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double totalPay = pr.getGrossPay() + pr.getCommunicationAllowance() + pr.getTransportationAllowance() + pr.getColaAllowance() + pr.getPerDiemAllowance() + pr.getMealAllowance() + pr.getOtherAllowance() + pr.getAllowanceForLiquidation(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(totalPay)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("DEDUCTIONS: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("SSS Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getSss())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("PHIC Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getPhic())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("HDMF Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getHdmf())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Withholoding Taxes: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getTax())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("SSS Loan: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "sss loan"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("HDMF Loan: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "hdmf loan"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Additional HDMF Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase( String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces( as.findAdvancesTotalAmount(pr.getPayrollId(), "additional HDMF contribution"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("PAG-IBIG 2: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "pag-ibig ii"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Advances to O/E: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Bond: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash bond"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Advance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash advance"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Lending: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "lending"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Jewelry: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "jewelry"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Staffhouse: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "staffhouse"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Hotel and Restaurant Charges: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase( String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces( as.findAdvancesTotalAmount(pr.getPayrollId(), "hotel and restaurant charges"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Shortages: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash shortages"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Employee Charges: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "employee charges"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("ATM Initial Deposit: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "atm initial deposit"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Others__________________: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double otherCharges = as.findAdvancesTotalAmount(pr.getPayrollId(), "advances to o/e") + as.findAdvancesTotalAmount(pr.getPayrollId(), "other charges"); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(otherCharges)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL DEDUCTIONS:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double totalDeductions = as.findAdvancesTotalAmount(pr.getPayrollId()) + pr.getTax() + pr.getPhic() + pr.getHdmf() + pr.getSss(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(totalDeductions)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("NET PAY:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double netPay = CommonUtil.roundOffToTwoDecimalPlaces(totalPay - totalDeductions); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(netPay)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("Adjustments:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getAdjustments())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); // parLabel.add(new Phrase("_____________________________", content)); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); // parValue.add(new Phrase(String.valueOf(totalPay - totalDeductions), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL AMOUNT TO BE RECEIVED:", smallFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(netPay + pr.getAdjustments())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("Prepared By: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); // cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase("Conforme: ", content)); parValue.setAlignment(Element.ALIGN_LEFT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ int userId = ubas.findUserByBranch(getBranchId()); String employeeId = us.findEmployeeIdByUserId(userId); Employee e = es.findEmployeeById(employeeId); String payrollClerkMiddlename; if (e.getMiddlename() == null || e.getMiddlename().isEmpty()) { payrollClerkMiddlename = " "; } else { payrollClerkMiddlename = String.valueOf(e.getMiddlename().toUpperCase().charAt(0)) + ". "; } String payrollClerk = e.getFirstname().toUpperCase() + " " + payrollClerkMiddlename + e.getLastname().toUpperCase(); String employeeMiddlename; if (pr.getMiddlename() == null || pr.getMiddlename().isEmpty()) { employeeMiddlename = " "; } else { employeeMiddlename = String.valueOf(pr.getMiddlename().toUpperCase().charAt(0)) + ". "; } String employee = pr.getFirstname().toUpperCase() + " " + employeeMiddlename + pr.getLastname().toUpperCase(); cellLabel = new PdfPCell(); cellLabel.setPaddingTop(30); parLabel = new Paragraph(); parLabel.add(new Phrase(payrollClerk, smallerFont)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setPaddingTop(30); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setPaddingTop(30); parValue = new Paragraph(); parValue.add(new Phrase(employee, smallerFont)); parValue.setAlignment(Element.ALIGN_CENTER); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.BOTTOM); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); // parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Payroll Clerk", content)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); // parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase("Employee", content)); parValue.setAlignment(Element.ALIGN_CENTER); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); return table; }