List of usage examples for com.itextpdf.text.pdf PdfPCell setBorder
public void setBorder(final int border)
From source file:superlaskuttaja.logiikka.PdfExtractor.java
private void muodostaDokumentti(Document document, String laskunNumero, PdfWriter writer) throws DocumentException, SQLException, ParseException { document.open();/*from w ww.ja v a 2 s. com*/ //---------------------------------------------------------------------- PdfPTable table1 = new PdfPTable(7); Font f1 = new Font(Font.FontFamily.HELVETICA, 10); Font f2 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD); Font f3 = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD); Font f4 = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD); ResultSet rs = lataaja.getDbc() .executeQuery("select distinct Laskuttaja.yrityksenNimi, Laskuttaja.katuosoite,\n" + "Laskuttaja.postinumero, Laskuttaja.kaupunki, Lasku.paivays, Laskuttaja.alvTunniste,\n" + "Pankkiviivakoodi.erapaiva, Lasku.viivastyskorko, Pankkiviivakoodi.viiteTarkisteella,\n" + "T.nimi, Lasku.maksuehto, T.katuosoite, Laskuttaja.tilinumeronPankki,\n" + "T.postinumero, T.kaupunki, Laskuttaja.tilinumero, T.email, Laskuttaja.tilinumeronSwiftBic,\n" + "V.nimi, V.katuosoite, V.postinumero, V.kaupunki, V.email, Lasku.lisatiedot,\n" + "T.asiakasnumero, V.asiakasnumero, Laskuttaja.nimi, Laskuttaja.puhelinnumero,\n" + "Laskuttaja.sahkopostiOsoite, Pankkiviivakoodi.pankkiviivakoodi\n" + "from Lasku, Pankkiviivakoodi, Laskuttaja, Suorite, Asiakas T, Asiakas V\n" + "where Lasku.laskunNumero = " + laskunNumero + "\n" + "and Lasku.laskuttaja = Laskuttaja.yrityksenNimi\n" + "and Lasku.laskuttajanVersio = Laskuttaja.versio\n" + "and Lasku.pankkiviivakoodi = Pankkiviivakoodi.pankkiviivakoodi\n" + "and Lasku.laskunnumero = Suorite.lasku\n" + "and Suorite.tilaaja = T.asiakasnumero\n" + "and Suorite.tilaajanVersio = T.versio\n" + "and Suorite.vastaanottaja = V.asiakasnumero\n" + "and Suorite.vastaanottajanVersio = V.versio\n" + ""); rs.first(); table1.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin())); table1.setLockedWidth(true); table1.setWidths(new int[] { 370, 100, 73, 100, 73, 100, 179 }); PdfPCell cell; Paragraph p; cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(1), f4); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("LASKU", f4); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(2), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(3) + " " + rs.getString(4), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Pivys", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(pvmFormaatti1.format(pvmFormaatti3.parse(rs.getTimestamp(5).toString())), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Laskun numero", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(laskunNumero, f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Alv-tunniste: " + rs.getString(6), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Erpiv", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(pvmFormaatti1.format(pvmFormaatti4.parse(rs.getDate(7).toString())), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Viivstyskorko", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(Integer.toString(rs.getInt(8)) + ".0%", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); //Jos vastaanottaja on sama kuin tilaaja ei laiteta erikseen vastaanottajan tietoja nkyville. if (rs.getInt(25) == rs.getInt(26)) { cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(10), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Viitenumero", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(9), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(12), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Maksuehto", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(11), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(14) + " " + rs.getString(15), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Pankki", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(13), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(17), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Tilinumero", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(16), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Swift/BIC", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(18), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph("Listiedot", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(24), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); document.add(table1); } else { cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Palvelun tilaaja", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Viitenumero", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(9), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(10), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Maksuehto", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(11), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(12), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Pankki", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(13), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(14) + " " + rs.getString(15), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Tilinumero", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(16), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(rs.getString(17), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Swift/BIC", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph(rs.getString(18), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.LIGHT_GRAY); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph("Palvelun vastaanottaja", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(19), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(20), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(21) + " " + rs.getString(22), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(23), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph("Listiedot", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(rs.getString(24), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table1.addCell(cell); table1.completeRow(); document.add(table1); } // Otetaan alemmas tulevia tietoja talteen. String[] alasTulevatTiedot = new String[] { rs.getString(9), rs.getString(1), rs.getString(27), rs.getString(13), rs.getString(2), rs.getString(28), rs.getString(16), rs.getString(3) + " " + rs.getString(4), rs.getString(29), rs.getString(18), rs.getString(30), }; //Muodostetaan suoritteiden taulukko. PdfPTable table2 = new PdfPTable(7); table2.setWidths(new int[] { 370, 100, 73, 100, 73, 100, 179 }); table2.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin())); table2.setLockedWidth(true); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Kuvaus", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Mr", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Yks.", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(" hinta", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Alv %", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Alv ", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph("Yhteens", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorder(LEFT + BOTTOM + RIGHT + TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); table2.completeRow(); rs = lataaja.getDbc().executeQuery( "select distinct kuvaus, maara, maaranYksikot, aHintaVeroton, alvProsentti, ((alvProsentti / 100.0) * aHintaVeroton * maara) as alvEuroa,\n" + "((1.0 + alvProsentti / 100.0) * aHintaVeroton * maara) as yht, alkuaika\n" + "from Suorite\n" + "where lasku = " + laskunNumero + "\n" + ""); while (rs.next()) { cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getString(1) + " " + pvmFormaatti1.format(pvmFormaatti3.parse(rs.getTimestamp(8).toString())), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(2, 2).toString(), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getString(3), f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(4, 2).toString() + "", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getString(5) + "%", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(6, 2).toString() + "", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(7, 2).toString() + "", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(LEFT + RIGHT); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); table2.completeRow(); } cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(TOP); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table2.addCell(cell); table2.completeRow(); rs = lataaja.getDbc().executeQuery( "select distinct sum(aHintaVeroton * maara), sum((alvProsentti / 100.0) * aHintaVeroton * maara)\n" + "from Suorite\n" + "where lasku = " + laskunNumero + "\n" + ""); rs.first(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Veroton hinta yhteens", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(1, 2).toString() + "", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); table2.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Arvonlisvero yhteens", f2); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(2, 2).toString() + "", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); table2.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(7); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); table2.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(4); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); p = new Paragraph("Yhteens", f3); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); rs = lataaja.getDbc() .executeQuery("select laskunSumma\n" + "from Lasku, Pankkiviivakoodi\n" + "where laskunNumero = " + laskunNumero + "\n" + "and Lasku.pankkiviivakoodi = Pankkiviivakoodi.pankkiviivakoodi\n" + ""); rs.first(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(rs.getBigDecimal(1, 2).toString() + "", f3); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell); table2.completeRow(); document.add(table2); PdfPTable table3 = new PdfPTable(3); table3.setWidths(new int[] { 1, 1, 1 }); table3.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin())); table3.setLockedWidth(true); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Pyydmme kyttmn maksaessanne viitenumeroa: " + alasTulevatTiedot[0], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(BOTTOM); cell.setBorderColor(BaseColor.BLACK); cell.setBorderWidth(0.2f); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[1], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[2], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[3], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[4], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[5], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[6], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[7], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[8], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(1); p = new Paragraph(alasTulevatTiedot[9], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph(" ", f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(3); p = new Paragraph("Virtuaaliviivakoodi: " + alasTulevatTiedot[10], f1); p.setLeading(0, 1); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table3.addCell(cell); table3.completeRow(); table3.writeSelectedRows(0, -1, document.left(document.leftMargin()), table3.getTotalHeight() + document.bottom(document.bottomMargin()), writer.getDirectContent()); //---------------------------------------------------------------------- document.close(); }
From source file:Tables.Printer.java
public void footer(Document doc) throws DocumentException { Paragraph paragraph = new Paragraph("Njieforbi Bakery, Cameroon Buea"); doc.add(paragraph);// w w w.ja v a 2 s .c o m dNow = new Date(); String prodDate = "Created on the " + datOnly.format(dNow) + " at " + timOnly.format(dNow); ////////////////// PdfPTable timeOfProduction = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Phrase(prodDate.trim(), smallFooter)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setColspan(3); cell.setBorder(0); if (prodDate.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } timeOfProduction.addCell(cell); doc.add(timeOfProduction); Dialogs.create().title("Printing Complete").masthead("Printing process complete.") .message("Patient while the file open to see your printout.").showInformation(); }
From source file:Tables.PrinterClass.java
public void footer(Document doc) throws DocumentException { Paragraph paragraph = new Paragraph("@" + this.companyName); doc.add(paragraph);/*from ww w . j a v a 2 s.com*/ dNow = new Date(); String prodDate; prodDate = "Created on the " + dateOnly.format(dNow) + " at " + timeOnly.format(dNow); ////////////////// PdfPTable timeOfProduction = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Phrase(prodDate.trim(), smallFooter)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setColspan(3); cell.setBorder(0); if (prodDate.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } timeOfProduction.addCell(cell); doc.add(timeOfProduction); try { Image img = Image.getInstance(this.companyLogo); img.scaleAbsolute(20f, 20f); img.setAbsolutePosition((PageSize.A4.getWidth() - img.getScaledWidth()), (PageSize.A4.getHeight() - img.getScaledHeight())); //place the image at the bottom right position img.setAlt("Unity Systems"); } catch (Exception ex) { } }
From source file:tm.article_promotion.GArticlePromotionController.java
@FXML private void btnImprimerOnAction(ActionEvent event) throws DocumentException, FileNotFoundException { String s = cbPromotion.getSelectionModel().getSelectedItem().toString(); Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("promotion/promotion" + s + ".pdf")); PDFLogReport.open();//from ww w. j a v a 2 s . co m PdfPTable LogTable = new PdfPTable(5); PdfPCell table_cell; table_cell = new PdfPCell(new Phrase("Id Promotion")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Id Article")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Taux Reduction Gros")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Taux Reduction Detail")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Nombre Point")); LogTable.addCell(table_cell); ObservableList<ArticlePromotion> list = FXCollections.observableArrayList(); list = tblViewArtPromo.getItems(); for (ArticlePromotion ar : list) { table_cell = new PdfPCell(new Phrase(Integer.toString(ar.getIdPromotion()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(ar.getIdArticle()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(ar.getTauxReductionGros()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(ar.getTauxReductionDetail()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(ar.getNombrePointFidele()))); LogTable.addCell(table_cell); } table_cell.setBorder(4); table_cell.setColspan(6); PDFLogReport.add(LogTable); PDFLogReport.close(); }
From source file:tm.stock.GFactureController.java
@FXML private void btnImprimerOnAction(ActionEvent event) throws DocumentException, FileNotFoundException { Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream( "facture/facture" + tblView.getSelectionModel().getSelectedItem().getIdFacture() + ".pdf")); PDFLogReport.open();// www . j ava 2 s . c o m PdfPTable LogTable = new PdfPTable(10); PdfPCell table_cell; table_cell = new PdfPCell(new Phrase("ID_Article")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Designation")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Prix Unitaire")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Quantite")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("TVA (%)")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total TVA")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Remise (%)")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total Remise")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total HT")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total TTC")); LogTable.addCell(table_cell); ObservableList<Vente> list = FXCollections.observableArrayList(); list = tblViewVente.getItems(); for (Vente v : list) { table_cell = new PdfPCell(new Phrase(Integer.toString(v.getIdArticle()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(v.getNomArticle())); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getPrixUnitaire()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(v.getTva()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(v.getQuantite()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalTVA()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getRemise()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalRemise()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalHT()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalTTC()))); LogTable.addCell(table_cell); } table_cell.setBorder(4); table_cell.setColspan(6); PDFLogReport.add(LogTable); PDFLogReport.close(); }
From source file:tm.stock.GventeController.java
@FXML private void btnValiderOnAction(ActionEvent event) throws DocumentException, FileNotFoundException { Facture f = new Facture(); float prixTotal = 0; for (Vente v : ventes) { prixTotal += v.getTotalTTC();/*from w w w . j a va 2 s.c o m*/ } f.setPrixTotal(prixTotal); DateFormat df = new SimpleDateFormat("dd/MM/yy"); Date dateobj = new Date(); System.out.println(df.format(dateobj)); f.setDateAchat(df.format(dateobj).toString()); IFactureDAO facture = new FactureDAO(); facture.insertFacture(f); Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("facture/facture" + facture.getFacture() + ".pdf")); PDFLogReport.open(); PdfPTable LogTable = new PdfPTable(10); PdfPCell table_cell; table_cell = new PdfPCell(new Phrase("ID_Article")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Designation")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Prix Unitaire")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Quantite")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("TVA (%)")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total TVA")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Remise (%)")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total Remise")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total HT")); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase("Total TTC")); LogTable.addCell(table_cell); for (Vente v : ventes) { table_cell = new PdfPCell(new Phrase(Integer.toString(v.getIdArticle()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(v.getNomArticle())); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getPrixUnitaire()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(v.getTva()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Integer.toString(v.getQuantite()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalTVA()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getRemise()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalRemise()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalHT()))); LogTable.addCell(table_cell); table_cell = new PdfPCell(new Phrase(Float.toString(v.getTotalTTC()))); LogTable.addCell(table_cell); v.setIdFacture(facture.getFacture()); } table_cell.setBorder(4); table_cell.setColspan(6); PDFLogReport.add(LogTable); PDFLogReport.close(); IVenteDAO v = new VenteDAO(); v.insertVente(ventes); }
From source file:tn.com.hitechart.eds.Util.pdfRpport.FirstPdf.java
private void createTable(Section subCatPart) throws BadElementException { //-------------------------- TAB POINTAGE -------------------// PdfPTable table = new PdfPTable(8); table.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); table.setLockedWidth(true);//from w w w . j a v a 2 s. c om // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); //----------- C1 --------------// PdfPCell c1 = new PdfPCell(new Phrase("Date Rapport")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C2 --------------// c1 = new PdfPCell(new Phrase("Technicien")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C3 --------------// c1 = new PdfPCell(new Phrase("Poinatge")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); //----------- C4 --------------// c1 = new PdfPCell(new Phrase("Matin")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); //----------- C5 --------------// c1 = new PdfPCell(new Phrase("Aprs-Midi")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); //----------- C6 --------------// c1 = new PdfPCell(new Phrase("Rapport Journalier", catFont)); c1.setBorder(Rectangle.NO_BORDER); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(3); table.addCell(c1); //----------- C7 --------------// //----------- C8 --------------// table.setHeaderRows(1); //----------- R2 --------------// //----------- C1 --------------// c1 = new PdfPCell(new Phrase(tabDatapointage[0], dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setRowspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase(user.getLogin(), dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setRowspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("Arrive")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(tabDatapointage[1], dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(tabDatapointage[2], dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C7 --------------// c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C8 --------------// c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- R3 --------------// c1 = new PdfPCell(new Phrase("Sortie")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(tabDatapointage[3], dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(tabDatapointage[4], dataFont)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C7 --------------// c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); //----------- C8 --------------// c1 = new PdfPCell(new Phrase("")); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); table.setSpacingAfter(10); subCatPart.add(table); //-------------------------- END TAB POINTAGE -------------------// // TODO: 20/01/2017 //--------------------------------- TASK ---------------------// PdfPTable tableTask = new PdfPTable(5); tableTask.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); tableTask.setLockedWidth(true); PdfPCell c2 = new PdfPCell(new Phrase("Dossiers Traits", catFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setColspan(5); c2.setBorder(Rectangle.NO_BORDER); tableTask.addCell(c2); tableTask.setHeaderRows(1); c2 = new PdfPCell(new Phrase("NDoss.", dataFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); tableTask.addCell(c2); c2 = new PdfPCell(new Phrase("Client", dataFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); tableTask.addCell(c2); c2 = new PdfPCell(new Phrase("Dure", dataFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); tableTask.addCell(c2); c2 = new PdfPCell(new Phrase("Mission", dataFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); tableTask.addCell(c2); c2 = new PdfPCell(new Phrase("Resultat", dataFont)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); tableTask.addCell(c2); if (tasks.isEmpty()) { c2 = new PdfPCell(new Phrase("Aucune Tache a t trait", catFontempty)); c2.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setColspan(5); tableTask.addCell(c2); } else { if (!dossiers.isEmpty()) { for (Dossier d : dossiers) { tableTask.addCell(d.getNumDoss()); tableTask.addCell(d.getClient()); tableTask.addCell(convertLongtoDurationfr(d.getTimeDuration())); tableTask.addCell(td.getTaskById(d.get_idTask()).getType()); tableTask.addCell(td.getTaskById(d.get_idTask()).getRes()); } } } tableTask.setSpacingAfter(10); subCatPart.add(tableTask); //-------------------------- END TAB TASK -------------------// // TODO: 20/01/2017 tab achat //-------------------------- TAB ACHAT -------------------// PdfPTable tableAchat = new PdfPTable(3); tableAchat.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); tableAchat.setLockedWidth(true); PdfPCell c3 = new PdfPCell(new Phrase("Frais Engags", catFont)); c3.setHorizontalAlignment(Element.ALIGN_CENTER); c3.setColspan(3); c3.setBorder(Rectangle.NO_BORDER); tableAchat.addCell(c3); tableAchat.setHeaderRows(1); c3 = new PdfPCell(new Phrase("N.Doss.", dataFont)); c3.setHorizontalAlignment(Element.ALIGN_CENTER); tableAchat.addCell(c3); c3 = new PdfPCell(new Phrase("Dsignation", dataFont)); c3.setHorizontalAlignment(Element.ALIGN_CENTER); tableAchat.addCell(c3); c3 = new PdfPCell(new Phrase("Montant TCC", dataFont)); c3.setHorizontalAlignment(Element.ALIGN_CENTER); tableAchat.addCell(c3); if (achats.isEmpty()) { c3 = new PdfPCell(new Phrase("la liste des achats est vide", catFontempty)); c3.setHorizontalAlignment(Element.ALIGN_CENTER); c3.setColspan(3); tableAchat.addCell(c3); } else { for (Achat achat : achats) { tableAchat.addCell(String.valueOf(achat.getNumDoss())); tableAchat.addCell(achat.getDesignation()); tableAchat.addCell(String.valueOf(achat.getPrix())); } } tableAchat.setSpacingAfter(10); subCatPart.add(tableAchat); //-------------------------- END TAB ACHAT -------------------// // TODO: 20/01/2017 tab composant //-------------------------- TAB COMPOSANT -------------------// PdfPTable tableComp = new PdfPTable(3); tableComp.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); tableComp.setLockedWidth(true); PdfPCell c4 = new PdfPCell(new Phrase("Composants", catFont)); c4.setHorizontalAlignment(Element.ALIGN_CENTER); c4.setColspan(3); c4.setBorder(Rectangle.NO_BORDER); tableComp.addCell(c4); tableComp.setHeaderRows(1); c4 = new PdfPCell(new Phrase("N.Doss.", dataFont)); c4.setHorizontalAlignment(Element.ALIGN_CENTER); tableComp.addCell(c4); c4 = new PdfPCell(new Phrase("Dsignation", dataFont)); c4.setHorizontalAlignment(Element.ALIGN_CENTER); tableComp.addCell(c4); c4 = new PdfPCell(new Phrase("Quantit", dataFont)); c4.setHorizontalAlignment(Element.ALIGN_CENTER); tableComp.addCell(c4); if (comps.isEmpty()) { c4 = new PdfPCell(new Phrase("la liste des composants est vide", catFontempty)); c4.setHorizontalAlignment(Element.ALIGN_CENTER); c4.setColspan(3); tableComp.addCell(c4); } else { for (Composant comp : comps) { tableComp.addCell(String.valueOf(comp.getNumDoss())); tableComp.addCell(comp.getName()); tableComp.addCell(String.valueOf(comp.getQte())); } } tableComp.setSpacingAfter(10); subCatPart.add(tableComp); //-------------------------- END TAB COMPOSANT -------------------// // TODO: 20/01/2017 tab message //-------------------------- TAB MESSAGE -------------------// PdfPTable tableMsg = new PdfPTable(2); tableMsg.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); tableMsg.setLockedWidth(true); PdfPCell c5 = new PdfPCell(new Phrase("Message Transmettre", catFont)); c5.setHorizontalAlignment(Element.ALIGN_CENTER); c5.setColspan(3); c5.setBorder(Rectangle.NO_BORDER); tableMsg.addCell(c5); c5 = new PdfPCell(new Phrase("N.Doss.", dataFont)); c5.setHorizontalAlignment(Element.ALIGN_CENTER); tableMsg.addCell(c5); tableMsg.setHeaderRows(1); c5 = new PdfPCell(new Phrase("Message", dataFont)); c5.setHorizontalAlignment(Element.ALIGN_CENTER); tableMsg.addCell(c5); tableMsg.setHeaderRows(1); if (msgs.isEmpty()) { c5 = new PdfPCell(new Phrase("Aucun message", catFontempty)); c5.setHorizontalAlignment(Element.ALIGN_CENTER); c5.setColspan(3); tableMsg.addCell(c5); } else { for (Message msg : msgs) { tableMsg.addCell(String.valueOf(msg.getNumDoss())); tableMsg.addCell(msg.getMsg()); } } tableMsg.setSpacingAfter(10); subCatPart.add(tableMsg); //-------------------------- END TAB MESSAGE -------------------// // TODO: 20/01/2017 tab Activitee //-------------------------- TAB ACTIVITEE -------------------// PdfPTable tableAct = new PdfPTable(2); tableAct.setTotalWidth(PageSize.A4.rotate().getWidth() - 10); tableAct.setLockedWidth(true); PdfPCell c6 = new PdfPCell(new Phrase("Autre Activites", catFont)); c6.setHorizontalAlignment(Element.ALIGN_CENTER); c6.setColspan(2); c6.setBorder(Rectangle.NO_BORDER); tableAct.addCell(c6); tableAct.setHeaderRows(1); c6 = new PdfPCell(new Phrase("N.Doss.", dataFont)); c6.setHorizontalAlignment(Element.ALIGN_CENTER); tableAct.addCell(c6); c6 = new PdfPCell(new Phrase("Dure", dataFont)); c6.setHorizontalAlignment(Element.ALIGN_CENTER); tableAct.addCell(c6); if (autreActs.isEmpty()) { c6 = new PdfPCell(new Phrase("Aucune autre Activite a t effectu", catFontempty)); c6.setHorizontalAlignment(Element.ALIGN_CENTER); c6.setColspan(3); tableAct.addCell(c6); } else { for (Task autreA : autreActs) { tableAct.addCell(String.valueOf(autreA.getType())); tableAct.addCell(autreA.getNumDoss()); } } tableAct.setSpacingAfter(10); subCatPart.add(tableAct); //-------------------------- END TAB MESSAGE -------------------// }
From source file:utilities.itext.Turnover.java
private static Paragraph createTablesWithDetails(ArrayList<PaymentPosition> data) throws DocumentException { Paragraph paragraph = new Paragraph(); PdfPTable expense = new PdfPTable(2); float[] colWidths = { 5f, 1f }; expense.setWidths(colWidths);/* w ww . j a v a 2s . com*/ int lastPaymentID = 0; for (PaymentPosition pp : data) { if (lastPaymentID != pp.getPayment().getId()) { //new Payment Paragraph p1 = new Paragraph(pp.getPayment().getPayee().getName()); PdfPCell c1 = new PdfPCell(p1); //add next cell with price //calc price BigDecimal totalPrice = new BigDecimal(BigInteger.ZERO); for (PaymentPosition payPos : data) { if (payPos.getPayment().getId() == pp.getPayment().getId()) { totalPrice = totalPrice.add(payPos.getTotalPrice()); } } Paragraph p2 = new Paragraph(totalPrice.toPlainString()); PdfPCell c2 = new PdfPCell(p2); c1.setBorder(Rectangle.NO_BORDER); c1.setBorderWidthTop(0.5f); c2.setBorder(Rectangle.NO_BORDER); c2.setBorderWidthTop(0.5f); expense.addCell(c1); expense.addCell(c2); } //payment position Paragraph p1 = new Paragraph(" " + pp.getQuantity() + "x: " + pp.getArticle().getName()); PdfPCell c1 = new PdfPCell(p1); //add next cell with price Paragraph p2 = new Paragraph(pp.getTotalPriceAsString()); PdfPCell c2 = new PdfPCell(p2); c1.setBorder(Rectangle.NO_BORDER); c2.setBorder(Rectangle.NO_BORDER); expense.addCell(c1); expense.addCell(c2); lastPaymentID = pp.getPayment().getId(); } paragraph.add(expense); paragraph.setSpacingBefore(10f); return paragraph; }
From source file:utils.pdf.cv_templates.Template1.java
private void addPersonalInformation(User user) throws DocumentException { Paragraph paragraph;//from w w w . j ava2 s.com PdfPCell cell; PdfPTable table; table = new PdfPTable(new float[] { 0.5f, 2f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.name + " " + user.surnames, font1); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.birthDate + "\n", font4); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph("Calle " + user.residenceAddress + " N " + user.residenceNumber + " " + user.residenceZipCode + " " + user.residenceCity + "\n", font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.phoneNumber, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.email, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); document.add(table); }
From source file:utils.pdf.cv_templates.Template1.java
private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException { Paragraph paragraph;//from ww w. ja v a2s . c o m PdfPCell cell; PdfPTable table; for (int i = 0; i < experienceList.size(); i++) { table = new PdfPTable(new float[] { 1f, 0.5f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); if (i == 0) { paragraph = new Paragraph("Experiencia Profesional", font1); cell.setBorder(PdfPCell.NO_BORDER); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).job + "." + " " + experienceList.get(i).company, font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).startDate + " - " + experienceList.get(i).endDate, font3); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }