List of usage examples for com.itextpdf.text.pdf PdfPTable addCell
public void addCell(final Phrase phrase)
From source file:com.mycom.products.mywebsite.backend.util.DownloadHandler.java
License:Open Source License
private void setTableHeader(String value, PdfPTable table) { PdfPCell cell = new PdfPCell(new Paragraph(value)); cell.setBorderColor(BaseColor.GRAY); cell.setFixedHeight(25);// ww w .j a v a 2s .c o m BaseColor myColor = WebColors.getRGBColor("#F7F7F7"); cell.setBackgroundColor(myColor); cell.setPaddingLeft(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); }
From source file:com.mycom.products.mywebsite.backend.util.DownloadHandler.java
License:Open Source License
private void setTableContent(String value, PdfPTable table) { PdfPCell cell = new PdfPCell(new Paragraph(value)); cell.setBorderColor(BaseColor.GRAY); cell.setPaddingLeft(10);/*ww w .ja v a 2s .c om*/ cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); }
From source file:com.mycompany.mavenproject2.VirtualkeyController.java
private static void createTable(/*Section subCatPart*/String tableName, Paragraph preface) throws BadElementException { try {//from w ww. ja va 2 s. c o m ArrayList<String> list = new ArrayList<String>(); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); int length = 0; java.sql.Connection conn = Connection.getConnect(); Statement st = conn.createStatement(); st = conn.createStatement(); ResultSet rs = st.executeQuery("SELECT * FROM " + tableName); ResultSetMetaData rsMetaData = rs.getMetaData(); int numberOfColumns = rsMetaData.getColumnCount(); System.out.println("resultSet MetaData column Count=" + numberOfColumns); for (int i = 1; i <= numberOfColumns; i++) { length = i; } MongoClient client = new MongoClient(); MongoDatabase db = client.getDatabase("FinalDemo"); PdfPTable table = new PdfPTable(length); for (int i = 1; i <= numberOfColumns; i++) { // System.out.println("column MetaData "); //System.out.println("column number " + i); // get the column's name. System.out.println(rsMetaData.getColumnName(i)); PdfPCell c1 = new PdfPCell(new Phrase(rsMetaData.getColumnName(i))); c1.setHorizontalAlignment(Element.ALIGN_CENTER); list.add(rsMetaData.getColumnName(i)); table.addCell(c1); } while (rs.next()) { for (String col : list) { //System.out.println("Column name is "+col+"value is "+rs.getString(col)); table.addCell(rs.getString(col)); } } /*PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);*/ table.setHeaderRows(1); preface.add(table); //subCatPart.add(table); } catch (ClassNotFoundException ex) { Logger.getLogger(VirtualkeyController.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(VirtualkeyController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.nerdcastle.nazmul.filetest.MainActivity.java
private static void createTable(Section subCatPart) throws BadElementException { ArrayList<String> a = new ArrayList<>(); a.add("1");//from ww w. ja v a2s .c om a.add("2"); a.add("3"); ArrayList<String> b = new ArrayList<>(); b.add("4"); b.add("5"); b.add("6"); ArrayList<String> c = new ArrayList<>(); c.add("7"); c.add("8"); c.add("9"); PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < a.size(); i++) { table.addCell(a.get(i)); table.addCell(b.get(i)); table.addCell(c.get(i)); } /* table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3");*/ subCatPart.add(table); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createHead(PdfPTable table, VisionVO vision) throws Exception { PdfPCell cell = new PdfPCell(); cell.addElement(new Phrase(vision.getTitle() + "\n" + BscReportSupportUtils.parse2(vision.getScore()), this.getFont(vision.getFontColor(), true))); this.setCellBackgroundColor(cell, vision.getBgColor()); cell.setColspan(MAX_COLSPAN);// w w w . j av a 2s . co m table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getPerspectiveTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getObjectiveTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createBody(PdfPTable table, VisionVO vision) throws Exception { Map<String, String> managementMap = BscKpiCode.getManagementMap(false); //Map<String, String> calculationMap = BscKpiCode.getCalculationMap(false); PdfPCell cell = null;/*from w w w . j a va2s .c o m*/ for (PerspectiveVO perspective : vision.getPerspectives()) { Image pImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("PERSPECTIVES", perspective.getTarget(), perspective.getMin(), perspective.getScore(), "", "", 0)); pImage.setWidthPercentage(10f); String content = this.getItemsContent(perspective.getName(), perspective.getScore(), perspective.getWeight(), perspective.getTarget(), perspective.getMin()); cell = new PdfPCell(); cell.addElement(pImage); cell.addElement(new Phrase("\n" + content, this.getFont(perspective.getFontColor(), false))); this.setCellBackgroundColor(cell, perspective.getBgColor()); cell.setRowspan(perspective.getRow()); table.addCell(cell); for (ObjectiveVO objective : perspective.getObjectives()) { Image oImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("OBJECTIVES", objective.getTarget(), objective.getMin(), objective.getScore(), "", "", 0)); oImage.setWidthPercentage(10f); content = this.getItemsContent(objective.getName(), objective.getScore(), objective.getWeight(), objective.getTarget(), objective.getMin()); cell = new PdfPCell(); cell.addElement(oImage); cell.addElement(new Phrase("\n" + content, this.getFont(objective.getFontColor(), false))); this.setCellBackgroundColor(cell, objective.getBgColor()); cell.setRowspan(objective.getRow()); table.addCell(cell); for (KpiVO kpi : objective.getKpis()) { /* content = this.getKpisContent( kpi, managementMap, calculationMap); */ Image kImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("KPI", kpi.getTarget(), kpi.getMin(), kpi.getScore(), kpi.getCompareType(), kpi.getManagement(), kpi.getQuasiRange())); kImage.setWidthPercentage(10f); content = this.getKpisContent(kpi, managementMap); cell = new PdfPCell(); cell.addElement(kImage); cell.addElement(new Phrase("\n" + content, this.getFont(kpi.getFontColor(), false))); this.setCellBackgroundColor(cell, kpi.getBgColor()); table.addCell(cell); } } } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createDateRange(PdfPTable table, VisionVO vision, Context context, int maxRows) throws Exception { String frequency = (String) context.get("frequency"); String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim(); String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim(); String startDate = StringUtils.defaultString((String) context.get("startDate")).trim(); String endDate = StringUtils.defaultString((String) context.get("endDate")).trim(); String date1 = startDate;//from w ww . j a v a2 s. c om String date2 = endDate; if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) { date1 = startYearDate + "/01/01"; date2 = endYearDate + "/12/" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12); } Map<String, Object> headContentMap = new HashMap<String, Object>(); this.fillHeadContent(context, headContentMap); String content = "Frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " Date range: " + date1 + " ~ " + date2 + "\n" + StringUtils.defaultString((String) headContentMap.get("headContent")); PdfPCell cell = null; cell = new PdfPCell(); cell.addElement(new Phrase(content, this.getFont(BscReportPropertyUtils.getFontColor(), false))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); cell.setColspan(maxRows); table.addCell(cell); for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { for (KpiVO kpi : objective.getKpis()) { cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getName(), this.getFont(kpi.getFontColor(), false))); this.setCellBackgroundColor(cell, kpi.getBgColor()); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) { cell = new PdfPCell(); cell.addElement( new Phrase(dateScore.getDate(), this.getFont(dateScore.getFontColor(), false))); this.setCellBackgroundColor(cell, dateScore.getBgColor()); table.addCell(cell); } for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) { Image image = Image .getInstance(BscReportSupportUtils.getByteIcon(kpi, dateScore.getScore())); image.setWidthPercentage(20f); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateScore.getScore()), this.getFont(dateScore.getFontColor(), false))); cell.addElement(image); this.setCellBackgroundColor(cell, dateScore.getBgColor()); table.addCell(cell); } } } } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void putCharts(PdfPTable table, Context context) throws Exception { String pieBase64Content = SimpleUtils.getPNGBase64Content((String) context.get("pieCanvasToData")); String barBase64Content = SimpleUtils.getPNGBase64Content((String) context.get("barCanvasToData")); BufferedImage pieImage = SimpleUtils.decodeToImage(pieBase64Content); BufferedImage barImage = SimpleUtils.decodeToImage(barBase64Content); ByteArrayOutputStream pieBos = new ByteArrayOutputStream(); ImageIO.write(pieImage, "png", pieBos); pieBos.flush();// w w w . j a va2 s. c o m ByteArrayOutputStream barBos = new ByteArrayOutputStream(); ImageIO.write(barImage, "png", barBos); barBos.flush(); PdfPCell cell = null; Image pieImgObj = Image.getInstance(pieBos.toByteArray()); pieImgObj.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(pieImgObj); table.addCell(cell); Image barImgObj = Image.getInstance(barBos.toByteArray()); barImgObj.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(barImgObj); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void putSignature(PdfPTable table, Context context) throws Exception { String uploadOid = (String) context.get("uploadSignatureOid"); if (StringUtils.isBlank(uploadOid)) { return;// w w w .j av a 2 s . c o m } byte[] imageBytes = UploadSupportUtils.getDataBytes(uploadOid); if (null == imageBytes) { return; } Image signatureImgObj = Image.getInstance(imageBytes); signatureImgObj.setWidthPercentage(40f); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(signatureImgObj); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private void createHead(PdfPTable table, VisionVO vision, Context context) throws Exception { String bgColor = "#F2F2F2"; String fnColor = "#000000"; PdfPCell cell = new PdfPCell(); cell.addElement(new Phrase("Department Balance SourceCard", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(MAX_COLSPAN);// w ww . ja v a 2 s .c om table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(vision.getTitle(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(MAX_COLSPAN); table.addCell(cell); String dateType = (String) context.get("dateType"); String year = (String) context.get("startYearDate"); String orgId = (String) context.get("orgId"); String departmentName = ""; String dateTypeName = "Year"; if ("1".equals(dateType)) { dateTypeName = "In the first half"; } if ("2".equals(dateType)) { dateTypeName = "In the second half"; } OrganizationVO organization = new OrganizationVO(); organization.setOrgId(orgId); DefaultResult<OrganizationVO> result = this.organizationService.findByUK(organization); if (result.getValue() != null) { organization = result.getValue(); departmentName = organization.getName(); } cell = new PdfPCell(); cell.addElement(new Phrase("Department", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(departmentName, this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(year + " " + dateTypeName, this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getPerspectiveTitle(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getObjectiveTitle(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Weight", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Maximum\nTarget\nMinimum", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Score", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); }