List of usage examples for com.lowagie.text.pdf PdfPTable setKeepTogether
public void setKeepTogether(boolean keepTogether)
From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java
License:Open Source License
private static String parseTable(WikiPDFContext context, Wiki wiki, String line, Document document, Connection db, ArrayList<Integer> wikiListTodo, ArrayList<Integer> wikiListDone, BufferedReader in) throws Exception { if (line == null) { return null; }//from www.j a va 2 s. c o m PdfPTable pdfTable = null; int columnCount = 0; int rowCount = 0; // Keep track of the table's custom styles HashMap<Integer, String> cStyle = new HashMap<Integer, String>(); while (line != null && (line.startsWith("|") || line.startsWith("!"))) { // Build a complete line String lineToParse = line; while (!line.endsWith("|")) { line = in.readLine(); if (line == null) { // there is an error in the line to process return null; } if (line.startsWith("!")) { lineToParse += CRLF + line.substring(1); } } line = lineToParse; // Determine if the row can output boolean canOutput = true; ++rowCount; String cellType = null; Scanner sc = null; if (line.startsWith("||") && line.endsWith("||")) { cellType = "th"; sc = new Scanner(line).useDelimiter("[|][|]"); // sc = new Scanner(line.substring(2, line.length() - 2)).useDelimiter("[|][|]"); } else if (line.startsWith("|")) { cellType = "td"; sc = new Scanner(line.substring(1, line.length() - 1)).useDelimiter("\\|(?=[^\\]]*(?:\\[|$))"); } if (sc != null) { if (rowCount == 1) { // Count the columns, get the specified widths too... while (sc.hasNext()) { ++columnCount; sc.next(); } // Reset the scanner now that the columns have been counted if (line.startsWith("||") && line.endsWith("||")) { sc = new Scanner(line).useDelimiter("[|][|]"); } else if (line.startsWith("|")) { sc = new Scanner(line.substring(1, line.length() - 1)) .useDelimiter("\\|(?=[^\\]]*(?:\\[|$))"); } // Start the table pdfTable = new PdfPTable(columnCount); //pdfTable.setWidthPercentage(100); pdfTable.setHorizontalAlignment(Element.ALIGN_LEFT); pdfTable.setSpacingBefore(10); pdfTable.setWidthPercentage(100); pdfTable.setKeepTogether(true); } // Determine the column span int colSpan = 1; // Determine the cell being output int cellCount = 0; while (sc.hasNext()) { String cellData = sc.next(); if (cellData.length() == 0) { ++colSpan; continue; } // Track the cell count being output ++cellCount; if (rowCount == 1) { // Parse and validate the style input LOG.debug("Checking style value: " + cellData); if (cellData.startsWith("{") && cellData.endsWith("}")) { String[] style = cellData.substring(1, cellData.length() - 1).split(":"); String attribute = style[0].trim(); String value = style[1].trim(); // Determine the width of each column and store it if ("width".equals(attribute)) { // Validate the width style if (StringUtils.hasAllowedOnly("0123456789%.", value)) { cStyle.put(cellCount, attribute + ": " + value + ";"); } } else { LOG.debug("Unsupported style: " + cellData); } canOutput = false; } } // Output the header if (canOutput) { PdfPCell cell = new PdfPCell(); cell.setPadding(10); cell.setBorderColor(new Color(100, 100, 100)); if ("th".equals(cellType)) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); } if (colSpan > 1) { cell.setColspan(colSpan); } // Output the data if (" ".equals(cellData) || "".equals(cellData)) { // Put a blank space in blank cells for output consistency cell.addElement(new Chunk(" ")); LOG.debug(" OUTPUTTING A BLANK"); } else { // Output the cell as a complete wiki float cellWidth = (100.0f / columnCount); parseContent(context, wiki, cellData, document, cell, db, wikiListTodo, wikiListDone, cellWidth); LOG.debug(" OUTPUTTING CONTENT"); } pdfTable.addCell(cell); } } } // read another line to see if it's part of the table line = in.readLine(); } if (pdfTable != null) { LOG.debug("document.add(pdfTable)"); document.add(pdfTable); // document.add(Chunk.NEWLINE); } return line; }
From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java
License:Open Source License
protected static String parseForm(WikiPDFContext context, Connection db, BufferedReader in, String line, Document document, PdfPCell cell) throws Exception { if (line == null) { return line; }//from w w w . jav a 2 s . c o m CustomForm form = WikiToHTMLUtils.retrieveForm(in, line); LOG.debug("parseForm"); for (CustomFormGroup group : form) { LOG.debug(" group..."); // Start the table PdfPTable pdfTable = new PdfPTable(2); pdfTable.setHorizontalAlignment(Element.ALIGN_LEFT); pdfTable.setSpacingBefore(10); // pdfTable.setWidthPercentage(100); pdfTable.setKeepTogether(true); if (group.getDisplay() && StringUtils.hasText(group.getName())) { // output the 1st row with a colspan of 2 if (StringUtils.hasText(group.getName())) { Paragraph groupParagraph = new Paragraph(group.getName()); PdfPCell groupCell = new PdfPCell(groupParagraph); groupCell.setHorizontalAlignment(Element.ALIGN_CENTER); groupCell.setColspan(2); groupCell.setPadding(20); groupCell.setBorderColor(new Color(100, 100, 100)); groupCell.setBackgroundColor(new Color(200, 200, 200)); groupCell.setNoWrap(true); pdfTable.addCell(groupCell); } } for (CustomFormField field : group) { LOG.debug(" field..."); if (field.hasValue()) { // output the row (2 columns: label, value) Paragraph fieldLabelParagraph = new Paragraph(field.getLabel()); PdfPCell fieldLabelCell = new PdfPCell(fieldLabelParagraph); fieldLabelCell.setPadding(20); fieldLabelCell.setBorderColor(new Color(100, 100, 100)); // fieldLabelCell.setNoWrap(true); pdfTable.addCell(fieldLabelCell); Paragraph fieldValueParagraph = new Paragraph(getFieldValue(context, field)); PdfPCell fieldValueCell = new PdfPCell(fieldValueParagraph); fieldValueCell.setPadding(20); fieldValueCell.setBorderColor(new Color(100, 100, 100)); // fieldValueCell.setNoWrap(true); pdfTable.addCell(fieldValueCell); } } LOG.debug("document.add(pdfTable)"); document.add(pdfTable); } return null; }
From source file:com.gp.cong.logisoft.lcl.report.FreightInvoiceLclPdfCreator.java
public void createImportFreightPdf(String realPath, String unitSsId, String fileId, String fileNumber, String outputFileName, String documentName, String voyNotiemailId, User loginUser) throws Exception { ImportPortConfigurationDAO importPortConfigurationDAO = new ImportPortConfigurationDAO(); LclUnitSsDispoDAO lclUnitSsDispoDAO = new LclUnitSsDispoDAO(); LclUnitSsDAO lclUnitSsDAO = new LclUnitSsDAO(); LclRemarksDAO lclRemarksDAO = new LclRemarksDAO(); LclBookingPieceDAO lclBookingPieceDAO = new LclBookingPieceDAO(); String trmname = ""; String trmAddress = ""; String trmZip = ""; String customerPo = ""; String unitNo = ""; String masterBl = ""; StringBuilder originValues = new StringBuilder(); StringBuilder destinationValues = new StringBuilder(); String subHouseBl = ""; String amsHouseBl = ""; String shipName = ""; String consName = ""; String notyName = ""; String forwName = ""; String billToParty = ""; String billToPartyAc = ""; Date pickUpDate = null;/* ww w . j a v a2s . co m*/ Date vesselEtd = null; String billToPartyAcctName = ""; StringBuilder consAddress = new StringBuilder(); LclBooking lclBooking = new LCLBookingDAO().findById(Long.valueOf(fileId)); shipName = null != lclBooking.getShipAcct() ? lclBooking.getShipContact().getCompanyName() : ""; consName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName() : ""; notyName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName() : ""; forwName = null != lclBooking.getFwdAcct() ? lclBooking.getFwdAcct().getAccountName() : ""; billToParty = null != lclBooking.getBillToParty() ? lclBooking.getBillToParty() : ""; if (billToParty.equalsIgnoreCase("C")) { billToPartyAc = null != lclBooking.getConsAcct() ? lclBooking.getConsAcct().getAccountno() : ""; billToPartyAcctName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName() : ""; } else if (billToParty.equalsIgnoreCase("A")) { billToPartyAc = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountno() : ""; billToPartyAcctName = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountName() : ""; } else if (billToParty.equalsIgnoreCase("N")) { billToPartyAc = null != lclBooking.getNotyAcct() ? lclBooking.getNotyAcct().getAccountno() : ""; billToPartyAcctName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName() : ""; } else if (billToParty.equalsIgnoreCase("T")) { billToPartyAc = null != lclBooking.getThirdPartyAcct() ? lclBooking.getThirdPartyAcct().getAccountno() : ""; billToPartyAcctName = null != lclBooking.getThirdPartyAcct() ? lclBooking.getThirdPartyAcct().getAccountName() : ""; } originValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfLoading())); destinationValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfDestination())); if (lclBooking.getTerminal() != null) { RefTerminal terminal = new TerminalDAO() .findByTerminalNo(String.valueOf(lclBooking.getTerminal().getTrmnum())); trmname = null != terminal ? terminal.getTerminalLocation() : ""; if (trmname.equalsIgnoreCase("IMPRTS LOS ANGELES")) { trmname = "Los Angeles"; } trmAddress = null != terminal ? terminal.getAddres1() : ""; trmZip = null != terminal ? terminal.getZipcde() : ""; } customerPo = new Lcl3pRefNoDAO().getCustomerPo(fileId); CustAddress custAddress = new CustAddressDAO().findByAccountNo(billToPartyAc); if (custAddress != null) { consAddress.append(billToPartyAcctName).append("\n"); consAddress.append(custAddress.getAddress1()).append("\n"); consAddress.append(custAddress.getCity1()).append(" ").append(custAddress.getState()).append(" ") .append(custAddress.getZip()); } List<LclBookingPiece> lclBookingPiece = lclBookingPieceDAO.findByProperty("lclFileNumber.id", Long.parseLong(fileId)); LclFileNumber lclFileNumber = new LclFileNumberDAO().getByProperty("id", Long.parseLong(fileId)); if (lclBookingPiece != null && !lclBookingPiece.isEmpty() && CommonUtils.isNotEmpty(lclBookingPiece.get(0).getLclBookingPieceUnitList())) { unitNo = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit() .getUnitNo(); masterBl = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit() .getLclUnitSsManifestList().get(0).getMasterbl(); vesselEtd = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclSsHeader() .getLclSsDetailList().get(0).getSta(); } Boolean isSegregationFlag = new LclBookingSegregationDao().isCheckedSegregationDr(Long.parseLong(fileId)); if (isSegregationFlag) { amsHouseBl = new LclBookingImportAmsDAO().getAmsNo(fileId); } else { amsHouseBl = new LclBookingImportAmsDAO().getAmsNoGroup(fileId); } if (lclFileNumber.getLclBookingImport() != null) { subHouseBl = lclFileNumber.getLclBookingImport().getSubHouseBl(); pickUpDate = lclFileNumber.getLclBookingImport().getPickupDateTime(); } PdfPCell cell = new PdfPCell(); PdfPTable mainTable = makeTable(2); mainTable.setWidthPercentage(100f); PdfPTable clientPTable = new PdfPTable(5); clientPTable.setWidthPercentage(100f); clientPTable.setWidths(new float[] { 25, 25, 17, 11, 22 }); clientPTable.setKeepTogether(true); cell = makeCell("BILL TO ACCOUNT NO.", Element.ALIGN_LEFT, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); clientPTable.addCell(cell); cell = makeCell("" + billToPartyAc, Element.ALIGN_LEFT, blackFontForFclAr, 0); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); clientPTable.addCell(cell); cell = makeCell("INVOICE NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); clientPTable.addCell(cell); cell = makeCell("DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthBottom(0.06f); clientPTable.addCell(cell); cell = makeCell("BILLING TM", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthBottom(0.06f); clientPTable.addCell(cell); cell = makeCell("" + consAddress.toString(), Element.ALIGN_LEFT, blackFontForFclAr, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); clientPTable.addCell(cell); //INVOICE NO cell = makeCell(fileNumber, Element.ALIGN_CENTER, blackFontForFclBl, 0); clientPTable.addCell(cell); //DATE String acctNumber = checkPayment(billToPartyAc); if (!acctNumber.equals("noCredit")) { if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && pickUpDate != null) { cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(pickUpDate), Element.ALIGN_CENTER, blackFontForFclBl, 0); } else if (pickUpDate == null && vesselEtd != null) { cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER, blackFontForFclBl, 0); } else { cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); } } else if (acctNumber.equals("noCredit") && vesselEtd != null) { cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER, blackFontForFclBl, 0); } else { cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); } cell.setBorderWidthLeft(0.06f); clientPTable.addCell(cell); //BILLING TM cell = makeCell(trmname, Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setBorderWidthLeft(0.06f); clientPTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); clientPTable.addCell(cell); cell = makeCell("CUSTOMER REF NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setColspan(3); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); clientPTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); clientPTable.addCell(cell); //CUSTOMER REF NO. cell = makeCell(customerPo, Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setColspan(3); cell.setMinimumHeight(15f); cell.setBorderWidthLeft(0.06f); clientPTable.addCell(cell); cell = new PdfPCell(); cell.addElement(clientPTable); cell.setColspan(5); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); mainTable.addCell(cell); PdfPTable othersTable = makeTable(4); othersTable.setWidthPercentage(100f); othersTable.setWidths(new float[] { 25, 25, 25, 25 }); cell = makeCell("CONTAINER NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("ECI SHIPMENT FILE NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("ORIGIN", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("DESTINATION", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); othersTable.addCell(cell); //CONTAINER NO cell = makeCell("" + unitNo, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //ECI SHIPMENT FILE NO cell = makeCell("IMP-" + fileNumber, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //ORIGIN cell = makeCell("" + originValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //DESTINATION cell = makeCell("" + destinationValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("MBL / AWB NUMBER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthRight(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); cell = makeCell("AMS HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthRight(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); cell = makeCell("SUB HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); //MBL / AWB NUMBER cell = makeCell("" + masterBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //amsHouseBl cell = makeCell(amsHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //subHouseBl cell = makeCell(subHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("SHIPPER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthRight(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); cell = makeCell("FORWARDER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); //SHIPPER cell = makeCell(shipName, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //FORWARDER cell = makeCell(forwName, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = makeCell("CONSIGNEE", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthRight(0.06f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); cell = makeCell("NOTIFY PARTY", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); othersTable.addCell(cell); //CONSIGNEE cell = makeCell(consName, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); //NOTIFY PARTY cell = makeCell(notyName, Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(2); cell.setMinimumHeight(20f); cell.setBorderWidthRight(0.06f); othersTable.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.addElement(othersTable); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); mainTable.addCell(cell); Font boldHeadingFon = FontFactory.getFont("Arial", 7f, Font.BOLD); Paragraph p = null; PdfPTable othersTable1 = makeTable(5); othersTable1.setWidthPercentage(100f); othersTable1.setWidths(new float[] { 2f, 1f, 4f, 1.3f, 1.3f }); //marks cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); p = new Paragraph(7f, "MARKS AND NUMBERS", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); othersTable1.addCell(cell); //no of pkgs cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "NO.OF.PKGS", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); othersTable1.addCell(cell); //desc cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "DESCRIPTION OF PACKAGES AND GOODS", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); othersTable1.addCell(cell); //grossweight cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "GROSS WEIGHT", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); othersTable1.addCell(cell); //measure cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "MEASURE", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); othersTable1.addCell(cell); // List<LclBookingPiece> lclBookingPiecesList = null; // lclBookingPiecesList = lclBookingPieceDAO.findByProperty("lclFileNumber.id", Long.parseLong(fileId)); if (lclBookingPiece != null && lclBookingPiece.size() > 0) { for (LclBookingPiece lclBookingPieces : lclBookingPiece) { //MARKS AND NUMBERS cell = new PdfPCell(); cell.setBorder(0); if (lclBookingPieces != null && lclBookingPieces.getMarkNoDesc() != null && !lclBookingPieces.getMarkNoDesc().equals("")) { p = new Paragraph(7f, "" + lclBookingPieces.getMarkNoDesc().toUpperCase(), blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //NO.OF.PKGS cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getBookedPieceCount() != null && lclBookingPieces.getPackageType().getAbbr01() != null) { p = new Paragraph(7f, "" + lclBookingPieces.getBookedPieceCount() + " " + lclBookingPieces.getPackageType().getAbbr01(), blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //DESCRIPTION OF PACKAGES AND GOODS cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getPieceDesc() != null && !lclBookingPieces.getPieceDesc().equals("")) { p = new Paragraph(7f, "" + lclBookingPieces.getPieceDesc().toUpperCase(), blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //grossweight cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getBookedWeightMetric() != null) { p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightMetric() + " KGS", blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //measure cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeMetric() != null) { p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeMetric() + " CBM", blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //2nd cell cell = new PdfPCell(); cell.setBorder(0); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); //3rd cell cell = new PdfPCell(); cell.setBorder(0); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "", blackNormalCourierFont8f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getBookedWeightImperial() != null) { p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightImperial() + " LBS", blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeImperial() != null) { p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeImperial() + " CFT", blackNormalCourierFont8f); } else { p = new Paragraph(7f, "", blackNormalCourierFont8f); } p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); othersTable1.addCell(cell); } } cell = new PdfPCell(); cell.setColspan(5); cell.addElement(othersTable1); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); mainTable.addCell(cell); PdfPTable chargesTable = makeTable(4); chargesTable.setWidthPercentage(100.5f); chargesTable.setWidths(new float[] { 45, 35, 5, 15 }); cell = makeCell("DESCRIPTION", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthBottom(0.06f); cell.setColspan(2); chargesTable.addCell(cell); cell = makeCell("CHARGES", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1")); cell.setColspan(2); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); chargesTable.addCell(cell); NumberFormat number = new DecimalFormat("###,###,##0.00"); String code = ""; // double totalCharges = 0.00; double lateFee = 0.00; double payAmount = 0.00; int chargeCount = 0; double total = 0.00; String[] billToPartyA; billToPartyA = new String[] { "C", "N", "T" }; List<String> billtoPartyList = Arrays.asList(billToPartyA); List<BookingChargesBean> lclBookingAcList = null; lclBookingAcList = new LclCostChargeDAO().findBybookingAcId(fileId, billtoPartyList); for (int j = 0; j < lclBookingAcList.size(); j++) { chargeCount++; BookingChargesBean lclBookingAc = (BookingChargesBean) lclBookingAcList.get(j); String codeDesc = ""; code = CommonUtils.isNotEmpty(lclBookingAc.getChargeCode()) ? lclBookingAc.getChargeCode() : ""; codeDesc = new GenericCodeDAO().getGenericCodeDesc(code); if (CommonUtils.isNotEmpty(lclBookingAc.getChargeCode())) { // String desc = lclBookingAc.getChargeCode().toUpperCase(); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl); cell.setBorderWidthRight(0.0f); } if (chargeCount == 1) { cell.setBorderWidthTop(0.0f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthLeft(0.0f); cell.setBorderWidthBottom(0.0f); } else { cell.setBorderWidthRight(0.0f); cell.setBorderWidthLeft(0.0f); cell.setBorderWidthBottom(0.0f); } chargesTable.addCell(cell); if (CommonUtils.isNotEmpty(codeDesc)) { cell = makeCell("" + codeDesc, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f); cell.setBorderWidthLeft(0.0f); } else { cell = makeCell("" + code, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f); cell.setBorderWidthLeft(0.0f); } if (chargeCount == 1) { cell.setBorderWidthTop(0.0f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); } else { cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); } chargesTable.addCell(cell); cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);//3 if (chargeCount == 1) { cell.setBorderWidthTop(0.0f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); } else { cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); } chargesTable.addCell(cell); cell = makeCell(number.format(lclBookingAc.getTotalAmt().doubleValue()), Element.ALIGN_RIGHT, blackFontForFclBl, Rectangle.BOX);//4 if (chargeCount == 1) { cell.setBorderWidth(0.0f); } else { cell.setBorderWidthLeft(0.0f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); } chargesTable.addCell(cell); total = total + lclBookingAc.getTotalAmt().doubleValue(); } for (int i = 0; i < (14 - chargeCount); i++) { // chargesTable.addCell(makeCellLeftNoBorderFclBL("")); // chargesTable.addCell(makeCellRightNoBorderFclBL("")); cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0.06f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); cell.setBorderWidthLeft(0.0f); chargesTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); cell.setBorderWidthLeft(0.0f); chargesTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); chargesTable.addCell(cell); cell = makeCell("", Element.ALIGN_RIGHT, blackFontForFclBl, 0.06f); cell.setBorderWidthLeft(0.0f); cell.setBorderWidthRight(0.0f); cell.setBorderWidthBottom(0.0f); cell.setMinimumHeight(10f); chargesTable.addCell(cell); } cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0); cell.setBorderWidthTop(0.06f); chargesTable.addCell(cell); cell = makeCell("INVOICE TOTAL", Element.ALIGN_CENTER, blackFontForFclBl, 0); // cell.setPaddingLeft(-15f); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthRight(0.06f); chargesTable.addCell(cell); cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); chargesTable.addCell(cell); cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0);//4 cell.setBorderWidthTop(0.06f); cell.setBorderWidthBottom(0.06f); chargesTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setColspan(4); chargesTable.addCell(cell); chargesTable.setKeepTogether(true); cell = new PdfPCell(); cell.setColspan(2); cell.addElement(chargesTable); cell.setBorder(0); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); mainTable.addCell(cell); // payAmount = total; // String acctNumber = checkPayment(billToPartyAc); boolean lateFeeFlag = false; TradingPartnerBC tradingPartnerBC = new TradingPartnerBC(); TradingPartner tradingPartner = null; // SimpleDateFormat simpDate = new SimpleDateFormat("dd-MMM-yyyy"); PdfPTable paidTable = makeTable(6); paidTable.setWidthPercentage(100.5f); paidTable.setWidths(new float[] { 30, 15, 25, 10, 5, 15 }); if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && !acctNumber.equals("noCredit")) { tradingPartner = tradingPartnerBC.findTradingPartnerById(acctNumber); if (CommonFunctions.isNotNullOrNotEmpty(tradingPartner.getAccounting())) { for (Iterator accountingList = tradingPartner.getAccounting().iterator(); accountingList .hasNext();) { CustomerAccounting customerAccounting = (CustomerAccounting) accountingList.next(); if (null != customerAccounting.getLclApplyLateFee() && customerAccounting.getLclApplyLateFee().equals("on")) { lateFeeFlag = true; } break; } } } cell = makeCell("ARRIVAL DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1")); cell.setBorderWidthTop(0.06f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthBottom(0.06f); paidTable.addCell(cell); SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); String outDate = ""; String crtDate = ""; if (vesselEtd != null) { //vessel arrivalDate outDate = sdf.format(vesselEtd); } cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0); paidTable.addCell(cell); CustomerAccounting customerAccounting = new CustomerAccountingDAO().findByProperty("accountNo", billToPartyAc); if (customerAccounting != null && (customerAccounting.getCreditRate() != null && (CommonUtils.isNotEmpty(outDate)) && !acctNumber.equals("noCredit"))) { Calendar c = Calendar.getInstance(); // c.setTime(new Date(outDate)); // Removed Deprecated Warning c.setTime(sdf.parse(outDate)); // Now use previous date. if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 7 Days")) { c.add(Calendar.DATE, 7); crtDate = sdf.format(c.getTime());// Adding 7 days } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 15 Days")) { c.add(Calendar.DATE, 15); crtDate = sdf.format(c.getTime());// Adding 15 days } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("NET 21 DAYS")) { c.add(Calendar.DATE, 21); crtDate = sdf.format(c.getTime());// Adding 21 days } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 30 Days")) { c.add(Calendar.DATE, 30); crtDate = sdf.format(c.getTime());// Adding 30 days } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 45 Days")) { c.add(Calendar.DATE, 45); crtDate = sdf.format(c.getTime());// Adding 45 days } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 60 Days")) { c.add(Calendar.DATE, 60); crtDate = sdf.format(c.getTime());// Adding 60 days } } if (lateFeeFlag) { lateFee = total * 0.015; // 1.5percent calculate payAmount = total + lateFee; cell = makeCell("LATE FEE IF NOT PAID BY - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0); cell.setColspan(2); cell.setBorderWidthTop(0.06f); cell.setBorderWidthLeft(0.06f); paidTable.addCell(cell); cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setBorderWidthTop(0.06f); cell.setBorderWidthLeft(0.06f); paidTable.addCell(cell); cell = makeCell(number.format(lateFee), Element.ALIGN_RIGHT, blackFontForFclBl, 0); cell.setBorderWidthTop(0.06f); paidTable.addCell(cell); cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setMinimumHeight(10f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthRight(0.06f); paidTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); paidTable.addCell(cell); cell = makeCell("PAY THIS AMOUNT IF NOT PAID BY DUE DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); cell.setColspan(2); paidTable.addCell(cell); cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); paidTable.addCell(cell); cell = makeCell(number.format(payAmount), Element.ALIGN_RIGHT, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); paidTable.addCell(cell); } else { // String dueDate = ""; // if(arRedInvoice.getDueDate() != null){ // SimpleDateFormat sdfa = new SimpleDateFormat("dd-MMM-yyyy"); // dueDate = sdfa.format(arRedInvoice.getDueDate()); // } // cell = makeCell(!"".equals(dueDate) ? "PAY THIS AMOUNT IF NOT PAID BY - " + dueDate : "PLEASE PAY THIS AMOUNT",Element.ALIGN_LEFT, blackFontForFclBl, 0); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setColspan(4); paidTable.addCell(cell); cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setMinimumHeight(10f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthRight(0.06f); paidTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); paidTable.addCell(cell); cell = makeCell("PLEASE PAY THIS AMOUNT - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); cell.setColspan(2); paidTable.addCell(cell); cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthTop(0.06f); paidTable.addCell(cell); cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); paidTable.addCell(cell); } cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0); cell.setColspan(5); paidTable.addCell(cell); //paidTable.setKeepTogether(true); cell = new PdfPCell(); cell.setColspan(2); cell.addElement(paidTable); cell.setBorder(0); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); mainTable.addCell(cell); ///end of description & charges // String paymentStatment = ""; // paymentStatment = checkPayment(arRedInvoice); PdfPTable commandTable = new PdfPTable(1); commandTable.setWidthPercentage(100); cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); if (customerAccounting != null && (customerAccounting.getCreditRate() != null && (CommonUtils.isNotEmpty(outDate)))) { if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Due Upon Receipt")) { cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0, Color.decode("#FFFF00")); commandTable.addCell(cell); } else { cell = makeCell("INVOICE PAYABLE ON OR BEFORE " + (crtDate), Element.ALIGN_CENTER, new Font(Font.HELVETICA, 10, Font.BOLDITALIC, Color.BLACK), Rectangle.NO_BORDER); commandTable.addCell(cell); } } else { cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0, Color.decode("#FFFF00")); commandTable.addCell(cell); } // if (lateFeeFlag == false) {//if(paymentStatment.equals("noCredit") || lateFeeFlag == false){ // cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT OR INVOICE PAYABLE WITHIN 30 DAYS FROM DEPARTURE/ARRIVAL DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0, Color.decode("#FFFF00")); // commandTable.addCell(cell); // } else { // cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); // commandTable.addCell(cell); // } cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER); commandTable.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.addElement(commandTable); cell.setBorder(0); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); cell.setExtraParagraphSpace(10f); mainTable.addCell(cell); PdfPTable bankDetailsTable = makeTable(4); bankDetailsTable.setWidthPercentage(100f); bankDetailsTable.setWidths(new float[] { 3f, 1f, 4f, 2.6f }); // // SystemRulesDAO systemRulesDAO = new SystemRulesDAO(); // String eftBank = systemRulesDAO.getSystemRulesByCode("EFTBank"); // String eftBankAddress = systemRulesDAO.getSystemRulesByCode("EFTBankAddress"); // String eftABANo = systemRulesDAO.getSystemRulesByCode("EFTABANo"); // String eftAcctName = systemRulesDAO.getSystemRulesByCode("EFTAcctName"); // String eftAccountNo = systemRulesDAO.getSystemRulesByCode("EFTAccountNo"); // CompanyModel company = systemRulesDAO.getCompanyDetails(); //PAYMENT METHODS cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthRight(0.6f); cell.setBorderWidthTop(0.6f); p = new Paragraph(7f, "PAYMENT METHODS", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); bankDetailsTable.addCell(cell); // Empty cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0); cell.setColspan(3); cell.setBorderWidthBottom(0.06f); bankDetailsTable.addCell(cell); //Via Check cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "Via Check", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); bankDetailsTable.addCell(cell); //Via ACH or Wire Transfer cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "Via ACH or Wire Transfer", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); bankDetailsTable.addCell(cell); //Credit Card Payments cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.6F); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, "Credit Card Payments", boldHeadingFon); p.setAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(Color.decode("#c5d9f1")); cell.addElement(p); bankDetailsTable.addCell(cell); // Via Check Details cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthRight(0.06f); cell.setBorderWidthBottom(0.06f); cell.setColspan(2); p = new Paragraph(10f, "PLEASE REMIT PAYMENT TO", boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, companyName, boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); String creditStatusDomain = ""; if (null != customerAccounting && null != customerAccounting.getCreditStatus()) {//no credit creditStatusDomain = customerAccounting.getCreditStatus().getCodedesc(); if (!("No Credit").equalsIgnoreCase(creditStatusDomain)) { p = new Paragraph(10f, "2401 N.W. 69TH STREET", boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, "Miami, FL 33147", boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); bankDetailsTable.addCell(cell); } else { p = new Paragraph(10f, "" + trmAddress, boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, "" + trmname + " " + trmZip, boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); bankDetailsTable.addCell(cell); } } //Via ACH or Wire Transfer Details cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthRight(0.06f); p = new Paragraph(10f, "Bank: " + company.getBankName(), boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, company.getBankAddress(), boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, "ABA: " + company.getBankAbaNumber(), boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, "ACCT: " + companyName, boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, "ACCOUNT NO: " + company.getBankAccountNumber(), boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); bankDetailsTable.addCell(cell); //Credit Card Payments Details cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthRight(0.06f); p = new Paragraph(10f, "If paying via Credit card", boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, " Please go to:", boldHeadingFon); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); p = new Paragraph(10f, webSite, fileNoFont); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); bankDetailsTable.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.addElement(bankDetailsTable); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthRight(0.06f); cell.setBorderWidthLeft(0.06f); cell.setBorderWidthBottom(0.06f); mainTable.addCell(cell); document.add(mainTable); }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addOperationTable(PdfWriter pdfWriter, GroupingContainer groupingContainer, Document document, OrderOperationComponent orderOperationComponent, Locale locale) throws DocumentException { Map<Long, Map<OperationProductColumn, ColumnAlignment>> outputProductsMap = groupingContainer .getOperationComponentIdProductOutColumnToAlignment(); Map<Long, Map<OperationProductColumn, ColumnAlignment>> inputProductsMap = groupingContainer .getOperationComponentIdProductInColumnToAlignment(); Entity operationComponent = orderOperationComponent.getOperationComponent(); Entity order = orderOperationComponent.getOrder(); Entity product = order.getBelongsToField(OrderFields.PRODUCT); Map<OperationProductColumn, ColumnAlignment> inputProductColumnAlignmentMap = inputProductsMap .get(operationComponent.getId()); Map<OperationProductColumn, ColumnAlignment> outputProductColumnAlignmentMap = outputProductsMap .get(operationComponent.getId()); PdfPTable table = pdfHelper.createPanelTable(3); PdfPCell headerCell = new PdfPCell(); headerCell.setBorder(Rectangle.NO_BORDER); headerCell.setColspan(2);//from ww w. j ava 2 s . c o m PdfPCell inputCell = new PdfPCell(); inputCell.setBorder(Rectangle.NO_BORDER); PdfPCell outputCell = new PdfPCell(); outputCell.setBorder(Rectangle.NO_BORDER); PdfPCell codeCell = new PdfPCell(); codeCell.setBorder(Rectangle.NO_BORDER); codeCell.setHorizontalAlignment(Element.ALIGN_CENTER); codeCell.setVerticalAlignment(Element.ALIGN_TOP); codeCell.setRowspan(2); // addOperationSummary(headerCell, operationComponent); addOrderSummary(headerCell, order, product, operationComponent); addOperationProductsTable(inputCell, operationProductInComponents(operationComponent, order), inputProductColumnAlignmentMap, ProductDirection.IN, locale); addOperationProductsTable(outputCell, operationProductOutComponents(operationComponent, order), outputProductColumnAlignmentMap, ProductDirection.OUT, locale); codeCell.addElement(createBarcode(pdfWriter, operationComponent)); float[] tableColumnWidths = new float[] { 70f, 70f, 10f }; table.setWidths(tableColumnWidths); table.setTableEvent(null); table.addCell(headerCell); table.addCell(codeCell); table.addCell(inputCell); table.addCell(outputCell); table.setKeepTogether(true); document.add(table); }
From source file:org.gtdfree.addons.PDFExportAddOn.java
License:Open Source License
@Override public void export(GTDModel model, ActionsCollection collection, OutputStream out, ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception { fontSelector = new FontSelector(); fontSelectorB = new FontSelector(); fontSelectorB2 = new FontSelector(); fontSelectorB4 = new FontSelector(); baseFont = fontModel.getBaseFont();/* w ww . j a v a 2 s .c om*/ for (BaseFont bf : fontModel.getFonts()) { fontSelector.addFont(new Font(bf, baseFontSize)); fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD)); fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD)); fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD)); } boolean emptyH2 = false; boolean emptyH3 = false; PdfPTable actionTable = null; Document doc = new Document(); if (sizeSet) { doc.setPageSize(pageSize); } if (marginSet) { doc.setMargins(marginLeft, marginRight, marginTop, marginBottom); } //System.out.println("PDF size "+doc.getPageSize().toString()); //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom); @SuppressWarnings("unused") PdfWriter pw = PdfWriter.getInstance(doc, out); doc.addCreationDate(); doc.addTitle("GTD-Free PDF"); doc.addSubject("GTD-Free data exported as PDF"); HeaderFooter footer = new HeaderFooter(newParagraph(), true); footer.setAlignment(HeaderFooter.ALIGN_CENTER); footer.setBorder(HeaderFooter.TOP); doc.setFooter(footer); doc.open(); Phrase ch = newTitle("GTD-Free Data"); Paragraph p = new Paragraph(ch); p.setAlignment(Paragraph.ALIGN_CENTER); PdfPTable t = new PdfPTable(1); t.setWidthPercentage(100f); PdfPCell c = newCell(p); c.setBorder(Table.BOTTOM); c.setBorderWidth(2.5f); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setPadding(5f); t.addCell(c); doc.add(t); Iterator<Object> it = collection.iterator(order); while (it.hasNext()) { Object o = it.next(); if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) { if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) { doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = false; emptyH3 = true; } else { doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = true; emptyH3 = false; } continue; } if (o instanceof Folder) { Folder f = (Folder) o; if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (f.isProject()) { if (order == ExportAddOn.ExportOrder.ProjectsActions || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph("Project")); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("Project:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (order == ExportAddOn.ExportOrder.FoldersActions || order == ExportAddOn.ExportOrder.FoldersProjectsActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); String type = ""; if (f.isAction()) { type = "Action list"; } else if (f.isInBucket()) { type = "In-Bucket"; } else if (f.isQueue()) { type = "Next action queue"; } else if (f.isReference()) { type = "Reference list"; } else if (f.isSomeday()) { type = "Someday/Maybe list"; } else if (f.isBuildIn()) { type = "Default list"; } c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph(type)); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("List:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (o instanceof Action) { emptyH2 = false; emptyH3 = false; Action a = (Action) o; if (compact) { if (actionTable == null) { actionTable = new PdfPTable(5); actionTable.setWidthPercentage(100f); actionTable.setHeaderRows(1); actionTable.setSpacingBefore(5f); c = newHeaderCell("ID"); actionTable.addCell(c); c = newHeaderCell("Pri."); actionTable.addCell(c); c = newHeaderCell("Description"); actionTable.addCell(c); c = newHeaderCell("Reminder"); actionTable.addCell(c); c = newHeaderCell(CHECK_RESOLVED); actionTable.addCell(c); float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft() - doc.getPageSize().getBorderWidthRight(); int i = model.getLastActionID(); float step = baseFontSize - 1; int steps = (int) Math.floor(Math.log10(i)) + 1; // ID column float col1 = 8 + steps * step; // Priority column float col2 = 4 + 3 * (baseFontSize + 4); // Reminder column float col4 = 10 + step * 11; // Resolved column float col5 = 8 + baseFontSize; // Description column float col3 = width - col1 - col2 - col4 - col5; actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 }); } addSingleActionRow(a, actionTable); } else { addSingleActionTable(model, doc, a); } } } if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date())); doc.close(); }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
/** * Prints pdf table. By default does not split table across * page boundaries /*ww w . j a v a2 s . c o m*/ * @param ordCol * @param keepTogether true does not split table across pages * @return */ public PdfPTable printPdfTable(int ordCol, boolean keepTogether) { PdfPTable table = new PdfPTable(getNrColumns()); table.setWidthPercentage(100); table.getDefaultCell().setPadding(3); table.getDefaultCell().setBorderWidth(0); table.setSplitRows(false); table.setKeepTogether(keepTogether); boolean asc = (ordCol == 0 || iAsc == null || iAsc.length <= Math.abs(ordCol) - 1 ? true : iAsc[Math.abs(ordCol) - 1]); if (ordCol < 0) asc = !asc; widths = new float[iColumns]; for (int i = 0; i < iColumns; i++) widths[i] = 0f; String lastLine[] = new String[Math.max(iColumns, (iHeaders == null ? 0 : iHeaders.length))]; if (iHeaders != null) { for (int i = 0; i < iColumns; i++) { if (isFiltered(i)) continue; PdfPCell c = createCell(); c.setBorderWidthBottom(1); float width = addText(c, iHeaders[i] == null ? "" : iHeaders[i], true); widths[i] = Math.max(widths[i], width); String align = (iAlign != null ? iAlign[i] : "left"); if ("left".equals(align)) c.setHorizontalAlignment(Element.ALIGN_LEFT); if ("right".equals(align)) c.setHorizontalAlignment(Element.ALIGN_RIGHT); if ("center".equals(align)) c.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c); } table.setHeaderRows(1); } if (ordCol != 0) { Collections.sort(iLines, new WebTableComparator(Math.abs(ordCol) - 1, asc)); } for (int el = 0; el < iLines.size(); el++) { WebTableLine wtline = (WebTableLine) iLines.elementAt(el); String[] line = wtline.getLine(); boolean blank = iBlankWhenSame; for (int i = 0; i < iColumns; i++) { if (isFiltered(i)) continue; if (blank && line[i] != null && !line[i].equals(lastLine[i])) blank = false; PdfPCell c = createCell(); float width = addText(c, blank || line[i] == null ? "" : line[i], false); widths[i] = Math.max(widths[i], width); String align = (iAlign != null ? iAlign[i] : "left"); if ("left".equals(align)) c.setHorizontalAlignment(Element.ALIGN_LEFT); if ("right".equals(align)) c.setHorizontalAlignment(Element.ALIGN_RIGHT); if ("center".equals(align)) c.setHorizontalAlignment(Element.ALIGN_CENTER); applyPdfStyle(c, wtline, (el + 1 < iLines.size() ? (WebTableLine) iLines.elementAt(el + 1) : null), ordCol); table.addCell(c); lastLine[i] = line[i]; } } try { if (getNrFilteredColumns() < 0) { table.setWidths(widths); } else { float[] x = new float[getNrColumns()]; int idx = 0; for (int i = 0; i < iColumns; i++) { if (isFiltered(i)) continue; x[idx++] = widths[i]; } table.setWidths(x); } } catch (Exception e) { e.printStackTrace(); } return table; }