List of usage examples for com.itextpdf.text Image TEXTWRAP
int TEXTWRAP
To view the source code for com.itextpdf.text Image TEXTWRAP.
Click Source Link
From source file:com.github.luischavez.levsym.modulos.funcion.PDF.java
License:Open Source License
public void GeneraPDF(ResultSet Resultados) throws Exception { ResultSetMetaData metaData = Resultados.getMetaData(); Object[] Columnas = new Object[metaData.getColumnCount()]; String encabezado = "Reportes del Sistema Administrativo" + "\n" + "REGISTROS ACTUALES EN AL BASE DE DATOS" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; Calendar c = Calendar.getInstance(); String date = Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "-" + Integer.toString(c.get(Calendar.MONTH)) + "-" + Integer.toString(c.get(Calendar.YEAR)) + " " + Integer.toString(c.get(Calendar.HOUR_OF_DAY)) + "-" + Integer.toString(c.get(Calendar.MINUTE)) + "-" + Integer.toString(c.get(Calendar.SECOND)); Font fuente = new Font(Font.getFamily("ARIAL"), 12, Font.BOLD); String choro = "Reporte por fecha de los modulos\n" + "de catalogo" + "\n" + "Systema Administrativo" + "\n" + "\n" + "\n" + "\n"; Image imagen = Image.getInstance(System.getProperty("user.dir") + "/Image/logo.png"); imagen.setAlignment(Image.TEXTWRAP); try {/*from w w w . j a v a 2s. c o m*/ Paragraph linea = new Paragraph(encabezado, fuente); Phrase para = new Phrase(choro); Paragraph fecha = new Paragraph(date + "\n" + "\n"); PdfPTable tabla = new PdfPTable(Columnas.length); tabla.setWidthPercentage(100); //Document documento = new Document(PageSize.LETTER); Document documento = new Document(PageSize.A4.rotate(), 50, 50, 100, 72); File Dir = new File(System.getProperty("user.dir") + "/Reportes/"); if (!Dir.exists()) { Dir.mkdirs(); } String file = System.getProperty("user.dir") + "/Reportes/" + metaData.getTableName(1) + " " + date + ".pdf"; PdfWriter.getInstance(documento, new FileOutputStream(file)); documento.open(); documento.add(imagen); documento.add(linea); documento.add(para); documento.add(fecha); for (int x = 0; x < Columnas.length; x++) { PdfPCell Celda = new PdfPCell(new Paragraph(metaData.getColumnName(x + 1), FontFactory.getFont("arial", 9, Font.BOLD, BaseColor.RED))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } while (Resultados.next()) { for (int x = 0; x < Columnas.length; x++) { //if(Resultados.getObject(x+1).getClass().getSimpleName().equals("Integer")) PdfPCell Celda = new PdfPCell(new Paragraph(String.valueOf(Resultados.getObject(x + 1)), FontFactory.getFont("arial", 9, BaseColor.BLACK))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } } documento.add(tabla); documento.close(); } catch (DocumentException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.mycom.products.mywebsite.backend.util.DownloadHandler.java
License:Open Source License
@RequestMapping(value = "/user/{id}", method = RequestMethod.GET) protected final void downloadUserInformation(@PathVariable int id, HttpServletRequest request, final HttpServletResponse response) throws ServletException, BusinessException, DocumentException { UserBean user = userService.select(id, FetchMode.EAGER); if (user == null) { return;/* w w w.j a va 2 s .co m*/ } Document document = new Document(); document.setMargins(70, 70, 20, 20); try { response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=\"" + user.getName() + "_profile.pdf\""); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); Image profileImage = null; try { profileImage = Image.getInstance(user.getContent().getFilePath()); } catch (Exception e) { // e.printStackTrace(); } if (profileImage != null) { profileImage.setAlignment(Image.MIDDLE | Image.TEXTWRAP); profileImage.setBorder(Image.BOX); profileImage.setBorderWidth(5); BaseColor bgcolor = WebColors.getRGBColor("#E5E3E3"); profileImage.setBorderColor(bgcolor); profileImage.scaleToFit(100, 100); document.add(profileImage); } document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); // Adding Table Data PdfPTable table = new PdfPTable(2); // 2 columns. table.setWidthPercentage(100); // Width 100% table.setSpacingBefore(15f); // Space before table table.setSpacingAfter(15f); // Space after table // Set Column widths float[] columnWidths = { 1f, 2f, }; table.setWidths(columnWidths); // Name setTableHeader("Name", table); setTableContent(user.getName(), table); // Gender setTableHeader("Gender", table); String gender = "Male"; if (user.getGender() == Gender.FEMALE) { gender = "Female"; } setTableContent(gender, table); // Age setTableHeader("Age", table); setTableContent("" + user.getAge(), table); // Date of Birth setTableHeader("DOB", table); DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); setTableContent(dateFormatter.format(user.getDob()), table); // Email setTableHeader("Email", table); setTableContent(user.getEmail(), table); // NRC setTableHeader("NRC", table); setTableContent(user.getNrc(), table); // Phone setTableHeader("Phone", table); setTableContent(user.getPhone(), table); // Roles String roleStr = ""; List<RoleBean> roles = user.getRoles(); if (roles != null && roles.size() > 0) { Iterator<RoleBean> itr = roles.iterator(); while (itr.hasNext()) { RoleBean role = itr.next(); roleStr += role.getName(); if (itr.hasNext()) { roleStr += ","; } } } setTableHeader("Role(s)", table); setTableContent(roleStr, table); // Address setTableHeader("Address", table); setTableContent(user.getAddress(), table); document.add(table); document.add(new Paragraph(new Date().toString())); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:ihm.panneaux.GenererPdf.java
private void initComponement() throws FileNotFoundException, DocumentException, IOException { String DEST = "devis/devis-" + devis.getNumero() + ".pdf"; OutputStream file = new FileOutputStream(new File(DEST)); com.itextpdf.text.Document document = new com.itextpdf.text.Document(); PdfWriter.getInstance((com.itextpdf.text.Document) document, file); // PAS TOUCHE PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST)); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); writer.setPageEvent(event);// ww w. j a va 2s . co m document.open(); PdfContentByte canvas = writer.getDirectContent(); Image logo = Image.getInstance("images/logo.png"); logo.scaleAbsolute(200, 57); // INFO DEVIS Image devisImg = Image.getInstance("images/imgDevis.png"); devisImg.scaleAbsolute(110, 34); devisImg.setAbsolutePosition((PageSize.POSTCARD.getWidth() + 150), (PageSize.POSTCARD.getHeight() - devisImg.getScaledHeight()) * 2); Font fontImgDevis = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Phrase numeroInfo = new Phrase("Numro " + devis.getNumero(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, numeroInfo, devisImg.getScaledWidth() + 413, devisImg.getScaledHeight() + 710, 0); Phrase dateInfo = new Phrase("Le " + devis.getDate(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, dateInfo, devisImg.getScaledWidth() + 420, devisImg.getScaledHeight() + 695, 0); Image devisImgBordure = Image.getInstance("images/bordureDevis.png"); devisImgBordure.setAbsolutePosition((devisImg.getScaledWidth() + 318), devisImg.getScaledHeight() + 660); devisImgBordure.scaleAbsolute(120, 122); // INFO ENTREPRISE Font fontEntreprise = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD); Phrase coGerants = new Phrase("Co-grants : " + devis.getEntreprise().getCoGerant(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, coGerants, devisImg.getScaledWidth() + 210, devisImg.getScaledHeight() + 660, 0); Phrase siege = new Phrase("Sige : " + devis.getEntreprise().getSiege(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, siege, devisImg.getScaledWidth() + 149, devisImg.getScaledHeight() + 640, 0); Phrase tel = new Phrase("TEL : " + devis.getEntreprise().getTel(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, tel, devisImg.getScaledWidth() + 113, devisImg.getScaledHeight() + 625, 0); Image bordureEntreprise = Image.getInstance("images/bordureEntreprise.png"); bordureEntreprise.setAbsolutePosition(devisImg.getScaledWidth() - 80, devisImg.getScaledHeight() + 610); // INFO CLIENT Font fontClient = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL); Phrase nomPrenom = new Phrase(devis.getClient().getNom() + " " + devis.getClient().getPrenom(), fontClient); Phrase commune = new Phrase(devis.getClient().getAdresse(), fontClient); Phrase adresse = new Phrase(devis.getClient().getCodePostale() + " " + devis.getClient().getCommune(), fontClient); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, nomPrenom, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 595, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, commune, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 580, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, adresse, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 565, 0); document.add(logo); document.add(devisImg); document.add(devisImgBordure); document.add(bordureEntreprise); // AJOUT DES DONNEES DU TABLEAUX float[] columnWidths = { 14, 3, 4, 3, 4 }; Font fontCategorie = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); fontCategorie.setColor(BaseColor.GREEN); PdfPTable table = new PdfPTable(columnWidths); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.setTotalWidth(PageSize.A4.getWidth() - 15); table.setSpacingBefore(150); table.setLockedWidth(true); Font Categorie = new Font(FontFamily.HELVETICA, 13, Font.BOLD); Font Chantier = new Font(FontFamily.HELVETICA, 11, Font.UNDERLINE); PdfPCell cellChantier = new PdfPCell(new Phrase("CHANTIER : " + chantier, Chantier)); cellChantier.setColspan(3); cellChantier.setBorder(Rectangle.NO_BORDER); table.addCell(cellChantier); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(new Phrase("Dsignation", Categorie)); PdfPCell unite = new PdfPCell(new Phrase("Unite", Categorie)); PdfPCell quantite = new PdfPCell(new Phrase("Quantite", Categorie)); PdfPCell prixht = new PdfPCell(new Phrase("Prix HT", Categorie)); PdfPCell pvtht = new PdfPCell(new Phrase("Pvt HT", Categorie)); unite.setHorizontalAlignment(Element.ALIGN_CENTER); quantite.setHorizontalAlignment(Element.ALIGN_CENTER); prixht.setHorizontalAlignment(Element.ALIGN_CENTER); pvtht.setHorizontalAlignment(Element.ALIGN_CENTER); unite.setBorder(Rectangle.NO_BORDER); quantite.setBorder(Rectangle.NO_BORDER); prixht.setBorder(Rectangle.NO_BORDER); pvtht.setBorder(Rectangle.NO_BORDER); table.addCell(unite); table.addCell(quantite); table.addCell(prixht); table.addCell(pvtht); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); double htTotalParcour = 0; double ttcTotalParcour = 0; if (this.EquipementDeChantier.isEmpty() == false) { table.addCell(new Phrase("Equipement De Chantier", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : EquipementDeChantier) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); /* BACKUP table.addCell(listeMaterielDevi.getMateriel().getNom()); table.addCell(listeMaterielDevi.getMateriel().getUnite()); table.addCell(Double.toString(listeMaterielDevi.getQuantite())); table.addCell(Double.toString(listeMaterielDevi.getMateriel().getPrix())+""); table.addCell(Double.toString(listeMaterielDevi.getPvtHT())+""); */ ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Couverture.isEmpty() == false) { table.addCell(new Phrase("Couverture", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Couverture) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureArdoise.isEmpty() == false) { table.addCell(new Phrase("Couverture Ardoise", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureArdoise) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureTuile.isEmpty() == false) { table.addCell(new Phrase("Couverture Tuile", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureTuile) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Demoussage.isEmpty() == false) { table.addCell(new Phrase("Demoussage", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Demoussage) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Velux.isEmpty() == false) { table.addCell(new Phrase("Velux", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Velux) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Zinguerie.isEmpty() == false) { table.addCell(new Phrase("Zinguerie", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Zinguerie) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Plancher.isEmpty() == false) { table.addCell(new Phrase("Plancher", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Plancher) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } ttcTotalParcour = (ttcTotalParcour * devis.getTva() / 100) + ttcTotalParcour; LineDash solid = new SolidLine(); PdfPCell cell, cell2, cellSOUSTOTAL, cellhttotal, tva, getTva, totalttc, gettotalttc; table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); cell = new PdfPCell(new Phrase("")); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new CustomBorder(null, null, null, solid)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.addCell(new Phrase("")); table.addCell(new Phrase("")); cellSOUSTOTAL = new PdfPCell(new Phrase("SOUS-TOTAL")); cellSOUSTOTAL.setHorizontalAlignment(Element.ALIGN_MIDDLE); cellSOUSTOTAL.setBorder(Rectangle.NO_BORDER); table.addCell(cellSOUSTOTAL); table.addCell(new Phrase("")); double prixHT_2Chiffre = Math.round((htTotalParcour) * Math.pow(10, 2)) / Math.pow(10, 2); String httotal = String.valueOf(prixHT_2Chiffre); cellhttotal = new PdfPCell(new Phrase(httotal + "")); cellhttotal.setBorder(Rectangle.NO_BORDER); cellhttotal.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellhttotal); table.addCell(new Phrase("")); table.addCell(new Phrase("")); tva = new PdfPCell(new Phrase("TVA")); tva.setBorder(Rectangle.NO_BORDER); tva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(tva); getTva = new PdfPCell(new Phrase(devis.getTva() + "%")); getTva.setBorder(Rectangle.NO_BORDER); getTva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(getTva); String tvaprix = String.valueOf(htTotalParcour * devis.getTva() / 100); double prixTVA_2Chiffre = Math.round(Double.parseDouble(tvaprix) * Math.pow(10, 2)) / Math.pow(10, 2); cell2 = new PdfPCell(new Phrase(Double.toString(prixTVA_2Chiffre) + "")); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setCellEvent(new CustomBorder(null, null, null, solid)); cell2.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell2); table.addCell(""); table.addCell(""); totalttc = new PdfPCell(new Phrase("Total TTC")); totalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); totalttc.setBorder(PdfPCell.NO_BORDER); table.addCell(totalttc); table.addCell(""); double prixTTC_2Chiffre = Math.round(ttcTotalParcour * Math.pow(10, 2)) / Math.pow(10, 2); String ttctotal = String.valueOf(Double.toString(prixTTC_2Chiffre)); gettotalttc = new PdfPCell(new Phrase(ttctotal + "")); gettotalttc.setBorder(PdfPCell.NO_BORDER); gettotalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(gettotalttc); table.setSpacingAfter(10); document.add(table); Pattern p = Pattern.compile("[.^\\.]+"); String texte = devis.getInformationComplementaire(); Font infoComptBlue = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlue.setColor(BaseColor.BLUE); Font infoComptRed = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptRed.setColor(BaseColor.RED); Font infoComptBlack = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlack.setColor(BaseColor.BLACK); Paragraph infoComp = new Paragraph(); Image BonPourAccord = null; BonPourAccord = Image.getInstance("images/BonPourAccord.png"); infoComp.setAlignment(Element.ALIGN_LEFT); BonPourAccord.setAlignment(Image.TEXTWRAP | Image.ALIGN_RIGHT); String[] phrase = p.split(texte); for (int i = 0; i < phrase.length; i++) { if (i == 0 || i == 1) { infoComp.add(new Paragraph(phrase[i], infoComptBlue)); } if (i == 2 || i == 3 || i == 4 || i == 5) { infoComp.add(new Paragraph(phrase[i], infoComptRed)); } if (i > 5 && i <= 11) infoComp.add(new Paragraph(phrase[i], infoComptBlack)); if (i > 11) infoComp.add(new Paragraph(phrase[i], infoComptRed)); } /* A OPTIMISER */ float taille_tableau = table.calculateHeights() + table.getRowHeight(table.getLastCompletedRowIndex()); if (taille_tableau > 386) { document.newPage(); } document.add(BonPourAccord); document.add(infoComp); document.close(); EnvoieDevis envoie = new EnvoieDevis(null, true, session, devis); this.CouvertureArdoise.clear(); this.CouvertureTuile.clear(); this.Demoussage.clear(); this.EquipementDeChantier.clear(); this.Velux.clear(); this.Zinguerie.clear(); this.Couverture.clear(); this.Plancher.clear(); }
From source file:report.pdfs.Basics_PDF_Report.java
private void addBarChart(Section catPart) { Basics_Bar_Chart_Report chart = new Basics_Bar_Chart_Report(show, "Basic Expenses Overview"); Image To_be_Added = null;//w w w . ja v a2s . c om try { To_be_Added = Image.getInstance("bar_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Basics_PDF_Report.java
private void addPieChart(Section catPart) { Basics_Pie_Chart_Report chart = new Basics_Pie_Chart_Report(show, "Comparison", "Basic Expenses Overview"); Image To_be_Added = null;//from w w w.j a v a 2 s. c o m try { To_be_Added = Image.getInstance("pie_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Feed_PDF_Report.java
private void addBarChart(Section catPart) { Feed_Bar_Chart_Report chart = new Feed_Bar_Chart_Report(show, "Feed Expenses Overview"); Image To_be_Added = null;//from w ww .j a v a 2 s .c om try { To_be_Added = Image.getInstance("bar_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Feed_PDF_Report.java
private void addPieChart(Section catPart) { Feed_Pie_Chart_Report chart = new Feed_Pie_Chart_Report(show, "Comparison", "Feed Expenses Overview"); Image To_be_Added = null;//w ww . j a v a2 s .c o m try { To_be_Added = Image.getInstance("pie_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Fertilizer_PDF_Report.java
private void addBarChart(Section catPart) { Fertilizer_Bar_Chart_Report chart = new Fertilizer_Bar_Chart_Report(show, "Fertilizer Expenses Overview"); Image To_be_Added = null;//from w w w . j a v a2s. c o m try { To_be_Added = Image.getInstance("bar_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Fertilizer_PDF_Report.java
private void addPieChart(Section catPart) { Fertilizer_Pie_Chart_Report chart = new Fertilizer_Pie_Chart_Report(show, "Comparison", "Fertilizer Expenses Overview"); Image To_be_Added = null;/*from w w w . j a v a 2 s . c o m*/ try { To_be_Added = Image.getInstance("pie_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }
From source file:report.pdfs.Gas_PDF_Report.java
private void addBarChart(Section catPart) { Gas_Bar_Chart_Report chart = new Gas_Bar_Chart_Report(show, "Gas Expenses Overview"); Image To_be_Added = null;//from w ww . j a va 2 s . c o m try { To_be_Added = Image.getInstance("bar_chart.png"); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP); //To_be_Added.setBorder(Image.BOX); //To_be_Added.setBorderWidth(15); catPart.add(To_be_Added); }