List of usage examples for com.itextpdf.text BaseColor BLACK
BaseColor BLACK
To view the source code for com.itextpdf.text BaseColor BLACK.
Click Source Link
From source file:ServletsReportesPDF.ReporteSiembraMecanizada.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . java 2s . co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String num_lote = request.getParameter("num_lote"); response.setContentType("application/pdf"); OutputStream out = response.getOutputStream(); try { try { Connection con = null; Statement st = null; Statement st2 = null; Statement st3 = null; ResultSet rs = null; ResultSet rs2 = null; ResultSet rs3 = null; Class.forName("com.mysql.jdbc.Driver"); con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root", "9510"); st = (Statement) con.createStatement(); st2 = (Statement) con.createStatement(); st3 = (Statement) con.createStatement(); rs = st.executeQuery( "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='" + num_lote + "'"); rs2 = st2.executeQuery("SELECT * from siembra_mecanizada where num_lote ='" + num_lote + "'"); rs3 = st3.executeQuery("SELECT * from siembra_mecanizada where num_lote ='" + num_lote + "'"); if (con != null) { Document documento = new Document(A4.rotate()); PdfWriter writer = PdfWriter.getInstance(documento, out); FooterPiePaginaiText footer = new FooterPiePaginaiText(); writer.setPageEvent(footer); documento.open(); try { Image imagenes = Image.getInstance( "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png"); imagenes.setAlignment(Element.ALIGN_RIGHT); imagenes.scaleToFit(200, 200); documento.add(imagenes); //documento.add(imagenes); Paragraph par21 = new Paragraph(); Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK); par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip)); par21.setAlignment(Element.ALIGN_CENTER); par21.add(new Phrase(Chunk.NEWLINE)); documento.add(par21); String nombre = null; String Apellido = null; String cedula = null; while (rs.next()) { nombre = (rs.getString("nombre")); cedula = (rs.getString("cedula")); Apellido = (rs.getString("apellido")); } Paragraph par2 = new Paragraph(); Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK); Date date = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy "); par2.add(new Paragraph("Fecha: " + dateFormat.format(date), fontfecha)); //par2.add(new Paragraph(new Date().toString())); par2.setAlignment(Element.ALIGN_RIGHT); ; documento.add(par2); Paragraph par7 = new Paragraph(); Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK); par7.add(new Phrase("Nombre: " + nombre + " " + Apellido, fontUsuario)); par7.add(new Phrase("\nc.c: " + cedula, fontUsuario)); par7.setAlignment(Element.ALIGN_LEFT); par7.add(new Phrase(Chunk.NEWLINE)); documento.add(par7); Paragraph par3 = new Paragraph(); Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri)); par3.setAlignment(Element.ALIGN_CENTER); par3.add(new Phrase(Chunk.NEWLINE)); documento.add(par3); } catch (Exception eX) { eX.getMessage(); } try { Paragraph par1 = new Paragraph(); Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase("REPORTE SIEMBRA MECANIZADA", fonttitulo)); par1.setAlignment(Element.ALIGN_CENTER); par1.add(new Phrase(Chunk.NEWLINE)); documento.add(par1); PdfPTable tabla = new PdfPTable(6); FontFactory.registerDirectories(); documento.add(new Paragraph("\n")); PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda2 = new PdfPCell(new Paragraph("Variedad Semilla", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda3 = new PdfPCell(new Paragraph("Costo Semilla", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda4 = new PdfPCell(new Paragraph("Costo Secado Semilla", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda5 = new PdfPCell(new Paragraph("Cantidad Bultos", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda6 = new PdfPCell(new Paragraph("Valor Bulto", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); tabla.addCell(celda1); tabla.addCell(celda2); tabla.addCell(celda3); tabla.addCell(celda4); tabla.addCell(celda5); tabla.addCell(celda6); while (rs2.next()) { tabla.addCell(rs2.getString("fecha_smzd")); tabla.addCell(rs2.getString("variedad_semilla_smzd")); tabla.addCell(rs2.getString("costo_semilla_smzd")); tabla.addCell(rs2.getString("secado_semilla_smzd")); tabla.addCell(rs2.getString("cantidad_bultos_smzd")); tabla.addCell(rs2.getString("valor_bulto_smzd")); } documento.add(tabla); Paragraph par4 = new Paragraph(); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK); par4.add(new Phrase("REPORTE MANO DE OBRA SIEMBRA MECANIZADA", fontFooter2)); par4.setAlignment(Element.ALIGN_CENTER); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); documento.add(par4); PdfPTable tabla2 = new PdfPTable(4); FontFactory.registerDirectories(); PdfPCell celda10 = new PdfPCell(new Paragraph("Costo Mquina", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda10.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda20 = new PdfPCell(new Paragraph("Cantidad Hectreas", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda20.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda30 = new PdfPCell(new Paragraph("Costo Mano Obra", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda30.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda40 = new PdfPCell(new Paragraph("Valor Total", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda10); tabla2.addCell(celda20); tabla2.addCell(celda30); tabla2.addCell(celda40); while (rs3.next()) { tabla2.addCell(rs3.getString("costo_mq_sembradora_smzd")); tabla2.addCell(rs3.getString("num_hect_sembradas_smzd")); tabla2.addCell(rs3.getString("costo_mano_obra_smzd")); tabla2.addCell(rs3.getString("valor_total_smzd")); } documento.add(tabla2); } catch (Exception e) { e.printStackTrace(); } documento.close(); } } catch (Exception e) { e.getMessage(); } } finally { out.close(); } }
From source file:SessionBean.ReportMgt.ReportMgtBean.java
License:Open Source License
public void createMonthlyReport(Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) { try {//from w w w. j a v a2 s . c om String RESULT; System.out.print("start"); if (startYear.equals(endYear) && startMonth.equals(endMonth)) { RESULT = "d:/GeneralReport-" + startYear + "." + startMonth + ".pdf"; } else { RESULT = "d:/GeneralReport-" + startYear + "." + startMonth + "-" + endYear + "." + endMonth + ".pdf"; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); Image image = Image.getInstance("d:/logo-4227.png"); image.scaleAbsolute(150, 50); document.add(new Paragraph("")); document.add(image); Calendar targetPeriod = Calendar.getInstance(); int month = targetPeriod.get(Calendar.MONTH) + 1; int year = targetPeriod.get(Calendar.YEAR); String reportTile; document.add(new Paragraph("WineXpress General Sales Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); if (startYear.equals(endYear) && startMonth.equals(endMonth)) { reportTile = startYear + "." + startMonth; document.add(new Paragraph(reportTile, FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); } else { reportTile = startYear + "." + startMonth + "-" + endYear + "." + endMonth; document.add(new Paragraph(reportTile, FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); } document.add(new Paragraph("Generated Time: " + new Date().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.PLAIN, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(6); table.getDefaultCell().setBorder(0); // PdfPCell cell= new PdfPCell(new Paragraph("Wine Name")); // cell.setColspan(4); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(BaseColor.BLACK); // table.addCell(cell); table.addCell("Item ID"); table.addCell("Item Name"); table.addCell("Sales (bottle)"); table.addCell("Revenue (SGD)"); table.addCell("Cost (SGD)"); table.addCell("Profit (SGD)"); Integer totalSales = 0; Double totalRevenue = 0D; Double totalCost = 0D; Double totalProfit = 0D; Query q1; q1 = em.createQuery("select i from PurchaseEntity i"); Query q2; q2 = em.createQuery("select i from ItemEntity i"); System.out.print("2"); List<ItemEntity> itemList = q2.getResultList(); List<PurchaseEntity> purchaseList = q1.getResultList(); System.out.print("3"); startMonth -= 1; endMonth -= 1; for (ItemEntity i : itemList) { Integer sales = 0; Double revenue = 0D; Double cost = 0D; for (PurchaseEntity p : purchaseList) { if ((p.getPurchasedDate().get(Calendar.YEAR) >= startYear) && (p.getPurchasedDate().get(Calendar.YEAR) <= endYear) && (p.getPurchasedDate().get(Calendar.MONTH) >= startMonth) && (p.getPurchasedDate().get(Calendar.MONTH) <= endMonth)) { System.out.print("looploop1"); Long orderId = p.getOrderId(); OrderEntity order = em.find(OrderEntity.class, orderId); ItemEntity item = em.find(ItemEntity.class, order.getItemId()); System.out.print("looploop2"); if (item.getId().equals(i.getId())) { sales += p.getQuantity(); revenue += p.getTotalPrice(); cost += p.getQuantity() * item.getCost(); System.out.print("looploop3"); } } } Double profit = revenue - cost; totalSales += sales; totalRevenue += revenue; totalCost += cost; totalProfit += profit; table.addCell(i.getId().toString()); table.addCell(i.getItemName()); table.addCell(sales.toString()); table.addCell(revenue.toString()); table.addCell(cost.toString()); table.addCell(profit.toString()); } document.add(table); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table2 = new PdfPTable(6); table2.getDefaultCell().setBorder(0); table2.addCell(" "); table2.addCell(" "); table2.addCell(totalSales.toString()); table2.addCell(totalRevenue.toString()); table2.addCell(totalCost.toString()); table2.addCell(totalProfit.toString()); document.add(table2); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Copyright 2015 All rights reserved | WineXpress", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, BaseColor.BLACK))); document.close(); FileOutputStream fos = new FileOutputStream(RESULT); fos.write(baos.toByteArray()); fos.close(); System.out.println("created"); Calendar generatedTime = Calendar.getInstance(); ReportEntity report = new ReportEntity("GeneralReport-" + reportTile, "G", RESULT, generatedTime); em.persist(report); em.flush(); } catch (Exception e) { } }
From source file:SessionBean.ReportMgt.ReportMgtBean.java
License:Open Source License
public void createProductReport(Long productId, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) {// ww w . ja va2 s . com try { System.out.print("start"); ItemEntity item = em.find(ItemEntity.class, productId); String RESULT; String reportTitle; if (startYear.equals(endYear) && startMonth.equals(endMonth)) { RESULT = "d:/ProductReport-" + item.getId() + "-" + startYear + "." + startMonth + ".pdf"; reportTitle = startYear + "." + startMonth; } else { RESULT = "d:/ProductReport-" + item.getId() + "-" + startYear + "." + startMonth + "-" + endYear + "." + endMonth + ".pdf"; reportTitle = startYear + "." + startMonth + "-" + endYear + "." + endMonth; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); Image image = Image.getInstance("d:/logo-4227.png"); image.scaleAbsolute(150, 50); document.add(image); document.add(new Paragraph("WineXpress Product Sales Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph("Item " + item.getId() + ": " + item.getItemName() + ", " + item.getVitage(), FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); document.add(new Paragraph("Generated Time: " + new Date().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.PLAIN, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBorder(0); // PdfPCell cell= new PdfPCell(new Paragraph("Wine Name")); // cell.setColspan(4); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(BaseColor.BLACK); // table.addCell(cell); table.addCell("Period"); table.addCell("Sales"); table.addCell("Revenue"); table.addCell("Cost"); table.addCell("Profit"); table.addCell(" "); table.addCell("(bottle)"); table.addCell("(SGD)"); table.addCell("(SGD)"); table.addCell("(SGD)"); Integer totalSales = 0; Double totalRevenue = 0D; Double totalCost = 0D; Double totalProfit = 0D; Query q1; q1 = em.createQuery("select i from PurchaseEntity i"); Query q2; q2 = em.createQuery("select i from ItemEntity i"); System.out.print("2"); List<ItemEntity> itemList = q2.getResultList(); List<PurchaseEntity> purchaseList = q1.getResultList(); System.out.print("3"); for (int y = startYear; y <= endYear; y++) { for (int m = startMonth - 1; m <= endMonth - 1; m++) { Integer sales = 0; Double revenue = 0D; Double cost = 0D; System.out.print("loop"); for (PurchaseEntity p : purchaseList) { System.out.print("looploop1"); Long orderId = p.getOrderId(); OrderEntity order = em.find(OrderEntity.class, orderId); ItemEntity item1 = em.find(ItemEntity.class, order.getItemId()); System.out.print("looploop2"); if (item1.getId().equals(item.getId()) && p.getPurchasedDate().get(Calendar.MONTH) == m && p.getPurchasedDate().get(Calendar.YEAR) == y) { sales += p.getQuantity(); revenue += p.getTotalPrice(); cost += p.getQuantity() * item.getCost(); System.out.print("looploop3"); } } Double profit = revenue - cost; totalSales += sales; totalRevenue += revenue; totalCost += cost; totalProfit += profit; int n = m + 1; table.addCell(y + "-" + n); table.addCell(sales.toString()); table.addCell(revenue.toString()); table.addCell(cost.toString()); table.addCell(profit.toString()); } } document.add(table); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table2 = new PdfPTable(5); table2.getDefaultCell().setBorder(0); table2.addCell(" "); table2.addCell(totalSales.toString()); table2.addCell(totalRevenue.toString()); table2.addCell(totalCost.toString()); table2.addCell(totalProfit.toString()); document.add(table2); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Copyright 2015 All rights reserved | WineXpress", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, BaseColor.BLACK))); document.close(); FileOutputStream fos = new FileOutputStream(RESULT); fos.write(baos.toByteArray()); fos.close(); System.out.println("created"); Calendar generatedTime = Calendar.getInstance(); ReportEntity report = new ReportEntity("ProductReport-" + item.getId() + "-" + reportTitle, item.getId().toString(), RESULT, generatedTime); em.persist(report); em.flush(); } catch (Exception e) { } }
From source file:src.servlets.ManageAdmin.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from w w w . j a v a2s. c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map m = request.getParameterMap(); if (m.containsKey("GetPDF")) { try { String Report = getServletContext().getRealPath("") + "admin\\PDF_Report.pdf"; FileOutputStream file = new FileOutputStream(Report); Document document = new Document(); document.addAuthor("K00140908"); PdfWriter.getInstance(document, file); ///////////////////////ADDING THE FILES TO PDF//////////////////// //Inserting Image in PDF String uploadPath = getServletContext().getRealPath("") + "images\\logo.gif"; Image img = Image.getInstance(uploadPath); img.scaleAbsolute(120f, 60f);// width,height of image in float // Inserting Title in PDF ORIGINAL // Font fontTitle=new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.WHITE); // Chunk title=new Chunk("PDF GENERATION in Java with iText", fontTitle); // title.setBackground(new BaseColor(255,102,0), 1f, 1f, 1f, 3f); // title.setLineHeight(30f); // title.setUnderline(BaseColor.BLACK,5f,0.5f,2f,0.5f,PdfContentByte.LINE_CAP_ROUND); Font fontTitle = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLACK); Chunk title = new Chunk("Lit Realty System Report", fontTitle); title.setLineHeight(30f); //Inserting Table in PDF PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); // Sets the width percentage that the table will occupy in the page table.setSpacingAfter(10f); table.setSpacingBefore(15f); table.setWidths(new float[] { 2f, 2f, 2f }); // Sets relative width of table Font fontHeader = new Font(Font.FontFamily.HELVETICA, 15, Font.BOLD, BaseColor.BLUE); PdfPCell headercell = new PdfPCell(new Phrase("Property Photo", fontHeader)); // Creates new cell in table headercell.setBackgroundColor(new BaseColor(230, 230, 243)); headercell.setPaddingBottom(5f); table.addCell(headercell); headercell = new PdfPCell(new Phrase("Property ID", fontHeader)); headercell.setBackgroundColor(new BaseColor(233, 233, 233)); headercell.setPaddingBottom(5f); table.addCell(headercell); headercell = new PdfPCell(new Phrase("Price", fontHeader)); headercell.setBackgroundColor(new BaseColor(233, 233, 233)); headercell.setPaddingBottom(5f); table.addCell(headercell); PdfPCell cell1 = new PdfPCell(img, false); table.addCell(cell1); table.addCell("134000"); table.addCell("213445"); table.addCell("134000"); //Inserting List com.itextpdf.text.List list = new com.itextpdf.text.List(true, 30); list.add(new ListItem("Example1")); list.add(new ListItem("Example2")); list.add(new ListItem("Example3")); //Adding elements into PDF Document document.open(); document.add(img); document.add(title); document.add(Chunk.NEWLINE); document.add(table); document.newPage(); document.add(new Chunk("List of Examples").setUnderline(+1f, -5f)); document.add(list); document.newPage(); document.add(new Chunk("List of Examples").setUnderline(+1f, -5f)); document.add(list); document.newPage(); document.add(new Chunk("List of Properts By Agent X").setUnderline(+1f, -5f)); //////////////////////GET Propertys From Entity/////////////// List<Properties> allPropertiesList = PropertiesDB.getAllProperties(); PdfPTable propertyTable = new PdfPTable(3); PdfPCell propertyHeadingcell1 = new PdfPCell(new Phrase("Photo")); PdfPCell propertyHeadingcell2 = new PdfPCell(new Phrase("Property ID")); PdfPCell propertyHeadingcell3 = new PdfPCell(new Phrase("Price")); propertyHeadingcell1.setBorder(Rectangle.NO_BORDER); propertyHeadingcell2.setBorder(Rectangle.NO_BORDER); propertyHeadingcell3.setBorder(Rectangle.NO_BORDER); propertyTable.addCell(propertyHeadingcell1); propertyTable.addCell(propertyHeadingcell2); propertyTable.addCell(propertyHeadingcell3); document.add(Chunk.NEWLINE); String uploadPathforPropertyPhoto = getServletContext().getRealPath("") + "images\\properties\\thumbnails\\"; Image propertyThumbnail; img.scaleAbsolute(120f, 60f);// width,height of image in float for (Properties anProperty : allPropertiesList) { propertyThumbnail = Image.getInstance(uploadPathforPropertyPhoto + anProperty.getPhoto()); PdfPCell propertycell1 = new PdfPCell(propertyThumbnail, false); propertycell1.setPaddingBottom(20); PdfPCell propertycell2 = new PdfPCell(new Phrase(anProperty.getListingNum().toString())); PdfPCell propertycell3 = new PdfPCell(new Phrase(anProperty.getPrice().toString())); propertycell1.setBorder(Rectangle.NO_BORDER); propertycell2.setBorder(Rectangle.NO_BORDER); propertycell3.setBorder(Rectangle.NO_BORDER); propertyTable.addCell(propertycell1); propertyTable.addCell(propertycell2); propertyTable.addCell(propertycell3); } document.add(Chunk.NEWLINE); document.add(propertyTable); //////////////////////GET Propertys From Entity/////////////// document.close(); file.close(); System.out.println("Pdf created successfully ! :)"); String filePath = Report; File downloadFile = new File(filePath); FileInputStream inStream = new FileInputStream(downloadFile); // if you want to use a relative path to context root: String relativePath = getServletContext().getRealPath(""); System.out.println("relativePath = " + relativePath); // obtains ServletContext ServletContext context = getServletContext(); // gets MIME type of the file String mimeType = context.getMimeType(filePath); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } System.out.println("MIME type: " + mimeType); // modifies response response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); // forces download String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); // obtains response's output stream OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } inStream.close(); outStream.close(); ///////////////// processRequest(request, response); } catch (DocumentException ex) { Logger.getLogger(ManageAdmin.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:superlaskuttaja.logiikka.PdfExtractor.java
private void muodostaDokumentti(Document document, String laskunNumero, PdfWriter writer) throws DocumentException, SQLException, ParseException { document.open();/*from w w w . j a v a 2 s.c o m*/ //---------------------------------------------------------------------- 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:tprog.web.DescargarPDF.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); URL wsdlLocation = new URL(getServletContext().getInitParameter("wsdl")); webservice.PublicadorService service = new webservice.PublicadorService(wsdlLocation); webservice.Publicador proxy = service.getPublicadorPort(); System.out.println("Llego hasta el servlet"); //response.setContentType("application/pdf"); try {// w ww .j av a 2 s. co m String idReservaString = request.getParameter("idReserva"); response.setContentType("application/pdf"); Integer idReserva = Integer.parseInt(idReservaString); WrapperVerFactura wrapper = proxy.verFactura(idReserva); DtFacturaF dtf = wrapper.getFactura(); Set<DtServicioF> servicios = new HashSet(dtf.getServicios()); Set<DtPromocionF> promociones = new HashSet(dtf.getPromociones()); String fecha = Integer.toString(dtf.getFecha().getDay()) + "-" + Integer.toString(dtf.getFecha().getMonth()) + "-" + Integer.toString(dtf.getFecha().getYear()) + "\n"; //creo el documento pdf dinmicamente : no s donde se guarda //pero se genera a demanda siempre Document document = new Document(); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); document.add(new Paragraph("Detalles de la Factura", FontFactory.getFont("arial", 22, Font.ITALIC, BaseColor.BLACK))); document.add(new Paragraph(" ")); //ingreso los datos de la factura document.add(new Paragraph("Id de la Reserva: " + idReservaString)); document.add(new Paragraph("Fecha: " + fecha)); document.add(new Paragraph("Cliente: " + dtf.getNicknameCliente())); document.add(new Paragraph("Monto: $" + dtf.getMonto())); document.add(new Paragraph(" ")); //tabla para los servicios if (!servicios.isEmpty()) { document.add(new Paragraph("Servicios")); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell("Item"); table.addCell("Nombre"); table.addCell("Cantidad"); table.addCell("Precio"); table.addCell("Proveedor"); table.getDefaultCell().setBackgroundColor(null); int i = 1; for (DtServicioF servicio : servicios) { table.addCell(Integer.toString(i)); table.addCell(servicio.getNombre()); table.addCell(Integer.toString(servicio.getCantidad())); table.addCell(Double.toString(servicio.getPrecio())); table.addCell(servicio.getNicknameProveedor()); i++; } document.add(table); document.add(new Paragraph(" ")); } //tabla para las promos if (!promociones.isEmpty()) { document.add(new Paragraph("Promociones")); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell("Item"); table.addCell("Nombre"); table.addCell("Cantidad"); table.addCell("Precio"); table.addCell("Proveedor"); table.getDefaultCell().setBackgroundColor(null); int i = 1; for (DtPromocionF promocion : promociones) { table.addCell(Integer.toString(i)); table.addCell(promocion.getNombre()); table.addCell(Integer.toString(promocion.getCantidad())); table.addCell(Double.toString(promocion.getPrecio())); table.addCell(promocion.getNicknameProveedor()); i++; } document.add(table); document.add(new Paragraph(" ")); } document.close(); // session.setAttribute("descargaOK", "La descarga se complet correctamente."); response.sendRedirect("VerPerfil"); } catch (DocumentException de) { throw new IOException(de.getMessage()); } }
From source file:utiles.FacturaPdf.java
/** * metodo que hace uso de la clase itext para generar archivos PDF recogiendo * los datos para una factura/*from w w w .j av a 2 s . c o m*/ * @param _nombre recoge el cliente que realiza la reserva * @param _dni optiene la documentacion del cliente * @param _telefono se le pasa numero de contacto del cliente * @param _cantidad se indica numero de servicios que ha comprado * @param _servicio recoge el nombre del servicio comprado * @param _fecha optiene fecha en la que el cliente tiene la "cita" * @param _total coste de todos los servicios comprados "cantidad*precio del servicio - la promocion" * @throws Exception */ public static void ITextHelloWorld(String _nombre, String _dni, String _telefono, String _cantidad, String _servicio, String _fecha, String _total) throws Exception { Document document = new Document(); Paragraph parrafo, paragraph_2, parrafo2, parrafo3, parrafo4; Image imagen = Image.getInstance("src/icon/Spa.jpg"); // Le indicamos donde se guardara el archivo PdfWriter.getInstance(document, new FileOutputStream("src/pdfGenerados/" + "Factura_" + _nombre + "_" + _servicio + "_" + _cantidad + "_" + _total + ".pdf")); // Este codigo genera una tabla de 2 columnas PdfPTable table = new PdfPTable(7); table.setWidthPercentage(100); String nombre = _nombre; String dni = _dni; String telefono = _telefono; String cantidad = _cantidad; String servicio = _servicio; String fecha = _fecha; String total = _total + " "; // addCell() agrega una celda a la tabla, el cambio de fila // ocurre automaticamente al llenar la fila table.addCell("Nombre"); table.addCell("Dni"); table.addCell("Telefono"); table.addCell("Cantidad"); table.addCell("Servicio"); table.addCell("Fecha reserva"); table.addCell("Precio total"); table.addCell(nombre); table.addCell(dni); table.addCell(telefono); table.addCell(cantidad); table.addCell(servicio); table.addCell(fecha); table.addCell(total); document.open(); //Creamos una cantidad significativa de paginas para probar el encabezado parrafo = new Paragraph("Gracias por confiar en nuestros servicios SpaRelajate"); paragraph_2 = new Paragraph(" FACTURA "); parrafo2 = new Paragraph(" "); parrafo3 = new Paragraph(" "); parrafo4 = new Paragraph(" "); //este codigo hace que se nos centre tanto el texto como la imagen parrafo.setAlignment(Element.ALIGN_CENTER); paragraph_2.setAlignment(Element.ALIGN_CENTER); parrafo2.setAlignment(Element.ALIGN_CENTER); imagen.setAlignment(Element.ALIGN_CENTER); paragraph_2.setFont(new Font(FontFactory.getFont("Helvetica", 40, Font.BOLD, BaseColor.BLACK))); //aade la documentacion que tendra el pdf document.add(parrafo4); document.add(parrafo4); document.add(imagen); document.add(parrafo4); document.add(parrafo4); document.add(paragraph_2); document.add(parrafo3); document.add(parrafo4); document.add(parrafo4); document.add(parrafo4); document.add(parrafo4); document.add(table); document.add(parrafo4); document.add(parrafo2); document.add(parrafo3); document.add(parrafo4); document.add(parrafo4); document.add(parrafo4); document.add(parrafo4); document.add(parrafo4); document.add(parrafo2); document.add(parrafo); document.close(); }
From source file:Valuacion.Autorizacion.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/* w w w . j av a2 s . co m*/ reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(160, 515, 210, 45, 5); reporte.contenido.roundRectangle(380, 515, 375, 45, 5); reporte.contenido.roundRectangle(35, 490, 720, 20, 5); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 160, 580, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Autorizacion de Operaciones (" + this.c_filtro.getSelectedItem().toString() + ")", 160, 570, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 760, 580, 0); ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); Foto[] fotos = (Foto[]) ord.getFotos().toArray(new Foto[0]); for (int k = 0; k < fotos.length - 1; k++) { for (int f = 0; f < (fotos.length - 1) - k; f++) { if (fotos[f].getFecha().after(fotos[f + 1].getFecha()) == true) { Foto aux; aux = fotos[f]; fotos[f] = fotos[f + 1]; fotos[f + 1] = aux; } } } if (fotos.length > 0) reporte.agregaObjeto(reporte.crearImagen( "ordenes/" + ord.getIdOrden() + "/" + fotos[0].getDescripcion(), 0, -60, 120, 80, 0)); else { } //************************datos de la orden**************************** reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Orden:" + ord.getIdOrden(), 164, 550, 0); if (ord.getFecha() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:" + ord.getFecha(), 285, 550, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:", 285, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Compaia:" + ord.getCompania().getIdCompania() + " " + ord.getCompania().getNombre(), 164, 540, 0); if (ord.getSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:" + ord.getSiniestro(), 164, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:", 164, 530, 0); if (ord.getFechaSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F. Siniestro:" + ord.getFechaSiniestro(), 285, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F.Siniestro:", 285, 530, 0); if (ord.getPoliza() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:" + ord.getPoliza(), 164, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:", 164, 520, 0); if (ord.getInciso() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:" + ord.getInciso(), 285, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:", 285, 520, 0); //********************************************************** //************datos de la unidad reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Unidad:" + ord.getTipo().getTipoNombre(), 385, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo:" + ord.getModelo(), 664, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Marca:" + ord.getMarca().getMarcaNombre(), 385, 540, 0); if (ord.getNoEconomico() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:" + ord.getNoEconomico(), 664, 540, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:", 664, 540, 0); if (ord.getNoMotor() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:" + ord.getNoMotor(), 385, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:", 385, 530, 0); if (ord.getNoSerie() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:" + ord.getNoSerie(), 385, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:", 385, 520, 0); //************************************************************* //****************Datos del valuador reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Valuador:", 40, 495, 0); if (ord.getEmpleadoByRLevantamiento() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, ord.getEmpleadoByRLevantamiento().getNombre(), 75, 495, 0); if (ord.getFechaTaller() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Entrega:" + ord.getFechaTaller(), 320, 495, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Entrega: //", 320, 495, 0); if (ord.getFechaCierre() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Cerrado:" + ord.getFechaCierre(), 500, 495, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Cerrado: //", 500, 495, 0); reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("N", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Operacin", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Instruccin Final", font, cabecera, centro, 8, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Descripcion", font, cabecera, centro, 0, 3, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("D/M", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Cam", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Reparar", font, cabecera, centro, 3, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Pintar", font, cabecera, centro, 3, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Min", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Max", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Min", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Max", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); }
From source file:Valuacion.Reportes.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/* w ww . j a v a 2s . c om*/ reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 575, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); String titulo = "Reporte"; if (c_tipo_fecha.getSelectedItem().toString().compareTo("Seleccione") != 0) { titulo += " " + c_tipo_fecha.getSelectedItem().toString(); if (t_fecha1.getText().compareTo("AAAA-MM-DD") != 0) titulo += " del " + t_fecha1.getText(); if (t_fecha2.getText().compareTo("AAAA-MM-DD") != 0) titulo += " al " + t_fecha2.getText(); } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 565, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 575, 0); reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); /*reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" "));*/ //reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; for (int a = 0; a < tabla.getNumberOfColumns(); a++) { tabla.addCell( reporte.celda(t_datos.getColumnName(a), font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); }
From source file:Valuacion.valuacion.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { Session session = HibernateUtil.getSessionFactory().openSession(); try {// w w w .jav a2 s .c o m reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(30, 700, 210, 45, 5); reporte.contenido.roundRectangle(250, 700, 325, 45, 5); //reporte.contenido.roundRectangle(550, 700, 210, 45, 5); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 30, 760, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tabulador de Mano de Obra", 30, 750, 0); //reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "Consulta de Ordenes Filtrado por '"+this.c_filtro.getSelectedItem().toString()+"' ("+this.t_busca.getText()+")", 505, 537, 0); ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); //************************datos de la orden**************************** reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Orden:" + ord.getIdOrden(), 34, 735, 0); if (ord.getFecha() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:" + ord.getFecha(), 155, 735, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:", 155, 735, 0); String clien = ord.getClientes().getNombre(); if (clien.length() > 30) clien = ord.getClientes().getNombre().substring(0, 30); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Cliente:" + clien, 34, 725, 0); if (ord.getSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:" + ord.getSiniestro(), 34, 715, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:", 34, 715, 0); if (ord.getFechaSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F. Siniestro:" + ord.getFechaSiniestro(), 155, 715, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F.Siniestro:", 155, 715, 0); if (ord.getPoliza() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:" + ord.getPoliza(), 34, 705, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:", 34, 705, 0); if (ord.getInciso() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:" + ord.getInciso(), 155, 705, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:", 155, 705, 0); //********************************************************** //************datos de la unidad reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Unidad:" + ord.getTipo().getTipoNombre(), 255, 735, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo:" + ord.getModelo(), 534, 735, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Marca:" + ord.getMarca().getMarcaNombre(), 255, 725, 0); if (ord.getNoEconomico() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:" + ord.getNoEconomico(), 534, 725, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:", 534, 725, 0); if (ord.getNoMotor() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:" + ord.getNoMotor(), 255, 715, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:", 255, 715, 0); if (ord.getNoSerie() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:" + ord.getNoSerie(), 255, 705, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:", 255, 705, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 564, 705, 0); //************************************************************* try { reporte.agregaObjeto(reporte.crearImagen(ord.getCompania().getFoto(), 455, -10, 13)); } catch (Exception e) { } reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); //reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Grupo", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("D/M", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Cam", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Reparar(hr)", font, cabecera, centro, 3, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Pin", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Costo M.O.", font, cabecera, centro, 0, 2, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Min", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Max", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } catch (Exception e) { e.printStackTrace(); } if (session != null) if (session.isOpen()) { session.flush(); session.clear(); session.close(); } }