List of usage examples for com.itextpdf.text BaseColor GRAY
BaseColor GRAY
To view the source code for com.itextpdf.text BaseColor GRAY.
Click Source Link
From source file:ictproject.ReportGenerator.java
private PdfPTable getPaniKoSroth(String name) throws Exception { PdfPTable table = new PdfPTable(5); // 3 columns. table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.setWidths(new int[] { 1, 1, 2, 1, 1 }); table.addCell(getNepaliPhrase("l;=g+="));//"..")); table.addCell(getNepaliPhrase("j8f g+="));//" .")); table.addCell(/*from ww w . j av a 2s . c om*/ getNepaliPhrase("kfgL >f]t ;'Sb} uPsf] cj:yf-clt w]/}%,w]/}$,l7s}#,sd@,5}g!_"));// ? ?? ? ?( ,,,,)")); table.addCell(getNepaliPhrase("kf]v/Lsf] ;+Vof"));// ?")); table.addCell(getNepaliPhrase("s}lkmot"));//")); table.setHeaderRows(2); table.getDefaultCell().setBackgroundColor(null); try { Statement stmt = conn.createStatement(); String sql; String selected = name; sql = "SELECT * from bidamanpanikosrot where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("serialNo"))); table.addCell(numberConverterToUnicode(rs.getString("wardNo"))); table.addCell(numberConverterToUnicode(rs.getString("paniKoSrotCount"))); table.addCell(numberConverterToUnicode(rs.getString("pokharicount"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } table.addCell(getNepaliPhrase("hDdf")); table.addCell(""); table.addCell(""); table.addCell(getSum(name, "pokharicount", "bidamanpanikosrot")); table.addCell(""); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable rogKoBibaran(String name) { PdfPTable table = new PdfPTable(6); // 3 columns. table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(getNepaliPhrase("l;=g+="));//.."); table.addCell(getNepaliPhrase("l;=g+="));//;" "); table.addCell(getNepaliPhrase("aif{-@)^(&)_"));//"?""));///)"); table.addCell(getNepaliPhrase("aif{-@)&)&!_")); table.addCell(getNepaliPhrase("aif{-@)&)&!_")); table.addCell(getNepaliPhrase("s}lkmot")); table.setHeaderRows(1);/* w ww . j av a 2 s. co m*/ table.getDefaultCell().setBackgroundColor(null); try { Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from panijanyarogkabibaran where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("SNo"))); table.addCell(getNepaliPhrase(converter(rs.getString("diseaseName")))); table.addCell(numberConverterToUnicode(rs.getString("year6970"))); table.addCell(numberConverterToUnicode(rs.getString("year7071"))); table.addCell(numberConverterToUnicode(rs.getString("year7172"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable actualBudget(String name, String tableName) { PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(getNepaliPhrase("cfly{s jif{"));//artik barsa table.addCell(getNepaliPhrase("vfg]kfgL-?k}of_"));//khanepani table.addCell(getNepaliPhrase(";/;kmfO-?k}of_"));//sarsafai table.addCell(getNepaliPhrase("hDdf"));//jamma table.addCell(getNepaliPhrase("s}lkmot"));//kaifiyat table.setHeaderRows(1);/*from w ww. j a va 2 s. co m*/ table.getDefaultCell().setBackgroundColor(null); try { Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from " + tableName + " where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(getNepaliPhrase(rs.getString("arthikBarsa"))); table.addCell(numberConverterToUnicode(rs.getString("khanePani"))); table.addCell(numberConverterToUnicode(rs.getString("sarSafai"))); table.addCell(numberConverterToUnicode(rs.getString("total"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } table.addCell(getNepaliPhrase("hDdf"));//jamma table.addCell(getSum(name, "khanePani", tableName)); table.addCell(getSum(name, "sarSafai", tableName)); table.addCell(getSum(name, "total", tableName)); table.addCell(""); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:Inventario.Inventario2.java
public void createDocument(String filename, String extension) throws DocumentException, FileNotFoundException { try {// w w w . j a v a 2 s .com Document document = new Document(PageSize.LETTER, 50, 50, 85, 50); document.addAuthor("Inventario"); document.addTitle("Reporte de Inventario Compra-Venta"); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); writer.setInitialLeading(16); Rectangle rct = new Rectangle(80, 104, 500, 688); writer.setBoxSize("art", rct); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); document.open(); Paragraph parrafo2 = new Paragraph("Reportes de Inventario", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.GRAY)); parrafo2.setAlignment(0); document.add(parrafo2); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.close(); } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;//ww w.j a va 2s . c om @Override protected void done() { // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException { BarcodeEAN barcode = new BarcodeEAN(); barcode.setCodeType(Barcode.EAN8); barcode.setCode(code); PdfPCell cell = new PdfPCell( barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY), true); cell.setPadding(10); return cell; } class ImageContent implements PdfPTableEvent { protected com.itextpdf.text.Image content; public ImageContent(com.itextpdf.text.Image content) { this.content = content; } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { try { PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS]; float x = widths[3][1] + 10; float y = heights[3] - 10 - content.getScaledHeight(); content.setAbsolutePosition(x, y); canvas.addImage(content); } catch (DocumentException e) { throw new ExceptionConverter(e); } } } @Override protected Object doInBackground() throws Exception { // System.err.println(" Roll No Received ....." + rollno); Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(15f, 15f, 15f, 15f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); //DONE BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(Barcode.EAN8); Barcode128 code128 = new Barcode128(); code128.setCode(String.valueOf("123456")); Barcode128 code128_jacket = new Barcode128(); code128_jacket.setCode(String.valueOf("10345")); codeEAN.setCode(String.valueOf("123456")); com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null); // imageEAN.scalePercent(10f); //464f, 725f // imageEAN.setAbsolutePosition(474f, 662f); int i = 1; while (i <= pageno) { doc.newPage(); // cb.addImage(imageRight); // cb.addImage(imageEAN); i++; } com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null); carcode.scaleAbsolute(100f, 35f); carcode.setAbsolutePosition(500f, 600f); writer.addDirectImageSimple(carcode); // cb.addImage(carcode); com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null); carcode2.scaleAbsolute(100f, 35f); carcode2.setAbsolutePosition(450f, 760f); writer.addDirectImageSimple(carcode2); // cb.addImage(carcode2); Image image1 = Image.getInstance("jklogo.gif"); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(99); table.addCell(image1); doc.add(table); table = new PdfPTable(4); table.setWidthPercentage(99); float[] columnWidths = { 6, 2 }; PdfPTable CandidateTable = new PdfPTable(columnWidths); Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall)); PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall)); // DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // String today = formatter.format(cInfo.getDob()); PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall)); PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall)); PdfPCell type = new PdfPCell(new Phrase("Total Time #" + String.valueOf("350.00"), fsmall)); // String scrtoday = formatter.format(cInfo.getScreeningdate()); // System.out.println("Today : " + today); PdfPCell scrdate = new PdfPCell(new Phrase("Laps #" + String.valueOf("4"), fsmall)); PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall)); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); CandidateTable.addCell(rollno); CandidateTable.addCell(cell); CandidateTable.addCell(cname); CandidateTable.addCell(cell); CandidateTable.addCell(dob); CandidateTable.addCell(cell); PdfPTable CandidateOtherTable = new PdfPTable(columnWidths); CandidateOtherTable.addCell(fname); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(scrdate); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(type); CandidateOtherTable.addCell(cell); PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall)); PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall)); PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00 ", fsmall)); race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths); CandidateRaceDetails.addCell(race_start_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_end_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_total_time); CandidateRaceDetails.addCell(cell); PdfPTable tablewith3cells = new PdfPTable(3); //1 St Col for Roll No Name and DOB tablewith3cells.addCell(CandidateTable); //2 nd Col for Father Name sCREEning Date Gurkha tablewith3cells.addCell(CandidateOtherTable); //3rd Col for Barcode to be Printed tablewith3cells.addCell(CandidateRaceDetails); // Setting the Width here to 101 tablewith3cells.setWidthPercentage(99); doc.add(tablewith3cells); PdfPTable userArea = new PdfPTable(1); userArea.setWidthPercentage(99); userArea.addCell(" \n \n Congratulations \n \n "); doc.add(userArea); PdfPTable footerCSBC = new PdfPTable(2); footerCSBC.setWidthPercentage(99); PdfPCell height_box = new PdfPCell(new Phrase("Height \n\n\n", f)); height_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_box = new PdfPCell(new Phrase("Chest \n\n\n", f)); chest_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp \n\n\n", f)); chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup \n\n\n", f)); pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX); //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); footerCSBC.addCell(height_box); footerCSBC.addCell(chest_box); footerCSBC.addCell(chest_exp_box); footerCSBC.addCell(pushup_box); doc.add(footerCSBC); float[] columnWidths_ForBarcode = { 6, 3 }; PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode); // terminalinfo.setWidthPercentage(99); String computername = InetAddress.getLocalHost().getHostName(); System.out.println(computername); PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f)); String UserMatchScore = "\t Barcode\n\n"; PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f)); PdfPCell barcode = new PdfPCell(carcode2); PdfPCell jacketnumber = new PdfPCell(carcode); pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); terminalinfo.addCell(score); terminalinfo.addCell(pcname); terminalinfo.addCell(barcode); terminalinfo.addCell(jacketnumber); doc.add(terminalinfo); PdfPCell eula_notice = new PdfPCell(new Phrase(" ", f)); eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable eula_notice_table = new PdfPTable(1); eula_notice_table.setWidthPercentage(25); eula_notice_table.addCell(eula_notice); doc.add(eula_notice_table); } catch (Exception e) { System.err.println(e.getMessage()); // ConsoleMsg(e.getMessage()); } finally { doc.close(); doc.close(); doc.close(); } //ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); return 0; }
From source file:Operaciones.Destajo.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { Session session = HibernateUtil.getSessionFactory().openSession(); try {//from ww w . j a va2s .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, 480, 720, 30, 5); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); 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, "Hoja de Avance", 160, 570, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 760, 580, 0); Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(ord)); Foto foto = (Foto) session.createCriteria(Foto.class) .add(Restrictions.eq("orden.idOrden", Integer.parseInt(ord))).addOrder(Order.desc("fecha")) .setMaxResults(1).uniqueResult(); if (foto != null) { reporte.agregaObjeto(reporte.crearImagen( "ordenes/" + dato.getIdOrden() + "/" + foto.getDescripcion(), 0, -60, 120, 80, 0)); } else { } //************************datos de la orden**************************** reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Orden:" + dato.getIdOrden(), 164, 550, 0); if (dato.getFecha() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:" + dato.getFecha(), 285, 550, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:", 285, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Compaia:" + dato.getCompania().getIdCompania() + " " + dato.getCompania().getNombre(), 164, 540, 0); if (dato.getSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:" + dato.getSiniestro(), 164, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:", 164, 530, 0); if (dato.getFechaSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F. Siniestro:" + dato.getFechaSiniestro(), 285, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F.Siniestro:", 285, 530, 0); if (dato.getPoliza() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:" + dato.getPoliza(), 164, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:", 164, 520, 0); if (dato.getInciso() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:" + dato.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:" + dato.getTipo().getTipoNombre(), 385, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo:" + dato.getModelo(), 664, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Marca:" + dato.getMarca().getMarcaNombre(), 385, 540, 0); if (dato.getNoEconomico() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:" + dato.getNoEconomico(), 664, 540, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:", 664, 540, 0); if (dato.getNoMotor() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:" + dato.getNoMotor(), 385, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:", 385, 530, 0); if (dato.getNoSerie() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:" + dato.getNoSerie(), 385, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:", 385, 520, 0); //************************************************************* switch (this.global) { case "h": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Hojalateria", 40, 495, 0); break; case "m": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Mecanica", 40, 495, 0); break; case "s": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Suspension", 40, 495, 0); break; case "e": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: electrico", 40, 495, 0); break; case "p": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Pintura", 40, 495, 0); break; } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Empleado:" + t_responsable.getText(), 165, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Asignacin:" + t_asignacion.getText(), 430, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Limite:" + t_limite.getText(), 600, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Monto x Hora: $" + t_monto.getText(), 40, 485, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Horas Totales: " + t_horas.getText(), 165, 485, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Importe a Pagar: $" + t_importe.getText(), 600, 485, 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(" ")); 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("Fecha Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("% de Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Importe Pagado", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Notas", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) { session.flush(); session.clear(); session.close(); } }
From source file:org.com.controller.ProductController.java
@RequestMapping(value = "/repProduct", method = RequestMethod.GET) public void productReport(Model m, HttpServletResponse response, HttpServletRequest request, OutputStream outputStream) throws Exception { String name = "ProductReport-"; Date d = new Date(); name = name + d.toString() + ".pdf"; response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=" + name); Rectangle pagesize = new Rectangle(216f, 720f); Document document = new Document(PageSize.A4); PdfWriter.getInstance(document, outputStream); document.open();/* ww w . jav a2 s.co m*/ document.addTitle("PRODUCT DETAILSA REPORT"); document.add(new Paragraph("PRODUCT DETAILSA REPORT ", FontFactory.getFont(FontFactory.HELVETICA, 28, BaseColor.CYAN))); document.add(new Paragraph("DATE: " + new Date())); document.add(new Paragraph("-------------------------------------------------------- ")); document.add(new Paragraph(" ")); ProductDaoImpl pdi = new ProductDaoImpl(); PdfPTable table = new PdfPTable(4); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell("ID"); table.addCell("TITLE"); table.addCell("PUBLISHER"); table.addCell("PRICE"); ArrayList<ProductTable> list = pdi.getAllProduct(); for (ProductTable u : list) { table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(u.getPid().toString()); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(u.getPname()); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(u.getPublisher()); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(u.getSprice().toString()); } document.add(table); document.close(); }
From source file:org.javad.stamp.pdf.SetTenant.java
License:Apache License
protected void drawSeparator(PdfContentByte content, float x, float y, float width, float height) { float sx = (getOrientation() == Orientation.HORIZONTAL) ? x : x + PdfUtil.convertFromMillimeters(getPadding() + 2); float dx = (getOrientation() == Orientation.HORIZONTAL) ? x : x + width - PdfUtil.convertFromMillimeters(getPadding() + 2); float sy = (getOrientation() == Orientation.HORIZONTAL) ? y + PdfUtil.convertFromMillimeters(getVerticalPadding() + 2) : y;/*from ww w . java 2s.c o m*/ float dy = (getOrientation() == Orientation.HORIZONTAL) ? y + height - PdfUtil.convertFromMillimeters(getVerticalPadding() + 2) : y; content.setLineWidth(0.5f); content.setColorStroke(BaseColor.GRAY); content.moveTo(sx, sy); content.setLineDash(5.0f, 2.0f, 0.0f); content.lineTo(dx, dy); content.stroke(); content.setLineDash(1.0f, 0.0f, 0.0f); }
From source file:org.javad.stamp.pdf.StampBox.java
License:Apache License
/** * Will draw the bisect lines within the content are of the output * rectangle./*from ww w . ja v a 2s.com*/ * * @param content * @param rect */ @SuppressWarnings("incomplete-switch") void drawBisect(PdfContentByte content, OutputBounds rect) { content.setLineWidth(0.5f); content.setColorStroke(BaseColor.GRAY); float dx1 = 0.0f; float dx2 = 0.0f; float dy1 = 0.0f; float dy2 = 0.0f; float xp = (int) PdfUtil.convertFromMillimeters(getPadding() + 2); float yp = (int) PdfUtil.convertFromMillimeters(getVerticalPadding() + 2); switch (bisect) { case top_left: dx1 = xp; dy1 = rect.height - yp; dx2 = rect.width - xp; dy2 = yp; break; case top_right: dx1 = xp; dy1 = yp; dx2 = rect.width - xp; dy2 = rect.height - yp; break; case vertical: dx1 = rect.width / 2; dy1 = yp; dx2 = dx1; dy2 = rect.height - yp; } content.moveTo(rect.x + dx1, rect.y + dy1); content.setLineDash(5.0f, 2.0f, 0.0f); content.lineTo(rect.x + dx2, rect.y + dy2); content.stroke(); content.setLineDash(1.0f, 0.0f, 0.0f); }
From source file:pdf.PDFDesign.java
public PdfPTable createPriceTable(List<Item> itemList) throws DocumentException, IOException { PdfPTable table = new PdfPTable(nColumns); table.setWidthPercentage(100.0f);/* ww w . j av a2 s .c o m*/ //PdfContentByte cb = writer.getDirectContent(); for (int i = 0; i < itemList.size(); i++) { Item item = itemList.get(i); //cell.setBorder(0); //BarcodeEAN code = new BarcodeEAN(); //code.setCode(item.getBarCode()); //code.setGuardBars(false); //Image im = code.createImageWithBarcode(cb, BaseColor.BLACK, BaseColor.BLACK); //p.add(im);//new Chunk(im,0.5f,0.5f)); PdfPTable innerTable = new PdfPTable(1); Paragraph p1 = new Paragraph(); p1.setFont(titleLineFont); String t = item.getTitle(); String[] split = t.split("//"); //System.out.println(t); for (String split1 : split) { p1.add(split1 + "\n"); } PdfPCell innercCell1 = new PdfPCell(p1); innercCell1.setLeading(11f, 0f); innercCell1.setBorder(0); if (t.contains("//") && (size.equals("4x6") || size.equals("4x7") || size.equals("5x6") || size.equals("5x7"))) { innercCell1.setFixedHeight(titleLineFixedHeight); } else { innercCell1.setFixedHeight(15.0f); } //innercCell1.setFixedHeight(titleLineFixedHeight); innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p2 = new Paragraph(); p2.setFont(amountAndPriceLabelLineFont); p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n"); PdfPCell innercCell2 = new PdfPCell(p2); innercCell2.setLeading(5f + textFontInc, 0f); innercCell2.setBorder(0); innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p3 = new Paragraph(); p3.setFont(bigPriceNumberFont); p3.add(item.getPrice().substring(0, item.getPrice().length() - 3)); p3.setFont(decimalPriceNumberFont); p3.add(item.getPrice().substring(item.getPrice().length() - 3, item.getPrice().length())); p3.setFont(unitPriceLineFont); p3.add(item.getCurrency()); PdfPCell innercCell3 = new PdfPCell(p3); if (styleName.equals("style6") /*&& (size.equals("4x7") || size.equals("4x6"))*/) { innercCell3 = new PdfPCell(createLine3Table(item, 45 + priceFontInc, 20, 15)); } innercCell3.setBorder(0); innercCell3.setLeading(bigPriceNumberLeading, 0f); innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p4 = new Paragraph(); p4.setFont(unitPriceLineFont); p4.add("Cena za " + item.getXAmount() + item.getXUnit() + ": " + item.getUnitPrice() + " " + item.getCurrency()); PdfPCell innercCell4 = new PdfPCell(p4); innercCell4.setBorder(0); innercCell4.setLeading(5f + textFontInc, 0f); innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER); innerTable.addCell(innercCell1); innerTable.addCell(innercCell2); innerTable.addCell(innercCell3); innerTable.addCell(innercCell4); PdfPCell cell = new PdfPCell(innerTable); cell.setFixedHeight(cellHeight); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderColor(BaseColor.GRAY); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } int remainder = itemList.size() % nColumns; if (remainder != 0) { remainder = nColumns - remainder; } for (int i = 0; i < remainder; i++) { PdfPCell c = new PdfPCell(new Phrase(" ")); c.setBorderColor(BaseColor.GRAY); table.addCell(c); } return table; }