List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingBottom
public void setPaddingBottom(float paddingBottom)
From source file:be.kcbj.placemat.Placemat.java
License:Open Source License
private PdfPCell generateCell(Sponsor sponsor, float cellHeight) throws IOException, BadElementException { int numLines = 0; Paragraph p = new Paragraph(); if (sponsor.image != null) { Image image = Image.getInstance(SponsorManager.getImageUrl(sponsor.image)); if (sponsor.imageWidth != 0) { image.scaleToFit(sponsor.imageWidth, 1000); } else if (sponsor.imageHeight != 0) { image.scaleToFit(1000, sponsor.imageHeight); }// w ww . jav a 2 s .c o m Chunk imageChunk = new Chunk(image, 0, 0, true); p.add(imageChunk); } if (sponsor.twoColumns) { StringBuilder sb = new StringBuilder(); if (sponsor.name != null) { sb.append(sponsor.name); } if (sponsor.name2 != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.name2); } if (sponsor.address != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.address); } if (sponsor.address2 != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.address2); } p.add(Chunk.NEWLINE); p.add(new Chunk(sb.toString(), new Font(Font.FontFamily.HELVETICA, 8, Font.NORMAL))); numLines++; } else { if (sponsor.twoRows && sponsor.image != null) { p.add(Chunk.NEWLINE); } if (sponsor.name != null) { p.add(generateFittedChunk(sponsor.name, Font.BOLD)); numLines++; } if (sponsor.name2 != null) { p.add(Chunk.NEWLINE); p.add(generateFittedChunk(sponsor.name2, Font.BOLD)); numLines++; } if (sponsor.address != null) { p.add(new Chunk("\n\n", new Font(Font.FontFamily.HELVETICA, 2, Font.NORMAL))); p.add(new Chunk(sponsor.address, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); numLines++; } if (sponsor.address2 != null) { p.add(Chunk.NEWLINE); p.add(new Chunk(sponsor.address2, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); numLines++; } } p.setPaddingTop(0); p.setSpacingBefore(0); p.setAlignment(Element.ALIGN_CENTER); p.setMultipliedLeading(numLines <= 3 ? 1.3f : 1.1f); PdfPCell cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setFixedHeight(cellHeight); if (sponsor.twoColumns) { cell.setColspan(2); } if (sponsor.twoRows) { cell.setRowspan(2); if (sponsor.image == null) { p.setMultipliedLeading(p.getMultipliedLeading() * 1.5f); } } cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(CELL_EVENT); cell.setPaddingBottom(4); cell.addElement(p); if (sponsor.isTodo()) { cell.setBackgroundColor(BaseColor.ORANGE); } return cell; }
From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java
License:Open Source License
protected void buildTitle(Document document) throws DocumentException { //the title is placed in a one-column table of width 100% PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setWidthPercentage(100f);//from w w w . j a v a2 s. c o m //one row for the title PdfPCell cell = new PdfPCell(new Phrase(configuration.getTitle(), configuration.getTitleFont())); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingBottom(10f); table.addCell(cell); //one row for the subtitle cell = new PdfPCell(new Phrase(configuration.getSubtitle(), configuration.getSubtitleFont())); cell.setBorder(Rectangle.NO_BORDER); cell.setBorder(Rectangle.TOP); table.addCell(cell); //make sure that there is some spacing between the title and the scores //20f just seems to work allright, but maybe something more configurable //would be better. table.setSpacingAfter(20f); document.add(table); }
From source file:be.rheynaerde.poolsheets.ClubPoolSheet.java
License:Open Source License
@Override protected void buildTable(Document document) throws DocumentException { int columnCount = configuration.getNrOfPlayers() + configuration.getSummaryColumnCount() + 3; int nameCellWidth = 5; PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth(//from w w w. j ava 2 s. c om (configuration.getNrOfPlayers() + 1 + nameCellWidth + 0.1f + configuration.getSummaryColumnCount()) * configuration.getSquareCellSize()); table.setLockedWidth(true); float[] widths = new float[columnCount]; widths[0] = 1f * nameCellWidth; for (int i = 1; i < widths.length; i++) { widths[i] = 1f; } widths[widths.length - 1 - configuration.getSummaryColumnCount()] = 0.1f; table.setWidths(widths); PdfPCell cell = new PdfPCell(new Paragraph(configuration.getTitle(), configuration.getTitleFont())); cell.setColspan(columnCount); cell.setPaddingBottom(configuration.getSquareCellSize() / 2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); { table.addCell(getHeaderCell(bundle.getString("name"))); table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } table.addCell(new PdfPCell()); //spacer column for (int i = 0; i < configuration.getSummaryColumnCount(); i++) { table.addCell(getHeaderCell(configuration.getSummaryColumnName(i))); } } for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(configuration.getNamePlayer(i + 1) == null ? "" : configuration.getNamePlayer(i + 1)); table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < i; j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(getSolidCell()); for (int j = i + 1; j < configuration.getNrOfPlayers(); j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(new PdfPCell()); //spacer column for (int j = 0; j < configuration.getSummaryColumnCount(); j++) { String result = configuration.getSummaryColumnValue(i + 1, j); PdfPCell summaryCell = new PdfPCell(new Phrase(result == null ? "" : result)); summaryCell.setHorizontalAlignment(Element.ALIGN_CENTER); summaryCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(summaryCell); } } document.add(table); }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPTable createOrderButton(Model model) throws IOException, BadElementException { final Chunk chunk = new Chunk("Order on taconic.com", iTextUtil.getFontButton()); chunk.setAction(//from ww w . j a v a 2 s . c om new PdfAction("http://www.taconic.com/start-an-order?modelNumber=" + model.getModelNumber())); final PdfPCell cell = cell(new Phrase(chunk)); cell.setBackgroundColor(iTextUtil.getTaconicRed()); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setPaddingTop(5); cell.setPaddingBottom(8); final PdfPTable button = new PdfPTable(new float[] { 80f, 20f }); button.addCell(cell(new Phrase(" "), 2)); button.addCell(cell); button.addCell(cell(new Phrase(" "))); button.addCell(cell(new Phrase(" "), 2)); return button; }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPCell createRow(String key, String value, String url) { final Paragraph paragraph = new Paragraph(); paragraph.add(new Chunk(key, iTextUtil.getFontModelKey())); paragraph.add(new Chunk(": ", iTextUtil.getFontModelKey())); if (value == null) { value = ""; }/*from w ww. j a va 2s. com*/ final Phrase valuePhrase = processHtmlCodes(value.trim(), iTextUtil.getFontModelValue(), iTextUtil.getFontModelSymbol()); if (!StringUtils.isEmpty(url)) { for (Chunk chunk : valuePhrase.getChunks()) { chunk.setAction(new PdfAction(url)); } } for (Chunk chunk : valuePhrase.getChunks()) { chunk.setLineHeight(13f); } paragraph.add(valuePhrase); final PdfPCell cell = cell(paragraph); cell.setPaddingBottom(5f); return cell; }
From source file:com.dandymadeproductions.ajqvue.io.PDFDataTableDumpThread.java
License:Open Source License
public void run() { // Class Method Instances String title;//from w w w . j a va 2s . c om Font titleFont; Font rowHeaderFont; Font tableDataFont; BaseFont rowHeaderBaseFont; PdfPTable pdfTable; PdfPCell titleCell; PdfPCell rowHeaderCell; PdfPCell bodyCell; Document pdfDocument; PdfWriter pdfWriter; ByteArrayOutputStream byteArrayOutputStream; int columnCount, rowNumber; int[] columnWidths; int totalWidth; Rectangle pageSize; ProgressBar dumpProgressBar; HashMap<String, String> summaryListTableNameTypes; DataExportProperties pdfDataExportOptions; String currentTableFieldName; String currentType, currentString; // Setup columnCount = summaryListTable.getColumnCount(); rowNumber = summaryListTable.getRowCount(); columnWidths = new int[columnCount]; pdfTable = new PdfPTable(columnCount); pdfTable.setWidthPercentage(100); pdfTable.getDefaultCell().setPaddingBottom(4); pdfTable.getDefaultCell().setBorderWidth(1); summaryListTableNameTypes = new HashMap<String, String>(); pdfDataExportOptions = DBTablesPanel.getDataExportProperties(); titleFont = new Font(pdfDataExportOptions.getFont()); titleFont.setStyle(Font.BOLD); titleFont.setSize((float) pdfDataExportOptions.getTitleFontSize()); titleFont.setColor(new BaseColor(pdfDataExportOptions.getTitleColor().getRGB())); rowHeaderFont = new Font(pdfDataExportOptions.getFont()); rowHeaderFont.setStyle(Font.BOLD); rowHeaderFont.setSize((float) pdfDataExportOptions.getHeaderFontSize()); rowHeaderFont.setColor(new BaseColor(pdfDataExportOptions.getHeaderColor().getRGB())); rowHeaderBaseFont = rowHeaderFont.getCalculatedBaseFont(false); tableDataFont = pdfDataExportOptions.getFont(); // Constructing progress bar. dumpProgressBar = new ProgressBar(exportedTable + " Dump"); dumpProgressBar.setTaskLength(rowNumber); dumpProgressBar.pack(); dumpProgressBar.center(); dumpProgressBar.setVisible(true); // Create a Title if Optioned. title = pdfDataExportOptions.getTitle(); if (!title.equals("")) { if (title.equals("EXPORTED TABLE")) title = exportedTable; titleCell = new PdfPCell(new Phrase(title, titleFont)); titleCell.setBorder(0); titleCell.setPadding(10); titleCell.setColspan(summaryListTable.getColumnCount()); titleCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pdfTable.addCell(titleCell); pdfTable.setHeaderRows(2); } else pdfTable.setHeaderRows(1); // Create Row Header. for (int i = 0; i < columnCount; i++) { currentTableFieldName = summaryListTable.getColumnName(i); rowHeaderCell = new PdfPCell(new Phrase(currentTableFieldName, rowHeaderFont)); rowHeaderCell.setBorderWidth(pdfDataExportOptions.getHeaderBorderSize()); rowHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); rowHeaderCell.setBorderColor(new BaseColor(pdfDataExportOptions.getHeaderBorderColor().getRGB())); pdfTable.addCell(rowHeaderCell); columnWidths[i] = Math.min(50000, Math.max(columnWidths[i], rowHeaderBaseFont.getWidth(currentTableFieldName + " "))); if (tableColumnTypeNameHashMap != null) summaryListTableNameTypes.put(Integer.toString(i), tableColumnTypeNameHashMap.get(currentTableFieldName)); else summaryListTableNameTypes.put(Integer.toString(i), "String"); } // Create the Body of Data. int i = 0; while ((i < rowNumber) && !dumpProgressBar.isCanceled()) { dumpProgressBar.setCurrentValue(i); // Collecting rows of data & formatting date & timestamps // as needed according to the Export Properties. if (summaryListTable.getValueAt(i, 0) != null) { for (int j = 0; j < summaryListTable.getColumnCount(); j++) { currentString = summaryListTable.getValueAt(i, j) + ""; currentString = currentString.replaceAll("\n", ""); currentString = currentString.replaceAll("\r", ""); currentType = summaryListTableNameTypes.get(Integer.toString(j)); // Format Date & Timestamp Fields as Needed. if ((currentType != null) && (currentType.equals("DATE") || currentType.equals("DATETIME") || currentType.indexOf("TIMESTAMP") != -1)) { if (!currentString.toLowerCase(Locale.ENGLISH).equals("null")) { int firstSpace; String time; // Dates fall through DateTime and Timestamps try // to get the time separated before formatting // the date. if (currentString.indexOf(" ") != -1) { firstSpace = currentString.indexOf(" "); time = currentString.substring(firstSpace); currentString = currentString.substring(0, firstSpace); } else time = ""; currentString = Utils.convertViewDateString_To_DBDateString(currentString, DBTablesPanel.getGeneralDBProperties().getViewDateFormat()); currentString = Utils.convertDBDateString_To_ViewDateString(currentString, pdfDataExportOptions.getPDFDateFormat()) + time; } } bodyCell = new PdfPCell(new Phrase(currentString, tableDataFont)); bodyCell.setPaddingBottom(4); if (currentType != null) { // Set Numeric Fields Alignment. if (currentType.indexOf("BIT") != -1 || currentType.indexOf("BOOL") != -1 || currentType.indexOf("NUM") != -1 || currentType.indexOf("INT") != -1 || currentType.indexOf("FLOAT") != -1 || currentType.indexOf("DOUBLE") != -1 || currentType.equals("REAL") || currentType.equals("DECIMAL") || currentType.indexOf("COUNTER") != -1 || currentType.equals("BYTE") || currentType.equals("CURRENCY")) { bodyCell.setHorizontalAlignment(pdfDataExportOptions.getNumberAlignment()); bodyCell.setPaddingRight(4); } // Set Date/Time Field Alignment. if (currentType.indexOf("DATE") != -1 || currentType.indexOf("TIME") != -1 || currentType.indexOf("YEAR") != -1) bodyCell.setHorizontalAlignment(pdfDataExportOptions.getDateAlignment()); } pdfTable.addCell(bodyCell); columnWidths[j] = Math.min(50000, Math.max(columnWidths[j], BASE_FONT.getWidth(currentString + " "))); } } i++; } dumpProgressBar.dispose(); // Check to see if any data was in the summary // table to even be saved. if (pdfTable.size() <= pdfTable.getHeaderRows()) return; // Create a document of the PDF formatted data // to be saved to the given output file. try { // Sizing & Layout totalWidth = 0; for (int width : columnWidths) totalWidth += width; if (pdfDataExportOptions.getPageLayout() == PDFExportPreferencesPanel.LAYOUT_PORTRAIT) pageSize = PageSize.A4; else { pageSize = PageSize.A4.rotate(); pageSize.setRight(pageSize.getRight() * Math.max(1f, totalWidth / 53000f)); pageSize.setTop(pageSize.getTop() * Math.max(1f, totalWidth / 53000f)); } pdfTable.setWidths(columnWidths); // Document pdfDocument = new Document(pageSize); byteArrayOutputStream = new ByteArrayOutputStream(); pdfWriter = PdfWriter.getInstance(pdfDocument, byteArrayOutputStream); pdfDocument.open(); pdfTemplate = pdfWriter.getDirectContent().createTemplate(100, 100); pdfTemplate.setBoundingBox(new com.itextpdf.text.Rectangle(-20, -20, 100, 100)); pdfWriter.setPageEvent(this); pdfDocument.add(pdfTable); pdfDocument.close(); // Outputting WriteDataFile.mainWriteDataString(fileName, byteArrayOutputStream.toByteArray(), false); } catch (DocumentException de) { if (Ajqvue.getDebug()) { System.out.println("Failed to Create Document Needed to Output Data. \n" + de.toString()); } } }
From source file:com.deadormi.servlet.CreaPdfServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww . j a v a2 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.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable bodySection() throws Exception { String exportRefRemarks = ""; String routingInsRemarks = ""; String InsStatement = ""; StringBuilder pierValues = new StringBuilder(); String[] remarkTypes = { REMARKS_TYPE_ROUTING_INSTRU, REMARKS_TYPE_EXPORT_REF }; List remarks = new LclRemarksDAO().getRemarksByTypes(lclbl.getFileNumberId(), remarkTypes); for (Object row : remarks) { Object[] col = (Object[]) row; if (col[1].toString().equalsIgnoreCase("Export Reference")) { exportRefRemarks = col[0].toString(); }/* w w w .j a va2s . com*/ if (col[1].toString().equalsIgnoreCase("Routing Instruction")) { routingInsRemarks = col[0].toString(); } } String bill_type = lclbl.getBillingType(); billingType = bill_type.equalsIgnoreCase("P") ? "** FREIGHT PREPAID **" : bill_type.equalsIgnoreCase("C") ? "** FREIGHT COLLECT **" : bill_type.equalsIgnoreCase("B") && "Y".equalsIgnoreCase(printPpdBlBothKey) ? "** FREIGHT PREPAID **" : "** FREIGHT COLLECT **"; billType = bill_type.equalsIgnoreCase("P") ? "PPD" : bill_type.equalsIgnoreCase("C") ? "COL" : "BOTH"; LclSsDetail bookedOrPickedVoy = null; ExportVoyageSearchModel pickedDetails = new LclUnitSsDAO() .getPickedVoyageByVessel(lclBooking.getFileNumberId(), "E"); if (pickedDetails != null && CommonUtils.isNotEmpty(pickedDetails.getUnitSsId())) { LclUnitSs lclUnitSs = new LclUnitSsDAO().findById(Long.parseLong(pickedDetails.getUnitSsId())); bookedOrPickedVoy = lclUnitSs.getLclSsHeader().getVesselSsDetail(); unitNumber = lclUnitSs.getLclUnit().getUnitNo(); voyageNumber = lclUnitSs.getLclSsHeader().getScheduleNo(); sealOut = CommonUtils.isNotEmpty(lclUnitSs.getSUHeadingNote()) ? lclUnitSs.getSUHeadingNote().toUpperCase() : ""; } else { bookedOrPickedVoy = null != lclbl.getBookedSsHeaderId() ? lclbl.getBookedSsHeaderId().getVesselSsDetail() : null; } StringBuilder carrierName = new StringBuilder(); if (bookedOrPickedVoy != null) { sailDate = DateUtils.formatStringDateToAppFormatMMM(bookedOrPickedVoy.getStd()); sailDateFormat = DateUtils.formatDateToMMMMDDYYYY(bookedOrPickedVoy.getStd()); ladenSailDateRemarks = "\nLaden On Board:" + sailDate; if (CommonFunctions.isNotNull(bookedOrPickedVoy.getSpReferenceName())) { carrierName.append(bookedOrPickedVoy.getSpReferenceName()).append(" "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getTransMode())) { carrierName.append(bookedOrPickedVoy.getTransMode()).append(". "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getSpReferenceNo())) { carrierName.append(bookedOrPickedVoy.getSpReferenceNo()); } pierValues.append(bookedOrPickedVoy.getDeparture().getUnLocationName()); if (null != bookedOrPickedVoy.getDeparture().getStateId()) { pierValues.append("/").append(bookedOrPickedVoy.getDeparture().getStateId().getCode()); } } Paragraph p = null; table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 5.3f, 4.7f }); PdfPCell bCell = null; bCell = new PdfPCell(); bCell.setBorder(0); bCell.setPadding(0f); bCell.setBorderWidthBottom(0.06f); bCell.setBorderWidthTop(0.06f); bCell.setBorderWidthRight(0.06f); PdfPTable bTable = new PdfPTable(2); bTable.setWidths(new float[] { 5f, 4f }); bTable.setWidthPercentage(100f); bTable.addCell(makeCellLeftTopNoBorderFont("SHIPPER/EXPORTER", -0.5f, 0.8f, blackBoldFont65)); PdfPCell shCell = new PdfPCell(); shCell.setBorder(0); shCell.setColspan(2); shCell.setPadding(0f); shCell.setPaddingLeft(4f); shCell.setBorderWidthBottom(0.06f); shCell.setFixedHeight(65f); String shipperDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getShipContact()); if (CommonUtils.isNotEmpty(shipperDetails)) { p = new Paragraph(11f, "" + shipperDetails.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(15f); } else { p = new Paragraph(8f, "", totalFontQuote); shCell.setPadding(35f); } shCell.addElement(p); bTable.addCell(shCell); //consignee bTable.addCell(makeCellLeftTopNoBorderFont("CONSIGNEE", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell cvCell = new PdfPCell(); cvCell.setBorder(0); cvCell.setColspan(2); cvCell.setPadding(0f); cvCell.setPaddingLeft(4f); cvCell.setBorderWidthBottom(0.06f); cvCell.setFixedHeight(65f); String consDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getConsContact()); if (CommonUtils.isNotEmpty(consDetails)) { p = new Paragraph(11f, "" + consDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); cvCell.setPadding(30f); } cvCell.addElement(p); bTable.addCell(cvCell); //Notify bTable.addCell(makeCellLeftTopNoBorderFont("NOTIFY PARTY", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell nvCell = new PdfPCell(); nvCell.setBorder(0); nvCell.setColspan(2); nvCell.setPadding(0f); nvCell.setPaddingLeft(4f); nvCell.setBorderWidthBottom(0.06f); nvCell.setFixedHeight(70f); String notyDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getNotyContact()); if (CommonUtils.isNotEmpty(notyDetails)) { p = new Paragraph(11f, "" + notyDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(25f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); nvCell.setPadding(40f); } nvCell.addElement(p); bTable.addCell(nvCell); //place of receipt PdfPCell prCell = new PdfPCell(); prCell.setBorder(0); prCell.setPaddingLeft(-0.9f); prCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PLACE OF RECEIPT", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); prCell.addElement(p); bTable.addCell(prCell); /* Pier Logic */ String pier = "N".equalsIgnoreCase(printPierPol) ? ("N".equalsIgnoreCase(printPierPol) && !"N".equalsIgnoreCase(hblPierOverRideKey)) ? hblPierOverRideKey : pierValues.toString() : ""; /* POL Logic */ String pol = ""; if ("Y".equalsIgnoreCase(printPierPol)) { if ("N".equalsIgnoreCase(hblPierOverRideKey)) { pol = pierValues.toString(); } else { pol = hblPierOverRideKey; } } else { pol = !"N".equalsIgnoreCase(hblPolOverRideKey) ? hblPolOverRideKey : polValues; } Boolean checkBlInsurance = new LclBlAcDAO().checkBlInsurance(lclbl.getFileNumberId(), INSURANCE_CHARGE_CODE); if (checkBlInsurance && "Y".equalsIgnoreCase(printBlInsuranceKey)) { InsStatement = LoadLogisoftProperties.getProperty("InsuranceChargeComment"); } PdfPCell pierCell = new PdfPCell(); pierCell.setBorder(0); pierCell.setBorderWidthLeft(0.06f); pierCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PIER", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pierCell.addElement(p); bTable.addCell(pierCell); //place of receipt values PdfPCell prvCell = new PdfPCell(); prvCell.setBorder(0); prvCell.setBorderWidthBottom(0.06f); if (lclBooking.getPooPickup()) { LclBookingPad lclBookingPad = lclBooking.getLclFileNumber().getLclBookingPadList().get(0); String pickUp_city = lclBookingPad.getPickUpCity().replaceAll("/", ","); pickUp_city = pickUp_city.substring(pickUp_city.indexOf("-") + 1, pickUp_city.length()); p = new Paragraph(7f, "" + pickUp_city.toUpperCase(), totalFontQuote); } else { StringBuilder placeofReceipt = new StringBuilder(); if (null != lclbl.getPortOfOrigin()) { placeofReceipt.append(lclbl.getPortOfOrigin().getUnLocationName()); if (CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId()) && CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId().getCode())) { placeofReceipt.append(",").append(lclbl.getPortOfOrigin().getStateId().getCode()); } } p = new Paragraph(7f, "" + placeofReceipt.toString().toUpperCase(), totalFontQuote); } p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); prvCell.addElement(p); bTable.addCell(prvCell); //pier values PdfPCell piervCell = new PdfPCell(); piervCell.setBorder(0); piervCell.setBorderWidthLeft(0.06f); piervCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pier, totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); piervCell.addElement(p); bTable.addCell(piervCell); //exporting carrier PdfPCell ecCell = new PdfPCell(); ecCell.setBorder(0); ecCell.setPaddingLeft(-0.5f); ecCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "EXPORTING CARRIER (Vessel) (Flag)", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); ecCell.addElement(p); bTable.addCell(ecCell); //portof loading PdfPCell portCell = new PdfPCell(); portCell.setBorder(0); portCell.setPaddingTop(-0.2f); portCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, "PORT OF LOADING", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); portCell.addElement(p); bTable.addCell(portCell); //exporting values PdfPCell exvCell = new PdfPCell(); exvCell.setBorder(0); exvCell.setFixedHeight(15f); exvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + carrierName.toString().toUpperCase(), totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); exvCell.addElement(p); bTable.addCell(exvCell); //port of loading values PdfPCell portvCell = new PdfPCell(); portvCell.setBorder(0); portvCell.setBorderWidthLeft(0.06f); portvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pol.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); portvCell.addElement(p); bTable.addCell(portvCell); //sea port of discharge PdfPCell seaCell = new PdfPCell(); seaCell.setBorder(0); seaCell.setPaddingLeft(-0.5f); seaCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "SEA PORT OF DISCHARGE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); seaCell.addElement(p); bTable.addCell(seaCell); //finalde PdfPCell finalCell = new PdfPCell(); finalCell.setBorder(0); finalCell.setBorderWidthLeft(0.06f); finalCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "FINAL DELIVERY TO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); finalCell.addElement(p); bTable.addCell(finalCell); //sea values PdfPCell seavCell = new PdfPCell(); seavCell.setBorder(0); seavCell.setFixedHeight(25f); // seavCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + podValues.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); seavCell.addElement(p); bTable.addCell(seavCell); //fina deliver values String finalDest = !fdOverride.equalsIgnoreCase("N") ? fdOverride : (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) ? agencyInfo[2] : blUtils.getBLConcatenatedFinalDestination(lclbl); PdfPCell finalvCell = new PdfPCell(); finalvCell.setBorder(0); finalvCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, !finalDest.equalsIgnoreCase(podValues) ? "" + finalDest.toUpperCase() : "", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); finalvCell.addElement(p); bTable.addCell(finalvCell); bCell.addElement(bTable); table.addCell(bCell); //2column cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); PdfPTable pTable = new PdfPTable(2); pTable.setWidths(new float[] { 4f, 2f }); pTable.setWidthPercentage(100f); PdfPCell nCell = null; nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOCUMENT NO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); nCell.addElement(p); pTable.addCell(nCell); nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "PAGE : " + ++page_count, blackBoldFont65); p.setAlignment(Element.ALIGN_RIGHT); nCell.addElement(p); pTable.addCell(nCell); String consolidateNumber = new LclConsolidateDAO() .getConsolidatesFileNumbers(lclbl.getLclFileNumber().getId().toString()); consolidateNumber = null == consolidateNumber ? lclbl.getLclFileNumber().getFileNumber() : lclbl.getLclFileNumber().getFileNumber() + "," + consolidateNumber; PdfPCell dvCell = new PdfPCell(); dvCell.setBorder(0); dvCell.setColspan(2); dvCell.setBorderWidthBottom(0.06f); dvCell.setPaddingLeft(8f); dvCell.setPaddingBottom(5f); dvCell.setPaddingTop(2f); p = new Paragraph(8f, "" + consolidateNumber.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); dvCell.addElement(p); pTable.addCell(dvCell); PdfPCell eCell = new PdfPCell(); eCell.setBorder(0); eCell.setPaddingTop(0.2f); eCell.setColspan(2); p = new Paragraph(7f, "EXPORT REFERENCE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); eCell.addElement(p); pTable.addCell(eCell); PdfPCell evCell = new PdfPCell(); evCell.setBorder(0); evCell.setColspan(2); evCell.setBorderWidthBottom(0.06f); evCell.setPaddingLeft(8f); evCell.setFixedHeight(35f); exportRefRemarks = exportRefRemarks + ("EXPORT".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("EXPORT".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (exportRefRemarks != null && !exportRefRemarks.equals("")) { p = new Paragraph(10f, "" + exportRefRemarks, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); } evCell.addElement(p); pTable.addCell(evCell); PdfPCell fCell = new PdfPCell(); fCell.setBorder(0); fCell.setColspan(2); fCell.setPaddingTop(0.2f); p = new Paragraph(7f, "FORWARDING AGENT-REFERENCES", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); fCell.addElement(p); pTable.addCell(fCell); //forwarding avlues PdfPCell fvCell = new PdfPCell(); fvCell.setBorder(0); fvCell.setColspan(2); fvCell.setPaddingLeft(3f); fvCell.setPaddingTop(2f); fvCell.setBorderWidthBottom(0.06f); fvCell.setFixedHeight(65f); if (null != lclbl.getFwdAcct() && !lclbl.getFwdAcct().getAccountName().equalsIgnoreCase("NO FRT. FORWARDER ASSIGNED")) { boolean forwarderAcctFlag = new LCLBlDAO() .getFreightForwardAcctStatus(lclbl.getFwdAcct().getAccountno()); String fwdDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getFwdContact()); if (CommonUtils.isNotEmpty(fwdDetails) && !forwarderAcctFlag) { p = new Paragraph(11f, "" + fwdDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setPadding(25f); } fvCell.addElement(p); pTable.addCell(fvCell); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setBorderWidthBottom(0.06f); pTable.addCell(fvCell); } //pointoforigin PdfPCell pCell = new PdfPCell(); pCell.setBorder(0); pCell.setColspan(2); pCell.setPaddingTop(0.2f); p = new Paragraph(7f, "POINT AND COUNTRY OF ORIGIN", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pCell.addElement(p); pTable.addCell(pCell); //point avlues PdfPCell pvCell = new PdfPCell(); pvCell.setBorder(0); pvCell.setColspan(2); pvCell.setPaddingLeft(8f); pvCell.setPaddingBottom(5f); pvCell.setPaddingTop(2f); pvCell.setFixedHeight(20f); pvCell.setBorderWidthBottom(0.06f); if (lclbl.getPointOfOrigin() != null) { p = new Paragraph(9f, "" + lclbl.getPointOfOrigin(), totalFontQuote); pvCell.addElement(p); } p.setAlignment(Element.ALIGN_LEFT); pTable.addCell(pvCell); //domes PdfPCell doCell = new PdfPCell(); doCell.setBorder(0); doCell.setColspan(2); doCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOMESTIC ROUTING/EXPORT INSTRUCTIONS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); doCell.addElement(p); pTable.addCell(doCell); //point avlues PdfPCell dovCell = new PdfPCell(); dovCell.setBorder(0); dovCell.setColspan(2); dovCell.setPaddingLeft(8f); dovCell.setBorderWidthBottom(0.06f); dovCell.setFixedHeight(45f); routingInsRemarks = routingInsRemarks + ("ROUTING".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("ROUTING".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (routingInsRemarks != null && !"".equalsIgnoreCase(routingInsRemarks)) { p = new Paragraph(10f, "" + routingInsRemarks, totalFontQuote); p.setSpacingAfter(10f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); dovCell.setPadding(15f); } dovCell.addElement(p); pTable.addCell(dovCell); //addito PdfPCell adCell = new PdfPCell(); adCell.setBorder(0); adCell.setColspan(2); adCell.setPaddingTop(0.2f); p = new Paragraph(7f, "ADDITIONAL DOCUMENT NUMBERS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); adCell.addElement(p); pTable.addCell(adCell); //add values PdfPCell advCell = new PdfPCell(); advCell.setBorder(0); advCell.setColspan(2); advCell.setPadding(10f); p = new Paragraph(7f, InsStatement, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); advCell.addElement(p); pTable.addCell(advCell); cell.addElement(pTable); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public void setCaribbenAndNonCaribben(LclBlPiece lclBlPiece, String impKeyValue, String metKeyValue, boolean iscaribben) throws Exception { String AWImp = "0.000", AVImp = "0.000"; String AWMet = "0.000", AVMet = "0.000"; if (lclBlPiece.getActualWeightImperial() != null) { AWImp = "Y".equalsIgnoreCase(impKeyValue) ? NumberUtils.convertToThreeDecimalhash(lclBlPiece.getActualWeightImperial().doubleValue()) : lclBlPiece.getActualWeightImperial().setScale(0, BigDecimal.ROUND_HALF_UP).toString(); }//from w w w. j av a 2s . c o m if (lclBlPiece.getActualVolumeImperial() != null) { AVImp = "Y".equalsIgnoreCase(impKeyValue) ? NumberUtils.convertToThreeDecimalhash(lclBlPiece.getActualVolumeImperial().doubleValue()) : lclBlPiece.getActualVolumeImperial().setScale(0, BigDecimal.ROUND_HALF_UP).toString(); } if ("N".equalsIgnoreCase(metKeyValue) && lclBlPiece.getActualWeightMetric() != null) { AWMet = NumberUtils.convertToThreeDecimalhash(lclBlPiece.getActualWeightMetric().doubleValue()); } if ("N".equalsIgnoreCase(metKeyValue) && lclBlPiece.getActualVolumeMetric() != null) { AVMet = NumberUtils.convertToThreeDecimalhash(lclBlPiece.getActualVolumeMetric().doubleValue()); } Paragraph p = null; cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); PdfPTable inner_Table = new PdfPTable(1); inner_Table.setWidthPercentage(100f); PdfPCell inner_Cell = null; inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setBorderWidthBottom(0.6f); p = new Paragraph(6f, iscaribben ? "LBS" : "KGS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); p = new Paragraph(7f, iscaribben ? AWImp : AWMet, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setPaddingBottom(18f); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); if ("N".equalsIgnoreCase(metKeyValue)) { inner_Cell.setBorderWidthBottom(0.6f); p = new Paragraph(6f, iscaribben ? "KGS" : "LBS", blackBoldFont65); } else { AWMet = ""; AWImp = ""; p = new Paragraph(6f, "", blackBoldFont65); } p.setAlignment(Element.ALIGN_LEFT); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); p = new Paragraph(7f, iscaribben ? AWMet : AWImp, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); if (commodity_count != lclBlPiecesList.size()) { inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setPaddingBottom(16f); inner_Table.addCell(inner_Cell); } cell.addElement(inner_Table); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); inner_Table = new PdfPTable(1); inner_Table.setWidthPercentage(100f); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setBorderWidthBottom(0.6f); p = new Paragraph(6f, iscaribben ? "CU.FT." : "CBM", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); p = new Paragraph(7f, iscaribben ? AVImp : AVMet, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setPaddingBottom(18f); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); if ("N".equalsIgnoreCase(metKeyValue)) { inner_Cell.setBorderWidthBottom(0.6f); p = new Paragraph(6f, iscaribben ? "CBM" : "CU.FT.", blackBoldFont65); } else { AVMet = ""; AVImp = ""; p = new Paragraph(6f, "", blackBoldFont65); } p.setAlignment(Element.ALIGN_LEFT); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); p = new Paragraph(7f, iscaribben ? AVMet : AVImp, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); inner_Cell.addElement(p); inner_Table.addCell(inner_Cell); if (commodity_count != lclBlPiecesList.size()) { inner_Cell = new PdfPCell(); inner_Cell.setBorder(0); inner_Cell.setPaddingBottom(16f); inner_Table.addCell(inner_Cell); } cell.addElement(inner_Table); table.addCell(cell); }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable appendChargesAndCommodity() throws Exception { LclBlAcDAO lclBlAcDAO = new LclBlAcDAO(); List<LclBlPiece> lclBlPiecesList = lclbl.getLclFileNumber().getLclBlPieceList(); List<LclBlAc> chargeList = lclBlAcDAO.getLclCostByFileNumberAsc(lclbl.getFileNumberId()); PdfPTable chargeTable = new PdfPTable(6); PdfPCell chargeCell = null;//from w w w. j ava2 s. com chargeTable.setWidths(new float[] { 3.8f, 1.5f, .8f, 3.8f, 1.5f, .8f }); chargeTable.setWidthPercentage(100f); Paragraph p = null; this.total_ar_amount = 0.00; this.total_ar_col_amount = 0.00; this.total_ar_ppd_amount = 0.00; List<LinkedHashMap<String, PdfPCell>> listChargeMap = null; LinkedHashMap<String, PdfPCell> chargeMap = null; if ("BOTH".equalsIgnoreCase(billType)) { listChargeMap = this.getTotalChargesList(chargeList, lclBlPiecesList); } else { chargeMap = this.getTotalCharges(chargeList, lclBlPiecesList); } LclBlAc blAC = lclBlAcDAO.manualChargeValidate(lclbl.getFileNumberId(), "OCNFRT", false); if (lclBlPiecesList != null && lclBlPiecesList.size() > 0 && blAC != null) { BigDecimal CFT = BigDecimal.ZERO, LBS = BigDecimal.ZERO; LclBlPiece lclBlPiece = (LclBlPiece) lclBlPiecesList.get(0); if (blAC.getRatePerUnitUom() != null) { CFT = blAC.getRatePerUnitUom().equalsIgnoreCase("FRV") ? blAC.getRatePerVolumeUnit() : BigDecimal.ZERO; LBS = blAC.getRatePerUnitUom().equalsIgnoreCase("FRW") ? blAC.getRatePerWeightUnit() : BigDecimal.ZERO; } if (CFT != BigDecimal.ZERO || LBS != BigDecimal.ZERO) { StringBuilder cbmValues = new StringBuilder(); if (CFT != BigDecimal.ZERO && lclBlPiece.getActualVolumeImperial() != null) { cbmValues.append(NumberUtils .convertToThreeDecimalhash(lclBlPiece.getActualVolumeImperial().doubleValue())); } if (LBS != BigDecimal.ZERO && lclBlPiece.getActualWeightImperial() != null) { cbmValues.append(NumberUtils .convertToThreeDecimalhash(lclBlPiece.getActualWeightImperial().doubleValue())); } if (null != blAC.getArAmount() && blAC.getArAmount().toString().equalsIgnoreCase(OCNFRT_Total)) { if (CFT == BigDecimal.ZERO) { cbmValues.append(" LBS @ ").append(LBS).append(" PER 100 LBS @ ") .append(blAC.getArAmount()); } else { cbmValues.append(" CFT @ ").append(CFT).append(" PER CFT @").append(blAC.getArAmount()); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(6); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(6); p = new Paragraph(2f, "" + cbmValues.toString().toUpperCase(), totalFontQuote); p.add(new Paragraph(2f, null != lclBlPiece && null != lclBlPiece.getCommodityType() ? " Commodity# " + lclBlPiece.getCommodityType().getCode() : " Commodity#", totalFontQuote)); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } } } this.OCNFRT_Total = ""; LinkedHashMap<String, PdfPCell> left_chargeMap = new LinkedHashMap<String, PdfPCell>(); LinkedHashMap<String, PdfPCell> right_chargeMap = new LinkedHashMap<String, PdfPCell>(); if ("BOTH".equalsIgnoreCase(billType) && listChargeMap != null && !listChargeMap.isEmpty()) { if (listChargeMap.size() > 1) { if (listChargeMap.get(0).size() > 6 || listChargeMap.get(1).size() > 6) { chargeMap = new LinkedHashMap<String, PdfPCell>(); chargeMap.putAll(listChargeMap.get(0)); chargeMap.putAll(listChargeMap.get(1)); int count = 0, size = chargeMap.size() / 2 <= 6 ? 6 : chargeMap.size() / 2; for (String key : chargeMap.keySet()) { if (count++ < size) { left_chargeMap.put(key, chargeMap.get(key)); } else { right_chargeMap.put(key, chargeMap.get(key)); } } } else { left_chargeMap.putAll(listChargeMap.get(0)); right_chargeMap.putAll(listChargeMap.get(1)); } } else { int count = 0, size = listChargeMap.get(0).size() / 2 <= 6 ? 6 : listChargeMap.get(0).size() / 2; for (String key : listChargeMap.get(0).keySet()) { if (count++ < size) { left_chargeMap.put(key, listChargeMap.get(0).get(key)); } else { right_chargeMap.put(key, listChargeMap.get(0).get(key)); } } } } else if (chargeMap != null && !chargeMap.isEmpty()) { int count = 0, size = chargeMap.size() / 2 <= 6 ? 6 : chargeMap.size() / 2; for (String key : chargeMap.keySet()) { if (count++ < size) { left_chargeMap.put(key, chargeMap.get(key)); } else { right_chargeMap.put(key, chargeMap.get(key)); } } } if (!left_chargeMap.isEmpty()) { String chargeDesc = null; PdfPTable innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidthPercentage(100f); PdfPCell inner_chargeCell = null; chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setBorderWidthRight(0.6f); chargeCell.setPadding(0); innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidths(new float[] { 5f, 3f }); if (!left_chargeMap.isEmpty()) { for (String key : left_chargeMap.keySet()) { inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell.setPaddingLeft(-15); chargeDesc = key.substring(key.indexOf("#") + 1, key.indexOf("$")); inner_chargeCell.addElement(new Paragraph(7f, "" + chargeDesc, totalFontQuote)); innner_chargeTable.addCell(inner_chargeCell); inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell = left_chargeMap.get(key); innner_chargeTable.addCell(inner_chargeCell); } } chargeCell.addElement(innner_chargeTable); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPadding(0); innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidths(new float[] { 5f, 3f }); if (!left_chargeMap.isEmpty()) { for (String key : right_chargeMap.keySet()) { inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell.setPaddingLeft(-15); chargeDesc = key.substring(key.indexOf("#") + 1, key.indexOf("$")); inner_chargeCell.addElement(new Paragraph(7f, "" + chargeDesc, totalFontQuote)); innner_chargeTable.addCell(inner_chargeCell); inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell = right_chargeMap.get(key); innner_chargeTable.addCell(inner_chargeCell); } } chargeCell.addElement(innner_chargeTable); chargeTable.addCell(chargeCell); } else { this.total_ar_amount = 0.00; this.total_ar_ppd_amount = 0.00; this.total_ar_col_amount = 0.00; } String acctNo = ""; String billToParty = ""; if (CommonFunctions.isNotNull(lclbl.getBillToParty()) && CommonUtils.isNotEmpty(lclbl.getBillToParty())) { if (lclbl.getBillToParty().equalsIgnoreCase("T") && CommonFunctions.isNotNull(lclbl.getThirdPartyAcct())) { billToParty = "THIRD PARTY"; acctNo = lclbl.getThirdPartyAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("S") && CommonFunctions.isNotNull(lclbl.getShipAcct())) { billToParty = "SHIPPER"; acctNo = lclbl.getShipAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("F") && CommonFunctions.isNotNull(lclbl.getFwdAcct())) { billToParty = "FORWARDER"; acctNo = lclbl.getFwdAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("A") && CommonFunctions.isNotNull(lclbl.getAgentAcct())) { billToParty = "AGENT"; if (lclBooking.getBookingType().equals("T") && lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() != null) { acctNo = lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo().getAccountno(); } else if (lclBooking.getAgentAcct() != null) { acctNo = lclBooking.getAgentAcct().getAccountno(); } else { acctNo = lclbl.getAgentAcct().getAccountno(); } } } if ("BOTH".equalsIgnoreCase(billType)) { if (this.total_ar_ppd_amount != 0.00 || this.total_ar_col_amount != 0.00) { if (this.total_ar_ppd_amount != 0.00) { if (CommonFunctions.isNotNullOrNotEmpty(ppdBillToSet) && ppdBillToSet.size() == 1) { for (String billTo : ppdBillToSet) { arBillToParty = billTo; break; } if (arBillToParty.equalsIgnoreCase("T")) { billToParty = "THIRD PARTY"; acctNo = null != lclbl.getThirdPartyAcct() ? lclbl.getThirdPartyAcct().getAccountno() : acctNo; } else if (arBillToParty.equalsIgnoreCase("S")) { acctNo = null != lclbl.getShipAcct() ? lclbl.getShipAcct().getAccountno() : acctNo; billToParty = "SHIPPER"; } else if (arBillToParty.equalsIgnoreCase("F")) { billToParty = "FORWARDER"; acctNo = null != lclbl.getFwdAcct() ? lclbl.getFwdAcct().getAccountno() : acctNo; } } else { acctNo = null; } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); if (null != acctNo) { p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_ppd_amount) + " PPD " + billToParty + "-" + acctNo, totalFontQuote); } else { p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_ppd_amount) + " PPD ", totalFontQuote); } p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } if (this.total_ar_col_amount != 0.00) { String colAcctNo = ""; if (lclBooking.getBookingType().equals("T") && lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() != null) { colAcctNo = lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() .getAccountno(); } else if (lclBooking.getAgentAcct() != null) { colAcctNo = lclBooking.getAgentAcct().getAccountno(); } else if (lclbl.getAgentAcct() != null) { colAcctNo = lclbl.getAgentAcct().getAccountno(); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); if (this.total_ar_ppd_amount == 0.00) { p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); } else { p = new Paragraph(7f, "", totalFontQuote); } p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_col_amount) + " COL AGENT-" + colAcctNo, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } NumberFormat numberFormat = new DecimalFormat("###,###,##0.000"); if (this.total_ar_ppd_amount != 0.00) { String totalString1 = numberFormat.format(this.total_ar_ppd_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } if (this.total_ar_col_amount != 0.00) { String totalString1 = numberFormat.format(this.total_ar_col_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } } } else if (this.total_ar_amount != 0.00) { chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); chargeCell.setPaddingTop(8f); p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); chargeCell.setPaddingTop(8f); p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_amount) + " " + billType + " " + billToParty + "-" + acctNo, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); NumberFormat numberFormat = new DecimalFormat("###,###,##0.000"); String totalString1 = numberFormat.format(this.total_ar_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(4); p = new Paragraph(5f, "" + sailDateFormat, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(5); chargeCell.setBorder(0); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(3); chargeCell.setBorder(0); chargeCell.setRowspan(3); String fdPodValue = null; if (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) { fdPodValue = agencyInfo[2]; } else if (CommonFunctions.isNotNull(lclbl.getFinalDestination()) && CommonFunctions.isNotNull(lclbl.getFinalDestination().getCountryId()) && CommonFunctions.isNotNull(lclbl.getFinalDestination().getCountryId().getCodedesc())) { fdPodValue = lclbl.getFinalDestination().getUnLocationName() + "," + lclbl.getFinalDestination().getCountryId().getCodedesc(); } p = new Paragraph(7f, fdPodValue != null ? fdPodValue.toUpperCase() : podValues.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); p = new Paragraph(5f, "UNIT# " + unitNumber, headingblackBoldFont); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPaddingTop(2f); p = new Paragraph(5f, "SEAL# " + sealOut, headingblackBoldFont); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPaddingTop(2f); p = new Paragraph(5f, "CONTROL-VOY# " + voyageNumber, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); String emailId = ""; StringBuilder agentDetails = new StringBuilder(); //Agent Details String agentAcctNo = ""; if ("Y".equalsIgnoreCase(altAgentKey)) { agentAcctNo = CommonUtils.isNotEmpty(altAgentValue) ? altAgentValue : ""; } else if (lclbl.getAgentAcct() != null) { agentAcctNo = (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[0])) ? agencyInfo[0] : lclbl.getAgentAcct().getAccountno(); } if (CommonUtils.isNotEmpty(agentAcctNo)) { CustAddress custAddress = new CustAddressDAO().findPrimeContact(agentAcctNo); if (CommonFunctions.isNotNull(custAddress)) { if (CommonFunctions.isNotNull(custAddress.getAcctName())) { agentDetails.append(custAddress.getAcctName()).append(" "); } if (CommonFunctions.isNotNull(custAddress.getPhone())) { agentDetails.append("Phone: ").append(custAddress.getPhone()).append("\n"); } else { agentDetails.append("\n"); } if (CommonFunctions.isNotNull(custAddress.getCoName())) { agentDetails.append(custAddress.getCoName()).append("\n"); } if (CommonFunctions.isNotNull(custAddress.getAddress1())) { agentDetails.append(custAddress.getAddress1().replace(", ", "\n")).append("\n"); } if (CommonFunctions.isNotNull(custAddress.getCity1())) { agentDetails.append(custAddress.getCity1()); } if (CommonFunctions.isNotNull(custAddress.getState())) { agentDetails.append(" ").append(custAddress.getState()); } if (CommonFunctions.isNotNull(custAddress.getEmail1())) { emailId = custAddress.getEmail1(); } } } BigDecimal PrintInvoiceValue = null; if (lclbl.getPortOfDestination() != null) { boolean schnum = new LCLPortConfigurationDAO().getSchnumValue(lclbl.getPortOfDestination().getId()); if (schnum) { BigDecimal printInvoice = lclbl.getInvoiceValue(); Long fileId = lclbl.getFileNumberId(); if (!CommonUtils.isEmpty(printInvoice) && !CommonUtils.isEmpty(fileId)) { PrintInvoiceValue = printInvoice; } } } chargeCell = new PdfPCell(); chargeCell.setBorder(2); chargeCell.setColspan(6); chargeCell.setPadding(0f); PdfPTable agent_Contact_Table = new PdfPTable(3); agent_Contact_Table.setWidthPercentage(100f); agent_Contact_Table.setWidths(new float[] { 2.3f, 1.7f, 1.8f }); PdfPCell agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setBorderWidthTop(1f); agent_Contact_cell.setBorderWidthLeft(1f); agent_Contact_cell.setBorderWidthBottom(0.06f); agent_Contact_cell.setBorderWidthRight(1f); p = new Paragraph(7f, "To Pick Up Freight Please Contact: ", blackContentNormalFont); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setColspan(2); agent_Contact_cell.setBorderWidthTop(1f); agent_Contact_cell.setPaddingBottom(2f); p = new Paragraph(7f, "Email: " + emailId.toLowerCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setColspan(2); agent_Contact_cell.setBorder(0); agent_Contact_cell.setBorderWidthLeft(1f); p = new Paragraph(7f, "" + agentDetails.toString(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setPaddingTop(27f); p = new Paragraph(7f, "" + agentAcctNo, totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setColspan(3); agent_Contact_cell.setBorderWidthLeft(1f); StringBuilder builder = new StringBuilder(); builder.append(PrintInvoiceValue != null ? "Value of Goods:USD $" + PrintInvoiceValue : ""); p = new Paragraph(3f, "" + builder.toString(), totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); chargeCell.addElement(agent_Contact_Table); chargeTable.addCell(chargeCell); return chargeTable; }