List of usage examples for com.itextpdf.text.pdf PdfPTable addCell
public void addCell(final Phrase phrase)
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable lineTable(FclBl bl, String deliveryDate, String realPath) throws Exception { PdfPCell cell = new PdfPCell(); PdfPCell celL = new PdfPCell(); String path = LoadLogisoftProperties.getProperty("application.image.logo"); String econoPath = LoadLogisoftProperties.getProperty("application.image.econo.logo"); String companyCode = new SystemRulesDAO().getSystemRulesByCode("CompanyCode"); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100);//from w w w.j a va 2s . c o m Paragraph p = null; cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); if (null != bl && bl.getBrand().equalsIgnoreCase("Econo") && ("03").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("OTI") && ("02").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("Ecu Worldwide")) { Image img = Image.getInstance(realPath + path); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DELIVERY ORDER", blackBoldFontheading); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DATE PRINTED : " + DateUtils.formatStringDateToAppFormatMMM(new Date()), blackFontForAR); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "CONSIGNEE NAME", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "DATE:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "REF:", blackFontForAR); cell.addElement(p); table.addCell(cell); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeName()) ? bl.getConsigneeName() : ""); stringBuilder.append("\n"); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeAddress()) ? bl.getConsigneeAddress() : ""); cell = new PdfPCell(); cell.setRowspan(2); cell.setBorderWidthTop(0f); p = new Paragraph(8f, stringBuilder.toString(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, deliveryDate, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, "04-" + bl.getFileNo(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); p = new Paragraph(8f, "THE MERCHANDISE DESCRIBED BELOW WILL BE ENTERED AND FORWARDED AS FOLLOWS:", blackFontForAR); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable tablebodyOne(FclBl bl, String freeDate, String localDeliveryOrTransferBy, String po, String referenceNumbers, String realPath) throws Exception { PdfPTable table = new PdfPTable(4); table.setWidths(new float[] { 3f, 2f, 2f, 4f }); table.setWidthPercentage(100);//from www . j a v a 2 s .c o m PdfPCell cell = null; Paragraph p = null; cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "IMPORTING CAREER:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setColspan(2); p = new Paragraph(8f, "LOCATION:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(9f, "FROM PORT OF ORIGIN AIRPORT:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getSslineName()) ? bl.getSslineName() : "", blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); cell.setColspan(2); p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getOnwardInlandRouting()) ? bl.getOnwardInlandRouting() : "", blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getTerminal()) ? bl.getTerminal() : "", blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "BILL OR AWB NO: ", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "ARRIVAL DATE:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(9f, "FREE TIME EXP:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(9f, "LOCAL DELIVERY OR TRANSFER BY:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getNewMasterBL()) ? bl.getNewMasterBL() : "", blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); if (bl.getEtaFd() != null) { p = new Paragraph(8f, "" + DateUtils.formatStringDateToAppFormatMMM(bl.getEtaFd()), blackFont); } else { p = new Paragraph(8f, "", blackFont); } cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, freeDate, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, localDeliveryOrTransferBy, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "PO#:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setColspan(2); p = new Paragraph(8f, "HAWB NO:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "REFERENCE NUMBERS:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, po, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); cell.setColspan(2); p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getImportAMSHouseBl()) ? bl.getImportAMSHouseBl() : "", blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, referenceNumbers, blackFont); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable tablebodyTwo(FclBl bl, String deliveryTo, String deliveryContact, String deliveryEmail, String deliveryPhone, String deliveryFax, String notify, String realPath) throws Exception { PdfPTable table = new PdfPTable(5); table.setWidths(new float[] { 2f, 2f, 2f, 2f, 2f }); table.setWidthPercentage(100);/*from ww w. java 2 s . c om*/ PdfPCell cell = null; Paragraph p = null; cell = new PdfPCell(); cell.setColspan(2); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "FOR DELIVERY TO:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "NOTIFY:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorderWidthTop(0f); p = new Paragraph(8f, deliveryTo, blackFont); cell.addElement(p); p = new Paragraph(8f, "Contact Name: " + deliveryContact, blackFont); cell.addElement(p); p = new Paragraph(8f, "Phone: " + deliveryPhone, blackFont); cell.addElement(p); p = new Paragraph(8f, "Fax: " + deliveryFax, blackFont); cell.addElement(p); p = new Paragraph(8f, "Email: " + deliveryEmail, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0f); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorderWidthTop(0f); cell.setBorderWidthTop(0f); p = new Paragraph(8f, notify, blackFont); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable tablebodyThree(FclBl bl, FclDoorDelivery fclDoorDelivery, MessageResources messageResources, String realPath) throws Exception { PdfPTable table = new PdfPTable(4); table.setWidths(new float[] { 2f, 1f, 5f, 2f }); table.setWidthPercentage(100);/*from w ww . j a v a2 s. c o m*/ PdfPCell cell = null; Paragraph p = null; cell = new PdfPCell(); p = new Paragraph(8f, "MARKS AND NUMBERS", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); p = new Paragraph(8f, "PIECES", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); p = new Paragraph(8f, "DESCRIPTION OF PACKAGES AND GOODS", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); p = new Paragraph(8f, "GROSS WEIGHT LBS", blackFontForAR); cell.addElement(p); table.addCell(cell); FclBlContainerDAO fclBlContainerDAO = new FclBlContainerDAO(); Set<FclBlContainer> containerSet = bl.getFclcontainer(); for (Iterator iter = containerSet.iterator(); iter.hasNext();) { FclBlContainer fclBlContainer = (FclBlContainer) iter.next(); StringBuilder tempSizeLegened = new StringBuilder(); String sizeLegend = fclBlContainer.getSizeLegend() != null ? (fclBlContainer.getSizeLegend().getCodedesc() != null ? fclBlContainer.getSizeLegend().getCodedesc() : "") : ""; int index = sizeLegend.indexOf("="); if (index != -1) { tempSizeLegened.append("1X"); String tempSize = sizeLegend.substring(index + 1, sizeLegend.length()); if (tempSize.equalsIgnoreCase(messageResources.getMessage("container40HC"))) { tempSize = "40" + "'" + "HC"; } else if (tempSize.equalsIgnoreCase(messageResources.getMessage("container40NOR"))) { tempSize = "40" + "'" + "NOR"; } else { tempSize = tempSize + "'"; } tempSizeLegened.append(tempSize); } else { tempSizeLegened.append(""); } StringBuilder marksNumber = new StringBuilder(); if (null != bl.getPrintContainersOnBL() && bl.getPrintContainersOnBL().equalsIgnoreCase("Yes")) { marksNumber.append(tempSizeLegened); marksNumber.append("\n"); marksNumber.append(fclBlContainer.getTrailerNo() != null ? fclBlContainer.getTrailerNo() : ""); marksNumber.append("\n"); marksNumber.append("SEAL: "); marksNumber.append(" " + fclBlContainer.getSealNo() != null ? fclBlContainer.getSealNo() : ""); } // HelperClass helperClass = new HelperClass(); // // List marksList = helperClass.splitDescrption(helperClass.wrapAddress(fclBlContainer.getMarks()), DESC_SIZE + 1); // if (!marksList.isEmpty()) { // marksNumber.append("\n"); // marksNumber.append(marksList.get(0).toString()); // marksList.remove(0); // } List<FclBlMarks> fclMarksList = fclBlContainerDAO.getPakagesDetails(fclBlContainer.getTrailerNoId()); if (fclMarksList != null && !fclMarksList.isEmpty()) { cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); p = new Paragraph(8f, marksNumber.toString(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); table.addCell(cell); for (FclBlMarks fclBlmarks : fclMarksList) { cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); p = new Paragraph(8f, "" + fclBlmarks.getNoOfPkgs(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); p = new Paragraph(8f, fclBlmarks.getDescPckgs(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); cell.setBorderWidthTop(0f); p = new Paragraph(8f, "" + fclBlmarks.getNetweightLbs(), blackFont); cell.addElement(p); table.addCell(cell); } } } cell = new PdfPCell(); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable tablebodyFour(FclBl bl, String billing, String realPath) throws Exception { PdfPTable table = new PdfPTable(5); table.setWidths(new float[] { 3f, 3f, 1f, 2f, 1f }); table.setWidthPercentage(100);//from w w w . java2 s.co m PdfPCell cell = null; Paragraph p = null; cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "PRE-PAID/COLLECT/3rd PARTY", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); p = new Paragraph(8f, "Received in Good Order By:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setFixedHeight(25f); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, billing, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); p = new Paragraph(8f, "", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorderWidthTop(0f); cell.setBorderWidthLeft(0f); cell.setBorderWidthRight(0f); p = new Paragraph(8f, "Signature:", blackFontForAR); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable emptyTable() throws Exception { PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100);//from w w w . j ava 2 s . c om PdfPCell cell = new PdfPCell(); cell = new PdfPCell(); cell.setFixedHeight(20f); cell.setColspan(4); cell.setBorder(0); table.addCell(cell); return table; }
From source file:com.grant.report.BillPdf.java
private void createTable(Paragraph preface) throws BadElementException, DocumentException { addEmptyLine(preface, 1);/*from w w w . j a v a 2s.c o m*/ PdfPTable table = new PdfPTable(6); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Item Code")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Description")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Qty")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Unit")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Rate")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Amount")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); float[] columnWidths = new float[] { 15f, 30f, 10f, 10f, 10f, 15f }; table.setWidths(columnWidths); ItemDAO dao = new ItemDAO(); String itemName; String itemNo; String description; String outwards; String unitPrice; String amount; String unit; Vector<Vector<String>> data; data = dao.getStockOutTbl(invoNo); String s = data.get(0).get(1); for (int i = 0; i < data.size(); i++) { Vector<String> data2 = data.get(i); itemName = data.get(i).get(0); description = data.get(i).get(3); outwards = data.get(i).get(5); itemNo = data.get(i).get(1); unit = data.get(i).get(6); unitPrice = data.get(i).get(8); amount = data.get(i).get(9); table.addCell(itemNo); table.addCell(description); table.addCell(outwards); table.addCell(unit); table.addCell(unitPrice); table.addCell(amount); } preface.add(table); }
From source file:com.horizzon.inventerium.ExportPdf.java
private static void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Buy Date")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Shopkeeper Name")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/* ww w.j ava 2 s . co m*/ c1 = new PdfPCell(new Phrase("Quantity")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Amount")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Profit")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Payment Status")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < transaction_list_export.size(); i++) { HashMap<String, String> transactionlist = new HashMap<String, String>(); transactionlist = transaction_list_export.get(i); table.addCell("" + transactionlist.get(T_DATE)); int pos = find_Shopkeeper_id(transactionlist.get(USER_ID), shopkeeper_id_export); table.addCell("" + shopkeeper_name_export.get(pos)); table.addCell(transactionlist.get(T_QTY)); int am = Integer.parseInt(transactionlist.get(T_UNIT_PRICE)) * Integer.parseInt(transactionlist.get(T_QTY)); table.addCell("" + am); table.addCell("" + Integer.parseInt(transactionlist.get(T_UNIT_PRICE)) / 2); table.addCell(transactionlist.get(T_PAYMENT_STATUS)); } subCatPart.add(table); }
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 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 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);/*from w w w . j av a2s. com*/ 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); }