List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
From source file:Output.QuotePDf.java
private PdfPTable disclaimerTable(Boolean spotrate, String mtdApproval, String spaceApproval, String overseasResponse) throws DocumentException { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100f); table.setSpacingAfter(10f);//from www. j ava2 s .c o m if (spotrate) { cell = new PdfPCell(new Phrase( "This rate requires special FMC filing. If you intend to book at this rate you must notify sales in writing prior to booking.", fmcFont)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } if (mtdApproval.equals("Pending") || spaceApproval.equals("Pending") || overseasResponse.equals("Pending")) { cell = new PdfPCell(new Phrase("Rate is subject to final operational acceptance.", fmcFont)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } cell = new PdfPCell(new Phrase( "Rates quoted are valid for 30 days from date of issue unless otherwise noted.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( new Phrase("Any extra charges for special handling are for the shipper's account and arrangement.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( new Phrase("Static/towable accessories must move with the main unit for the same rate to apply.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase( "Please always include the group email kam-roro-sales@us.kline.com in any correspondence.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase( "Please reference RQS number when booking with customer service (kamricbcarcus@us.kline.com).", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }
From source file:Output.QuotePDf.java
private PdfPTable carrierComments(Boolean includeCarrierComments, String carrierComments) { PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100f); table.setSpacingAfter(10f);// ww w .ja v a 2 s. co m if (includeCarrierComments) { cell = new PdfPCell(new Phrase("Carrier Comments", tableHeadingFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingBottom(10f); cell.setBackgroundColor(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Phrase(carrierComments, textFont)); cell.setPadding(5f); table.addCell(cell); } return table; }
From source file:Output.QuotePDf.java
private PdfPTable packingListTable(JTable packingListTable) throws DocumentException { PdfPTable table = new PdfPTable(11); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(100f); table.setWidths(new int[] { 5, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3 }); table.setSpacingAfter(10f);//ww w . j a va 2 s .co m cell = new PdfPCell(new Phrase("Packing List", tableHeadingFont)); cell.setBackgroundColor(BaseColor.BLACK); cell.setColspan(11); cell.setPaddingBottom(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Commodity", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Qty", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Kgs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("M3", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Lbs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); for (int row = 0; row < packingListTable.getRowCount(); row++) { for (int col = 0; col < 11; col++) { String packingListData = String.valueOf(packingListTable.getValueAt(row, col)); if (packingListData.equals("null")) { packingListData = " "; cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } } } return table; }
From source file:Output.QuotePDf.java
private PdfPTable sailingScheduleTable(JTable sailingScheduleTable, Boolean includeSailngSchedule) throws DocumentException { PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100f); table.setHorizontalAlignment(Element.ALIGN_CENTER); if (includeSailngSchedule) { cell = new PdfPCell(new Phrase("Sailing Schedule", tableHeadingFont)); cell.setPaddingBottom(5);//from w w w. j a v a 2 s . c o m cell.setBackgroundColor(BaseColor.BLACK); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("Vessel/Voyage", rowLabelFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Sail Date", rowLabelFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Transit Time", rowLabelFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Transshipment", rowLabelFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); for (int r = 0; r < sailingScheduleTable.getRowCount(); r++) { for (int c = 0; c < 4; c++) { Object sailingScheduleData = sailingScheduleTable.getValueAt(r, c); if (sailingScheduleData == null) { sailingScheduleData = " "; cell = new PdfPCell(new Phrase(String.valueOf(sailingScheduleData), textFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(String.valueOf(sailingScheduleData), textFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } } } } return table; }
From source file:pdf.PDFDesign.java
public PdfPTable createPriceTable(List<Item> itemList) throws DocumentException, IOException { PdfPTable table = new PdfPTable(nColumns); table.setWidthPercentage(100.0f); //PdfContentByte cb = writer.getDirectContent(); for (int i = 0; i < itemList.size(); i++) { Item item = itemList.get(i);/* w w w .ja v a2s . co m*/ //cell.setBorder(0); //BarcodeEAN code = new BarcodeEAN(); //code.setCode(item.getBarCode()); //code.setGuardBars(false); //Image im = code.createImageWithBarcode(cb, BaseColor.BLACK, BaseColor.BLACK); //p.add(im);//new Chunk(im,0.5f,0.5f)); PdfPTable innerTable = new PdfPTable(1); Paragraph p1 = new Paragraph(); p1.setFont(titleLineFont); String t = item.getTitle(); String[] split = t.split("//"); //System.out.println(t); for (String split1 : split) { p1.add(split1 + "\n"); } PdfPCell innercCell1 = new PdfPCell(p1); innercCell1.setLeading(11f, 0f); innercCell1.setBorder(0); if (t.contains("//") && (size.equals("4x6") || size.equals("4x7") || size.equals("5x6") || size.equals("5x7"))) { innercCell1.setFixedHeight(titleLineFixedHeight); } else { innercCell1.setFixedHeight(15.0f); } //innercCell1.setFixedHeight(titleLineFixedHeight); innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p2 = new Paragraph(); p2.setFont(amountAndPriceLabelLineFont); p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n"); PdfPCell innercCell2 = new PdfPCell(p2); innercCell2.setLeading(5f + textFontInc, 0f); innercCell2.setBorder(0); innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p3 = new Paragraph(); p3.setFont(bigPriceNumberFont); p3.add(item.getPrice().substring(0, item.getPrice().length() - 3)); p3.setFont(decimalPriceNumberFont); p3.add(item.getPrice().substring(item.getPrice().length() - 3, item.getPrice().length())); p3.setFont(unitPriceLineFont); p3.add(item.getCurrency()); PdfPCell innercCell3 = new PdfPCell(p3); if (styleName.equals("style6") /*&& (size.equals("4x7") || size.equals("4x6"))*/) { innercCell3 = new PdfPCell(createLine3Table(item, 45 + priceFontInc, 20, 15)); } innercCell3.setBorder(0); innercCell3.setLeading(bigPriceNumberLeading, 0f); innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p4 = new Paragraph(); p4.setFont(unitPriceLineFont); p4.add("Cena za " + item.getXAmount() + item.getXUnit() + ": " + item.getUnitPrice() + " " + item.getCurrency()); PdfPCell innercCell4 = new PdfPCell(p4); innercCell4.setBorder(0); innercCell4.setLeading(5f + textFontInc, 0f); innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER); innerTable.addCell(innercCell1); innerTable.addCell(innercCell2); innerTable.addCell(innercCell3); innerTable.addCell(innercCell4); PdfPCell cell = new PdfPCell(innerTable); cell.setFixedHeight(cellHeight); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderColor(BaseColor.GRAY); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } int remainder = itemList.size() % nColumns; if (remainder != 0) { remainder = nColumns - remainder; } for (int i = 0; i < remainder; i++) { PdfPCell c = new PdfPCell(new Phrase(" ")); c.setBorderColor(BaseColor.GRAY); table.addCell(c); } return table; }
From source file:pdf.PDFDesign.java
private PdfPTable createStyle6_4x7Table(List<Item> list) throws DocumentException, IOException { PdfPTable table = new PdfPTable(nColumns); table.setWidthPercentage(100.0f); for (int i = 0; i < list.size(); i++) { Item item = list.get(i);/*w w w. j av a 2s. c o m*/ PdfPTable innerTable = new PdfPTable(1); Paragraph p1 = new Paragraph(); p1.setFont(titleLineFont); String t = item.getTitle(); String[] split = t.split("//"); for (String split1 : split) { p1.add(split1 + "\n"); } PdfPCell innercCell1 = new PdfPCell(p1); innercCell1.setBorder(0); if (t.contains("//")) { innercCell1.setFixedHeight(titleLineFixedHeight); } else { innercCell1.setFixedHeight(15.0f + textFontInc); } innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p2 = new Paragraph(); p2.setFont(amountAndPriceLabelLineFont); p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n"); PdfPCell innercCell2 = new PdfPCell(p2); innercCell2.setLeading(5f, 0f); innercCell2.setBorder(0); innercCell2.setFixedHeight(12.0f); innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell innercCell3 = new PdfPCell(createLine3Table(item, 0, 0, 0)); innercCell3.setBorder(0); innercCell3.setLeading(2.0f, 0f); innercCell3.setFixedHeight(67.0f); innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p4 = new Paragraph(); p4.setFont(unitPriceLineFont); p4.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + " " + item.getCurrency()); PdfPCell innercCell4 = new PdfPCell(p4); innercCell4.setBorder(0); innercCell4.setLeading(1f, 0f); innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER); innerTable.addCell(innercCell1); innerTable.addCell(innercCell2); innerTable.addCell(innercCell3); innerTable.addCell(innercCell4); PdfPCell cell = new PdfPCell(innerTable); cell.setFixedHeight(cellHeight); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderColor(BaseColor.GRAY); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } int remainder = list.size() % nColumns; if (remainder != 0) { remainder = nColumns - remainder; } for (int i = 0; i < remainder; i++) { PdfPCell c = new PdfPCell(new Phrase(" ")); c.setBorderColor(BaseColor.GRAY); table.addCell(c); } return table; }
From source file:pdf.PDFDesign.java
private PdfPTable createEuroTable(List<Item> items) throws DocumentException, IOException { int nColumnsEuro = 4; PdfPTable table = new PdfPTable(nColumnsEuro); table.setWidthPercentage(100.0f); for (int i = 0; i < items.size(); i++) { table.addCell(createEuroCell(items.get(i))); }/*from ww w .j a va 2 s . co m*/ int remainder = items.size() % nColumnsEuro; if (remainder != 0) { remainder = nColumnsEuro - remainder; } for (int i = 0; i < remainder; i++) { table.addCell(""); } return table; }
From source file:pdf.PDFDesign.java
private PdfPCell createEuroCell(Item item) throws DocumentException, IOException { Font descFont = new Font(droidsans, 12, Font.NORMAL, color); Font unitPriceFont = new Font(droidsans, 10, Font.NORMAL, color); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100f); PdfPCell cell;/*w ww .ja va2s . c o m*/ Paragraph p; cell = new PdfPCell(); p = new Paragraph(); p.setFont(descFont); p.add(item.getTitle()); cell.setFixedHeight(28f); cell.setPhrase(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); p = new Paragraph(); p.setFont(descFont); p.add(item.getAmount() + item.getUnit()); cell.setFixedHeight(16f); cell.setPhrase(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(0); table.addCell(cell); table.addCell(createEuroInnerPrice(item)); cell = new PdfPCell(); p = new Paragraph(); p.setFont(unitPriceFont); p.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + item.getCurrency() + "/" + item.getSecondUnitPrice() + item.getSecondCurrency()); cell.setPhrase(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(0); cell.setLeading(2f, 0f); table.addCell(cell); PdfPCell finalCell = new PdfPCell(table); finalCell.setFixedHeight(117.4f); finalCell.setBorderColor(BaseColor.GRAY); return finalCell; }
From source file:pdf.PDFDesign.java
private PdfPCell createEuroInnerPrice(Item item) throws DocumentException { PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 1f, 1f }); table.addCell(createEuroInnerInnerPrice(item.getPrice(), item.getCurrency(), true)); table.addCell(createEuroInnerInnerPrice(item.getSecondPrice(), item.getSecondCurrency(), false)); PdfPCell finalCell = new PdfPCell(table); finalCell.setFixedHeight(57f);// ww w .j a v a 2 s.com finalCell.setLeading(20f, 0f); finalCell.setBorder(0); return finalCell; }
From source file:pdf.PDFDesign.java
private PdfPTable createEuro_6_Table(List<Item> list) throws DocumentException { //int nColumns = 4; PdfPTable table = new PdfPTable(nColumns); table.setWidthPercentage(100.0f); for (int i = 0; i < list.size(); i++) { table.addCell(createEuro_6_Cell(list.get(i))); }/* ww w.java 2 s .c o m*/ int remainder = list.size() % nColumns; if (remainder != 0) { remainder = nColumns - remainder; } for (int i = 0; i < remainder; i++) { PdfPCell c = new PdfPCell(new Phrase(" ")); c.setBorderColor(BaseColor.GRAY); table.addCell(c); } return table; }