List of usage examples for com.itextpdf.text.pdf PdfPTable PdfPTable
public PdfPTable(final PdfPTable table)
PdfPTable
. 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;/* w w w. j a v a 2s.c o m*/ 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);/*from w w w. ja va 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);/*w w w .ja v a 2 s . c o 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("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); }
From source file:com.pdfs.GeneradorVisitas.java
public void addCreditosTelmexSOFOM(DatosVisitaDomiciliaria credito) throws DocumentException { documento.add(foto);/*from w w w. java 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("Crdito TELMEX (Sofom)", 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 50010911552 a nombre de Sociedad Financiera Inbursa S.A. de C.V.\n" + "o mediante SPEI a la Cuenta 036180-50010911552-3\n" + "o bien en Bancomer:\n" + "Convenio CIE 386120 Referencia 50010911556", 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.pdfwriter.PrintInventoryReport.java
public void create(ObservableList list, String totalSales) { try {// ww w . j a v a 2 s . c o m Document document = new Document(PageSize.LETTER); document.setMargins(1, 1, 1, 1); PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); Font font2 = new Font(Font.FontFamily.UNDEFINED, 10, Font.BOLD); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(95); table.setWidths(new int[] { 40, 40, 40, 40, 40 }); PdfPCell cell; cell = new PdfPCell(new Phrase("", font2)); cell.setBorder(0); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(0); cell.setBorderWidthBottom(0); table.addCell(cell); cell = new PdfPCell( new Phrase("KELNOVI SHOPPING BOTIQUE", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell( new Phrase("Pondol,Loon, Bohol", new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell( new Phrase("Phone/Fax#:000-000-000", new Font(Font.FontFamily.UNDEFINED, 9, Font.UNDERLINE))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("SALES REPORT", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("NO.")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("PRODUCT NAME")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("PRICE")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("QUANTITY")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("AMOUNT PAYABLE")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); for (int i = 0; i < list.size(); i++) { it = (ProductClass) list.get(i); cell = new PdfPCell(new Phrase("" + it.idProperty().get())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); table.addCell(cell); cell = new PdfPCell(new Phrase("" + it.productDescriptionProperty().get())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); table.addCell(cell); cell = new PdfPCell(new Phrase("" + it.productPriceProperty().get())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); table.addCell(cell); cell = new PdfPCell(new Phrase("" + it.productQtyProperty().get())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); table.addCell(cell); //totalSales.setText(String.format("%,.2f",globalSales)); cell = new PdfPCell(new Phrase( String.format("%,.2f", Double.parseDouble(it.productTotalSalesProperty().get())))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(14); table.addCell(cell); } cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("TOTAL AMOUNT PAYABLE:")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell( new Phrase("Php " + totalSales, new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("Approved by:")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("MICHAEL NOVI MALUENDA II", new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE))); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("General Manager")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); document.add(table); document.close(); openFile(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.pdg.ticket.utils.FirstPdf.java
private static void createTable(Section subCatPart) throws BadElementException { 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); c1.setBackgroundColor(BaseColor.RED); table.addCell(c1);//ww w . j a va2 s.c o m 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); 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.pearson.controller.PdfGentrate.java
public static void main(String[] args) { try {//from w w w . j av a2s. c om /*Document document = new Document(PageSize. A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance (document, new FileOutputStream("C:\\my.pdf")); document.open(); // create a chunk object using chunk class of itext library. Chunk underlined = new Chunk("Welcome to Pearson Q-Service Portal : "); // set the distance between text and line. underlined.setTextRise(8.0f); // set the width of the line, 'y' position, color and design of the line underlined.setUnderline(new Color(0x00, 0x00, 0xFF),0.0f, 0.2f, 3.0f, 0.0f, PdfContentByte.LINE_CAP_PROJECTING_SQUARE); // finally add object to the document. document.add(underlined); document.add(new Paragraph("Hi username", FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 150, 200))));; document.add(new Paragraph("Tiltle",catFont)); document.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); document.add(new Paragraph("This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).", redFont)); PdfPTable table = new PdfPTable(3); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = {1f, 1f, 1f}; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell(new Paragraph("Cell 1")); cell1.setBorderColor(BaseColor.BLUE); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph("Cell 2")); cell2.setBorderColor(BaseColor.GREEN); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph("Cell 3")); cell3.setBorderColor(BaseColor.RED); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); //To avoid having the cell border and the content overlap, if you are having thick cell borders //cell1.setUserBorderPadding(true); //cell2.setUserBorderPadding(true); //cell3.setUserBorderPadding(true); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); document.add(table); document.close(); writer.close(); document.close(); } catch (Exception e2) { System.out.println(e2.getMessage()); } }*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddTableExample.pdf")); document.open(); PdfPTable table = new PdfPTable(3); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = { 1f, 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell(new Paragraph("Cell 1")); cell1.setBorderColor(BaseColor.BLUE); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph("Cell 2")); cell2.setBorderColor(BaseColor.GREEN); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph("Cell 3")); cell3.setBorderColor(BaseColor.RED); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); //To avoid having the cell border and the content overlap, if you are having thick cell borders //cell1.setUserBorderPadding(true); //cell2.setUserBorderPadding(true); //cell3.setUserBorderPadding(true); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); document.add(table); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.photoshop.misc.Factuurgenerator.java
private void createTable(Paragraph preface) throws BadElementException, DocumentException { // create header cell PdfPTable table = new PdfPTable(5); // set the width of the table to 100% of page table.setWidthPercentage(100);//from ww w . j av a 2s . c om table.setWidths(new float[] { 0.6f, 0.4f, 1.4f, 0.8f, 0.8f }); table.setHeaderRows(1); creatCell(this.Getspringmessage("amount"), table, true); creatCell(this.Getspringmessage("photonumber"), table, true); creatCell(this.Getspringmessage("description"), table, true); creatCell(this.Getspringmessage("productprice"), table, true); creatCell(this.Getspringmessage("total"), table, true); for (OrderRow row : order.getOrderRows()) { creatCell(row.getAantal() + "", table, false); creatCell(row.getPhoto_id() + "", table, false); creatCell(row.getProduct().getName(), table, false); creatCell(" " + row.getProductprice(), table, false); double totaalprijsproduct = row.getProductprice() * row.getAantal(); creatCell(" " + String.format("%.2f", totaalprijsproduct), table, false); totaalprijs = totaalprijs + totaalprijsproduct; } preface.add(table); }
From source file:com.photoshop.misc.Indexkaartgenerator.java
private void createTable(Paragraph preface) throws BadElementException, DocumentException { // create header cell PdfPTable table = new PdfPTable(4); // set the width of the table to 100% of page table.setWidthPercentage(100);/*from w w w .j a va 2s.c o m*/ table.setWidths(new float[] { 1f, 0.6f, 0.4f, 2f }); table.setHeaderRows(1); creatCell("Voorbeeld foto", table, true); creatCell("Aantal", table, true); creatCell("PhotoID", table, true); creatCell("Beschrijving", table, true); for (OrderRow row : order.getOrderRows()) { Photo pfdphoto = this.photoDao.getById(row.getPhoto_id()); Image Logo = null; try { String filename = env.getProperty("uploadDir") + "thumb/" + pfdphoto.getThumbnailURL(); Logo = Image.getInstance(filename); Logo.scaleAbsolute(75, 50); } catch (BadElementException | IOException ex) { Logger.getLogger(OrderController.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell c1 = new PdfPCell(Logo); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setPaddingTop(10); c1.setPaddingBottom(10); table.addCell(c1); creatCell(row.getAantal() + "", table, false); creatCell(row.getPhoto_id() + "", table, false); creatCell(row.getProduct().getName(), table, false); } preface.add(table); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createTable(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);//from w w w .ja v a2 s . c o m Paragraph paragraph = new Paragraph(); paragraph.setFont(font); creteEmptyLine(paragraph, 2); document.add(paragraph); PdfPTable table = new PdfPTable(7); paragraph.add(""); PdfPCell c1 = new PdfPCell(new Phrase("asasas", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("/?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); TbActivity ac = new TbActivity(); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); paragraph.add(""); for (int i = 0; i < 7; i++) { table.setWidthPercentage(100); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(paragraph); } document.add(table); }