List of usage examples for com.itextpdf.text.pdf PdfPTable addCell
public void addCell(final Phrase phrase)
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private void createBody(PdfPTable table, VisionVO vision) throws Exception { String bgColor = "#ffffff"; String fnColor = "#000000"; PdfPCell cell = null;/* w w w .ja v a 2 s . c o m*/ for (PerspectiveVO perspective : vision.getPerspectives()) { cell = new PdfPCell(); cell.addElement(new Phrase(perspective.getName(), this.getFont(fnColor, false))); this.setCellBackgroundColor(cell, bgColor); cell.setRowspan(perspective.getRow()); table.addCell(cell); for (ObjectiveVO objective : perspective.getObjectives()) { cell = new PdfPCell(); cell.addElement(new Phrase(objective.getName(), this.getFont(fnColor, false))); this.setCellBackgroundColor(cell, bgColor); cell.setRowspan(objective.getRow()); table.addCell(cell); for (KpiVO kpi : objective.getKpis()) { cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getName(), this.getFont(fnColor, false))); this.setCellBackgroundColor(cell, bgColor); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getWeight() + "%", this.getFont(fnColor, false))); this.setCellBackgroundColor(cell, bgColor); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase( "max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n" + "min: " + kpi.getMin() + "\n" + "unit: " + kpi.getUnit(), this.getFont(fnColor, false))); this.setCellBackgroundColor(cell, bgColor); cell.setRowspan(1); table.addCell(cell); DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateRangeScore.getScore()), this.getFont(dateRangeScore.getFontColor(), false))); this.setCellBackgroundColor(cell, dateRangeScore.getBgColor()); cell.setRowspan(1); table.addCell(cell); } } } }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.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("Personal Balance SourceCard", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(MAX_COLSPAN);//ww w. j a v a 2 s. c o m 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 empId = (String) context.get("empId"); String account = (String) context.get("account"); String fullName = ""; String jobTitle = ""; String departmentName = ""; String dateTypeName = "Year"; if ("1".equals(dateType)) { dateTypeName = "In the first half"; } if ("2".equals(dateType)) { dateTypeName = "In the second half"; } EmployeeVO employee = new EmployeeVO(); employee.setEmpId(empId); employee.setAccount(account); DefaultResult<EmployeeVO> result = this.employeeService.findByUK(employee); if (result.getValue() != null) { fullName = result.getValue().getEmpId() + " - " + result.getValue().getFullName(); jobTitle = result.getValue().getEmpId() + " - " + result.getValue().getFullName(); List<String> appendIds = this.organizationService .findForAppendOrganizationOids(result.getValue().getEmpId()); List<String> appendNames = this.organizationService.findForAppendNames(appendIds); StringBuilder sb = new StringBuilder(); for (int i = 0; appendNames != null && i < appendNames.size(); i++) { sb.append(appendNames.get(i)).append(Constants.ID_DELIMITER); } departmentName = sb.toString(); } cell = new PdfPCell(); cell.addElement(new Phrase("Job Title", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(jobTitle, this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); 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(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("name: " + fullName, this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Annual assessment: " + year, 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); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Maximum\nTarget\nMinimum", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Weight", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Formula", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Score", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(dateTypeName, this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java
License:Apache License
private void createBody(PdfPTable table, VisionVO vision) throws Exception { String bgColor = "#ffffff"; String fnColor = "#000000"; for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { int kx = 0; for (KpiVO kpi : objective.getKpis()) { PdfPCell cell = new PdfPCell(); if (kx == 0) { cell.addElement(new Phrase(objective.getName(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1);/*w w w.j a va2 s . co m*/ cell.setRowspan(objective.getRow()); table.addCell(cell); } cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getName(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement( new Phrase( "max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n" + "min: " + kpi.getMin() + "\n" + "unit: " + kpi.getUnit(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getWeight() + "%", this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getFormula().getName(), this.getFont(fnColor, true))); this.setCellBackgroundColor(cell, bgColor); cell.setColspan(1); table.addCell(cell); DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0); // ? cell = new PdfPCell(); cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateRangeScore.getScore()), this.getFont(dateRangeScore.getFontColor(), true))); this.setCellBackgroundColor(cell, dateRangeScore.getBgColor()); cell.setColspan(1); table.addCell(cell); kx++; } } } }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java
License:Apache License
private void createFoot(PdfPTable table, Context context) throws Exception { String bgColor = "#ffffff"; String fnColor = "#000000"; PdfPCell cell = new PdfPCell(); cell.addElement(new Phrase("assess:", this.getFont(fnColor, true))); cell.setColspan(1);/*from w w w . j a va 2s.c om*/ cell.setRowspan(2); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); cell = new PdfPCell(); cell.addElement( new Phrase(BscReportPropertyUtils.getPersonalReportClassLevel(), this.getFont(fnColor, true))); cell.setColspan(3); cell.setRowspan(2); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Total", this.getFont(fnColor, true))); cell.setColspan(1); cell.setRowspan(1); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); float total = 0.0f; if (context.get("total") != null && context.get("total") instanceof Float) { total = (Float) context.get("total"); } cell = new PdfPCell(); cell.addElement(new Phrase(BscReportSupportUtils.parse2(total), this.getFont(fnColor, true))); cell.setColspan(1); cell.setRowspan(1); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase("Class", this.getFont(fnColor, true))); cell.setColspan(1); cell.setRowspan(1); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(" ", this.getFont(fnColor, true))); cell.setColspan(1); cell.setRowspan(1); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); this.setCellBackgroundColor(cell, bgColor); table.addCell(cell); }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
private PdfPTable table(Form form) { int cellPadding = 5; PdfPTable table = new PdfPTable(8); table.setSpacingBefore(20);/*from w w w .ja v a 2 s. c o m*/ try { table.setWidths(new int[] { 100, 120, 30, 60, 60, 50, 50, 50 }); } catch (DocumentException e) { Log.e(TAG, "Width error:" + e.getMessage()); } PdfPCell cell = new PdfPCell(new Paragraph("Adres: " + form.getAddress(), normal)); cell.setColspan(8); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("Odbiorca: " + form.getOwner(), normal)); cell.setColspan(8); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("Data: " + form.getDate(), normal)); cell.setColspan(3); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.BOTTOM); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("tel: " + form.getPhone(), normal)); cell.setColspan(5); cell.setPadding(cellPadding); cell.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); //Header Paragraph p = new Paragraph("WODOMIERZ", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setNoWrap(true); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Nr fabryczny", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("DN", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Typ\r\nProducent", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Stan w (m3)", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Rok\r\nlegalizacji", bold); cell = new PdfPCell(p); ; cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Czy plomba\r\nlegalizacyjna jest\r\nuszkodzona?", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //First row cell = new PdfPCell(new Paragraph("Zamontowany", bold)); cell.setNoWrap(true); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getNewSN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewDN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewType() + "\r\n" + form.getNewManufacturer(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewState(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewYear(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getNewSeal().equals("Tak")) p = new Paragraph("tak", normal); else p = new Paragraph("tak", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getNewSeal().equals("Nie")) p = new Paragraph("nie", normal); else p = new Paragraph("nie", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //Second row cell = new PdfPCell(new Paragraph("Wymontowany", bold)); cell.setNoWrap(true); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getOldSN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldDN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldType() + "\r\n" + form.getOldManufacturer(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldState(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldYear(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getOldSeal().equals("Tak")) p = new Paragraph("tak", normal); else p = new Paragraph("tak", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getOldSeal().equals("Nie")) p = new Paragraph("nie", normal); else p = new Paragraph("nie", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //Third row cell = new PdfPCell(new Paragraph("Plomba nr 1", bold)); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getSealFirst(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Paragraph("Przyczyna wymiany: " + form.getReason(), normal)); cell.setPadding(cellPadding); cell.setColspan(5); table.addCell(cell); //Fourth row cell = new PdfPCell(new Paragraph("Plomba nr 2", bold)); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getSealSecond(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Paragraph("Umiejscowienie wodomierza: " + form.getPlacement(), normal)); cell.setPadding(cellPadding); cell.setColspan(5); table.addCell(cell); //Fourth row cell = new PdfPCell(new Paragraph("Nr moduu\r\nradiowego", bold)); cell.setPadding(cellPadding); table.addCell(cell); cell = new PdfPCell(new Paragraph(form.getNewModuleNumber(), normal)); cell.setPadding(cellPadding); cell.setColspan(7); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); table.setWidthPercentage(100); return table; }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
private PdfPTable signTable(Form form, Image sgn, ArrayList<String> workers) { int cellPadding = 5; PdfPTable table = new PdfPTable(2); table.setSpacingBefore(15);/*from w ww . j a va 2 s. c o m*/ PdfPCell cell = new PdfPCell(new Paragraph("Data i podpis klienta: ", normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Paragraph("Wykonali pracownicy: ", normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(sgn); cell.setRowspan(workers.size()); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); for (int i = 0; i < workers.size(); i++) { cell = new PdfPCell(new Paragraph(workers.get(i), normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); } table.setWidthPercentage(90); return table; }
From source file:com.northcoders.controller.BookingReportsController.java
@FXML private void generatePdf() throws Exception { BaseFont bf;//from ww w . jav a2s.c o m Font font; try { conditions = "Filtered by: Start Date:2017-03-15 End Date:2017-03-28"; /* Step-2: Initialize PDF documents - logical objects */ Document my_pdf_report = new Document(PageSize.LETTER.rotate()); PdfWriter.getInstance(my_pdf_report, new FileOutputStream("pdf_booking_report.pdf")); my_pdf_report.open(); //we have four columns in our table PdfPTable my_report_table = new PdfPTable(6); //create a cell object PdfPCell table_cell; bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); font = new Font(bf, 16); my_pdf_report.add(new Paragraph("Administration Report", font)); font = new Font(bf, 12); my_pdf_report.add(new Paragraph("Filter applied:" + conditions, font)); my_pdf_report.add(new Paragraph(" ")); table_cell = new PdfPCell(new Phrase("Customer")); my_report_table.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Start Date")); my_report_table.addCell(table_cell); table_cell = new PdfPCell(new Phrase("End Date")); my_report_table.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Room")); my_report_table.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Amount")); my_report_table.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Transactions")); my_report_table.addCell(table_cell); for (Booking item : bookings) { String customer_b = item.getCustomerId().getId() + " " + item.getCustomerId().getFirstName() + " " + item.getCustomerId().getLastName(); table_cell = new PdfPCell(new Phrase(customer_b)); my_report_table.addCell(table_cell); String date_start_b = dateToStr(item.getStartDate()); table_cell = new PdfPCell(new Phrase(date_start_b)); my_report_table.addCell(table_cell); String date_end_b = dateToStr(item.getEndDate()); table_cell = new PdfPCell(new Phrase(date_end_b)); my_report_table.addCell(table_cell); String room_b = String.valueOf(item.getRoomId().getRoomNumber()); table_cell = new PdfPCell(new Phrase(room_b)); my_report_table.addCell(table_cell); String price_b = String.format("%1$,.2f", item.getTotalPrice()); table_cell = new PdfPCell(new Phrase(price_b)); my_report_table.addCell(table_cell); String transaction_b = ""; for (PaymentTransaction trans : item.getPaymentTransactionList()) { transaction_b += String.format("%1$,.2f", trans.getAmount()) + " " + trans.getPaymentTypeId().getDescription() + "\n"; } table_cell = new PdfPCell(new Phrase(transaction_b)); my_report_table.addCell(table_cell); } /* Attach report table to PDF */ my_pdf_report.add(my_report_table); my_pdf_report.add(new Paragraph(" ")); font = new Font(bf, 6); my_pdf_report.add(new Paragraph("Report Time:" + dateTimeToStr(new Date()))); my_pdf_report.close(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.pdf.GetPdf.java
public static void addXls(Document document, String url, String type) throws IOException, DocumentException { Iterator<Row> rowIterator; int colNo;/*from www. j a va 2 s . c om*/ if (type.equals("xls")) { HSSFWorkbook excelWorkbook = new HSSFWorkbook(new URL(url).openStream()); HSSFSheet my_worksheet = excelWorkbook.getSheetAt(0); rowIterator = my_worksheet.iterator(); colNo = my_worksheet.getRow(0).getLastCellNum(); } else { XSSFWorkbook excelWorkbook1 = new XSSFWorkbook(new URL(url).openStream()); XSSFSheet my_worksheet = excelWorkbook1.getSheetAt(0); rowIterator = my_worksheet.iterator(); colNo = my_worksheet.getRow(0).getLastCellNum(); } PdfPTable my_table = new PdfPTable(colNo); PdfPCell table_cell = null; while (rowIterator.hasNext()) { Row row = rowIterator.next(); //Read Rows from Excel document Iterator<Cell> cellIterator = row.cellIterator();//Read every column for every row that is READ while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); //Fetch CELL if (cell.getCellType() == (Cell.CELL_TYPE_NUMERIC)) { table_cell = new PdfPCell(new Phrase(new Double(cell.getNumericCellValue()).toString())); System.out.println(cell.getNumericCellValue()); my_table.addCell(table_cell); } else if (cell.getCellType() == (Cell.CELL_TYPE_STRING)) { table_cell = new PdfPCell(new Phrase(cell.getStringCellValue())); System.out.println(cell.getStringCellValue()); my_table.addCell(table_cell); } else if (cell.getCellType() == (Cell.CELL_TYPE_FORMULA)) { table_cell = new PdfPCell(new Phrase(cell.getCellFormula())); my_table.addCell(table_cell); } else if (cell.getCellType() == (Cell.CELL_TYPE_BLANK)) { table_cell = new PdfPCell(new Phrase("")); my_table.addCell(table_cell); } else { table_cell = new PdfPCell(new Phrase("")); my_table.addCell(table_cell); } } } document.add(my_table); }
From source file:com.pdfs.GeneradorVisitas.java
public void addCreditosExpress(DatosVisitaDomiciliaria credito) throws DocumentException { documento.add(foto);// w w w . ja v a 2 s . co m Paragraph p = new Paragraph("BUFETE DEL RIO, S.C.", tituloN1); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("La Firma Marca la Diferencia ", tituloN2); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Balboa 1111, Portales Sur, 03300, Mxico, D.F.", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("(55) 5539 0104 con 10 Lneas contacto@corporativodelrio.com", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); PdfPTable datos = new PdfPTable(2); datos.setWidthPercentage(90); Phrase pnombre = new Phrase(credito.getNombre()); pnombre.setFont(cuerpo2); Phrase pcalle = new Phrase(credito.getCalle()); pcalle.setFont(cuerpo2); Phrase pnumcredito = new Phrase(credito.getNumcredito()); pnumcredito.setFont(cuerpo2); Phrase pcolonia = new Phrase(credito.getColonia()); pcolonia.setFont(cuerpo2); Phrase pdelegacion = new Phrase(credito.getDelegacion()); pdelegacion.setFont(cuerpo2); float sdo = credito.getSaldo(); Phrase psaldo = new Paragraph(nf.format(sdo)); psaldo.setFont(cuerpo2); Phrase pestadpCp = new Phrase(credito.getEstado() + " " + credito.getCp()); pestadpCp.setFont(cuerpo2); PdfPCell nombre = new PdfPCell(pnombre); PdfPCell titulocred = new PdfPCell(new Phrase("N Crdito")); PdfPCell calle = new PdfPCell(pcalle); PdfPCell numcredito = new PdfPCell(pnumcredito); PdfPCell colonia = new PdfPCell(pcolonia); PdfPCell titulosaldo = new PdfPCell(new Phrase("Saldo Vencido")); PdfPCell deleg = new PdfPCell(pdelegacion); PdfPCell saldo = new PdfPCell(psaldo); PdfPCell ciudadCP = new PdfPCell(pestadpCp); PdfPCell blanco = new PdfPCell(new Phrase(" ")); nombre.setBorder(Rectangle.NO_BORDER); titulocred.setBorder(Rectangle.NO_BORDER); titulocred.setHorizontalAlignment(Chunk.ALIGN_RIGHT); calle.setBorder(Rectangle.NO_BORDER); numcredito.setBorder(Rectangle.NO_BORDER); numcredito.setHorizontalAlignment(Chunk.ALIGN_RIGHT); colonia.setBorder(Rectangle.NO_BORDER); titulosaldo.setBorder(Rectangle.NO_BORDER); titulosaldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); deleg.setBorder(Rectangle.NO_BORDER); saldo.setBorder(Rectangle.NO_BORDER); saldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); ciudadCP.setBorder(Rectangle.NO_BORDER); blanco.setBorder(Rectangle.NO_BORDER); datos.addCell(nombre); datos.addCell(titulocred); datos.addCell(calle); datos.addCell(numcredito); datos.addCell(colonia); datos.addCell(titulosaldo); datos.addCell(deleg); datos.addCell(saldo); datos.addCell(ciudadCP); datos.addCell(blanco); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(datos); p = new Paragraph("Credito CT Express", tituloN2); p.setAlignment(Chunk.ALIGN_RIGHT); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Srvase la presente, como requerimiento de pago a favor de Inbursa para regularizar su situacin de adeudo que actualmente presenta en la Linea de Crdito CT Express otorgada por Inbursa.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Recuerde que este Crdito se otorg con base en su excelente historial de pago y manejo de su cuenta CT y ahora lo exhortamos a que regularize esta situacin a la brevedad, evitando as, situaciones inconvenientes y daando su buena imagen crediticia.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); p = new Paragraph( "Representamos a Inbursa para que recuperemos los pagos atrasados de la Lnea de Crdito que se otorg.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Invariablemente el pago de lo atrasado, deber hacerse nicamente en la Sucursal de Banco Inbursa de su eleccin, a las siguientes Cuentas:", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("CUENTA CONCENTRADORA 50015025905 a nombre de Banco Inbursa Cobranza Express PYME \n" + "o mediante SPEI a la Cuenta 036180-50015025905-6\n" + "o bien en Bancomer:\n" + "Convenio CIE 386120 Referencia 50015025902", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Y no olvide remitirnos el pago de su crdito va correo electrnico.", cuerpoNegritas); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Contamos con sus Pagos y con su Comunicacin donde un asesor de este Corporativo le atender. EN CASO DE QUE REQUIERA PLAZO PARA PAGAR, CONTACTENOS.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("A T E N T A M E N T E", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("BUFETE DEL RIO, S.C.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "BUFETE DEL RIO, S.C. una Divisin de CORPORATIVO DEL RIO Y ASOCIADOS S.C.\n" + "AVISO DE PRIVACIDAD. Puede ser consultado en la pgina Web www.corporativodelrio.com", cuerpoMini); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); }
From source file:com.pdfs.GeneradorVisitas.java
public void addCreditosTelmex(DatosVisitaDomiciliaria credito) throws DocumentException { documento.add(foto);//from ww w. j a va 2 s .c om Paragraph p = new Paragraph("BUFETE DEL RIO, S.C.", tituloN1); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("La Firma Marca la Diferencia ", tituloN2); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Balboa 1111, Portales Sur, 03300, Mxico, D.F.", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("(55) 5539 0104 con 10 Lneas contacto@corporativodelrio.com", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); PdfPTable datos = new PdfPTable(2); datos.setWidthPercentage(90); Phrase pnombre = new Phrase(credito.getNombre()); pnombre.setFont(cuerpo2); Phrase pcalle = new Phrase(credito.getCalle()); pcalle.setFont(cuerpo2); Phrase pnumcredito = new Phrase(credito.getNumcredito()); pnumcredito.setFont(cuerpo2); Phrase pcolonia = new Phrase(credito.getColonia()); pcolonia.setFont(cuerpo2); Phrase pdelegacion = new Phrase(credito.getDelegacion()); pdelegacion.setFont(cuerpo2); float sdo = credito.getSaldo(); Phrase psaldo = new Paragraph(nf.format(sdo)); psaldo.setFont(cuerpo2); Phrase pestadpCp = new Phrase(credito.getEstado() + " " + credito.getCp()); pestadpCp.setFont(cuerpo2); PdfPCell nombre = new PdfPCell(pnombre); PdfPCell titulocred = new PdfPCell(new Phrase("N Crdito")); PdfPCell calle = new PdfPCell(pcalle); PdfPCell numcredito = new PdfPCell(pnumcredito); PdfPCell colonia = new PdfPCell(pcolonia); PdfPCell titulosaldo = new PdfPCell(new Phrase("Saldo Vencido")); PdfPCell deleg = new PdfPCell(pdelegacion); PdfPCell saldo = new PdfPCell(psaldo); PdfPCell ciudadCP = new PdfPCell(pestadpCp); PdfPCell blanco = new PdfPCell(new Phrase(" ")); nombre.setBorder(Rectangle.NO_BORDER); titulocred.setBorder(Rectangle.NO_BORDER); titulocred.setHorizontalAlignment(Chunk.ALIGN_RIGHT); calle.setBorder(Rectangle.NO_BORDER); numcredito.setBorder(Rectangle.NO_BORDER); numcredito.setHorizontalAlignment(Chunk.ALIGN_RIGHT); colonia.setBorder(Rectangle.NO_BORDER); titulosaldo.setBorder(Rectangle.NO_BORDER); titulosaldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); deleg.setBorder(Rectangle.NO_BORDER); saldo.setBorder(Rectangle.NO_BORDER); saldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); ciudadCP.setBorder(Rectangle.NO_BORDER); blanco.setBorder(Rectangle.NO_BORDER); datos.addCell(nombre); datos.addCell(titulocred); datos.addCell(calle); datos.addCell(numcredito); datos.addCell(colonia); datos.addCell(titulosaldo); datos.addCell(deleg); datos.addCell(saldo); datos.addCell(ciudadCP); datos.addCell(blanco); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(datos); p = new Paragraph("Crdito TELMEX", tituloN2); p.setAlignment(Chunk.ALIGN_RIGHT); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Srvase la presente, como requerimiento de pago a favor de Inbursa para regularizar su situacin de adeudo que actualmente presenta en la Linea de Crdito Telmex otorgada por Inbursa.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Recuerde que este Crdito se otorg con base en su excelente historial de pago puntual de su Lnea Telmex y ahora lo exhortamos a que regularize esta situacin a la brevedad, evitando situaciones inconvenientes y daando su buena imagen crediticia.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); p = new Paragraph( "Representamos a Inbursa para que recuperemos los pagos atrasados de la Lnea de Crdito que se otorg.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Invariablemente el pago de lo atrasado, deber hacerse nicamente en la Sucursal de Banco Inbursa de su eleccin, a las siguientes Cuentas:", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("CUENTA CONCENTRADORA 50015025745 a nombre de Banco Inbursa Cobranza Telmex\n" + "o mediante SPEI a la Cuenta 036180-50015025745-6\n" + "o bien en Bancomer:\n" + "Convenio CIE 386120 Referencia 50015025741", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Y no olvide remitirnos el pago de su crdito va correo electrnico.", cuerpoNegritas); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Contamos con sus Pagos y con su Comunicacin donde un asesor de este Corporativo le atender. EN CASO DE QUE REQUIERA PLAZO PARA PAGAR, CONTACTENOS.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("A T E N T A M E N T E", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("BUFETE DEL RIO, S.C.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "BUFETE DEL RIO, S.C. una Divisin de CORPORATIVO DEL RIO Y ASOCIADOS S.C.\n" + "AVISO DE PRIVACIDAD. Puede ser consultado en la pgina Web www.corporativodelrio.com", cuerpoMini); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); }