List of usage examples for com.itextpdf.text Element ALIGN_CENTER
int ALIGN_CENTER
To view the source code for com.itextpdf.text Element ALIGN_CENTER.
Click Source Link
From source file:com.microware.intrahealth.Createpdf2.java
public static Paragraph mypara(String ab, int flag) { Paragraph preface1 = new Paragraph(ab, subFont); if (flag == 1) preface1.setAlignment(Element.ALIGN_CENTER); if (flag == 2) preface1.setAlignment(Element.ALIGN_LEFT); if (flag == 3) preface1.setAlignment(Element.ALIGN_RIGHT); return preface1; }
From source file:com.microware.intrahealth.Createpdf2.java
private static void createTable(Paragraph preface, String[] Header, ArrayList<HashMap<String, String>> data) throws BadElementException { Context _con = null;/*from w w w .j a v a 2 s.c om*/ // PdfPTable table = new PdfPTable(new float[] { 2, 1 }); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPTable table = new PdfPTable(new float[] { 1, 3, 3, 5, 5, 2, 3, 2, 2, 2 }); table.setHorizontalAlignment(Element.ALIGN_LEFT); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); } // table.addCell("Value"); // table.addCell("Location"); table.setHeaderRows(1); // PdfPCell c1 = new PdfPCell(new Phrase("Text",smallBold)); // c1.getBorder(); // c1.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(c1); // // c1 = new PdfPCell(new Phrase("Value",smallBold)); // c1.getBorder(); // c1.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(c1); // // table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); if (j == 0) { cells[j].setHorizontalAlignment(Element.ALIGN_LEFT); } else { cells[j].setHorizontalAlignment(Element.ALIGN_CENTER); } } dataprovider = new DataProvider(_con); // // Font f = FontFactory.getFont(getFilesDir() + "/" + HINDI_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // PdfPCell eCell = new PdfPCell(new Phrase(entry, f)); for (int i = 0; i < data.size(); i++) { Phrase phrase = new Phrase(); phrase.add(new Chunk(data.get(i).get("ASHAName"), subFont)); table.addCell(String.valueOf((i + 1))); table.addCell(data.get(i).get("ASHAName")); table.addCell(data.get(i).get("VillageName")); table.addCell(data.get(i).get("PWName")); table.addCell(data.get(i).get("MotherMCTSID")); table.addCell(data.get(i).get("HusbandName")); table.addCell(Validate.changeDateFormat(data.get(i).get("CheckupVisitDate"))); table.addCell(data.get(i).get("DangerSign")); table.addCell(data.get(i).get("CheckupPlace")); table.addCell(""); PdfPCell[] cells1 = table.getRow(i + 1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); // cells1[1].setHorizontalAlignment(Element.ALIGN_CENTER); // cells1[2].setHorizontalAlignment(Element.ALIGN_CENTER); } // table.addCell("Colour"); // table.addCell("Hazen Unit"); // table.addCell("1.2"); // table.addCell("Turbidity"); // table.addCell("NTU"); // table.addCell("2.3"); preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable1(Paragraph preface, String[] Header, String[] Text, String[] Value) throws BadElementException { Context _con = null;/*from w ww .java2 s .co m*/ PdfPTable table = new PdfPTable(new float[] { 2, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); if (j == 0) { cells[j].setHorizontalAlignment(Element.ALIGN_LEFT); } else { cells[j].setHorizontalAlignment(Element.ALIGN_CENTER); } } dataprovider = new DataProvider(_con); if (Text.length == Value.length) { for (int i = 0; i < Value.length; i++) { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text[i], subFont)); table.addCell(phrase); table.addCell(Value[i]); PdfPCell[] cells1 = table.getRow(i + 1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); cells1[1].setHorizontalAlignment(Element.ALIGN_CENTER); } } else { for (int i = 0; i < Value.length; i++) { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text[i], subFont)); table.addCell(phrase); table.addCell(""); PdfPCell[] cells1 = table.getRow(i + 1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); } } preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable2(Paragraph preface, String[] Header, String[] Text, String[] Source, String[] Value) throws BadElementException { Context _con = null;/*from w ww . j a va 2s . c o m*/ PdfPTable table = new PdfPTable(new float[] { 2, 1, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); if (j == 0) { cells[j].setHorizontalAlignment(Element.ALIGN_LEFT); } else { cells[j].setHorizontalAlignment(Element.ALIGN_CENTER); } } dataprovider = new DataProvider(_con); if (Text.length == Value.length) { for (int i = 0; i < Value.length; i++) { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text[i], subFont)); table.addCell(phrase); table.addCell(Source[i]); table.addCell(Value[i]); PdfPCell[] cells1 = table.getRow(i + 1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); cells1[1].setHorizontalAlignment(Element.ALIGN_CENTER); cells1[2].setHorizontalAlignment(Element.ALIGN_CENTER); } } else { for (int i = 0; i < Value.length; i++) { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text[i], subFont)); table.addCell(phrase); table.addCell(""); table.addCell(""); PdfPCell[] cells1 = table.getRow(i + 1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); } } preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable3(Paragraph preface, String[] Header, String[] Text, String[] Value, String[] Value1, String[] Value2) throws BadElementException { Context _con = null;/*from www . j a va2 s . com*/ PdfPTable table = new PdfPTable(new float[] { 1, 2, 1, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); if (j == 0) { cells[j].setHorizontalAlignment(Element.ALIGN_LEFT); } else { cells[j].setHorizontalAlignment(Element.ALIGN_CENTER); } } dataprovider = new DataProvider(_con); if (Text != null && Text.length > 0) { if (Text.length == Value.length) { for (int i = 0; i < Value.length; i++) { table.addCell(Text[i]); table.addCell(Value[i]); table.addCell(Value1[i]); table.addCell(Value2[i]); } } else { for (int i = 0; i < Value.length; i++) { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } } } else { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable4(Paragraph preface, String[] Header, String Text, String Value) throws BadElementException { Context _con = null;// ww w. j a va2 s .c o m PdfPTable table = new PdfPTable(new float[] { 1, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); if (j == 0) { cells[j].setHorizontalAlignment(Element.ALIGN_LEFT); } else { cells[j].setHorizontalAlignment(Element.ALIGN_CENTER); } } dataprovider = new DataProvider(_con); if (Text.length() > 0 && Value.length() > 0) { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text, subFont)); table.addCell(phrase); table.addCell(Value); PdfPCell[] cells1 = table.getRow(1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); cells1[1].setHorizontalAlignment(Element.ALIGN_CENTER); } else { Phrase phrase = new Phrase(); phrase.add(new Chunk(Text, subFont)); table.addCell(phrase); table.addCell(""); PdfPCell[] cells1 = table.getRow(1).getCells(); cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT); } preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable5(Paragraph preface, String[] Header, String[] Text, String[] Value, String[] Value1, String[] Value2, String[] Value3) throws BadElementException { Context _con = null;//from w w w.j a v a2 s . c o m PdfPTable table = new PdfPTable(new float[] { 1, 2, 1, 1, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); } dataprovider = new DataProvider(_con); if (Text != null && Text.length > 0) { if (Text.length == Value.length) { for (int i = 0; i < Value.length; i++) { table.addCell(Text[i]); table.addCell(Value[i]); table.addCell(Value1[i]); table.addCell(Value2[i]); table.addCell(Value3[i]); } } else { for (int i = 0; i < Value.length; i++) { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } } } else { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } preface.add(table); }
From source file:com.microware.intrahealth.Createpdfall.java
private static void createTable6(Paragraph preface, String[] Header, String[] Text, String[] Value, String[] Value1, String[] Value2, String[] Value3, String[] Value4) throws BadElementException { Context _con = null;// ww w.j a v a 2 s. c om PdfPTable table = new PdfPTable(new float[] { 1, 2, 1, 1, 1, 1 }); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int i = 0; i < Header.length; i++) { // table.addCell(new PdfPCell(new Phrase(Header[i], smallBold))); PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold)); c1.getBorder(); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); } table.setHeaderRows(1); PdfPCell[] cells = table.getRow(0).getCells(); for (int j = 0; j < cells.length; j++) { cells[j].setBackgroundColor(new BaseColor(0, 85, 133)); } dataprovider = new DataProvider(_con); if (Text != null && Text.length > 0) { if (Text.length == Value.length) { for (int i = 0; i < Value.length; i++) { table.addCell(Text[i]); table.addCell(Value[i]); table.addCell(Value1[i]); table.addCell(Value2[i]); table.addCell(Value3[i]); table.addCell(Value4[i]); } } else { for (int i = 0; i < Value.length; i++) { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } } } else { table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); } preface.add(table); }
From source file:com.mim.controllers.HomeCtrl.java
private void ordenReport(Document document, Lugar lugar) throws BadElementException, DocumentException, IOException { document.addTitle(current.getNumeroOrden()); // step 3//ww w.ja va 2s. c o m // step 4 PdfPTable table = new PdfPTable(8); //LEFT HEADER CONTENT PdfPTable leftHeaderTable = new PdfPTable(4); PdfPCell imgCell = new PdfPCell(); imgCell.setBorder(Rectangle.NO_BORDER); imgCell.setPaddingTop(14); imgCell.setColspan(1); imgCell.setFixedHeight(25); //Image img = Image.getInstance("/opt/shared/home/logo.png"); Image img = Image.getInstance("http://mimconstructions.com/img/mim%20trendy.png"); imgCell.addElement(img); PdfPCell reportTitleCell = new PdfPCell(new Paragraph("REPORTE MANTENIMIENTO")); reportTitleCell.setPaddingTop(14); reportTitleCell.setPaddingLeft(20); reportTitleCell.setColspan(3); reportTitleCell.setBorder(Rectangle.NO_BORDER); leftHeaderTable.addCell(imgCell); leftHeaderTable.addCell(reportTitleCell); PdfPCell leftHeaderMainCell = new PdfPCell(leftHeaderTable); leftHeaderMainCell.setColspan(4); //END CONTENT //RIGHT HEADER WITH INFO ABOUT ORDER AND DATE PdfPTable infHeader = new PdfPTable(3); PdfPCell numberOrderLabel = new PdfPCell(new Paragraph("#ORDEN")); numberOrderLabel.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderLabel.setColspan(1); String numeroOrden = null; if (current.getNumeroOrden() != null) { numeroOrden = current.getNumeroOrden(); } else { numeroOrden = current.getActividad(); } PdfPCell numberOrderValue = new PdfPCell(new Paragraph(numeroOrden)); numberOrderValue.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderValue.setColspan(2); PdfPCell prioridadLabel = new PdfPCell(new Paragraph("PRIORIDAD")); prioridadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadLabel.setColspan(1); PdfPCell prioridadValue = new PdfPCell(new Paragraph(current.getPrioridad())); prioridadValue.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadValue.setColspan(2); PdfPCell fechaLabel = new PdfPCell(new Paragraph("FECHA")); fechaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); fechaLabel.setColspan(1); //dd-MM-yyyy SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy"); Date startDate = current.getStartDate(); if (startDate == null) { startDate = new Date(); } String fecha = format1.format(startDate); PdfPCell fechaValue = new PdfPCell(new Paragraph(fecha)); fechaValue.setHorizontalAlignment(Element.ALIGN_CENTER); fechaValue.setColspan(2); infHeader.addCell(numberOrderLabel); infHeader.addCell(numberOrderValue); infHeader.addCell(prioridadLabel); infHeader.addCell(prioridadValue); infHeader.addCell(fechaLabel); infHeader.addCell(fechaValue); PdfPCell cellHeaderRight = new PdfPCell(infHeader); cellHeaderRight.setColspan(4); //END HEADER PdfPCell areaLabel = new PdfPCell(new Paragraph("AREA")); areaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); areaLabel.setVerticalAlignment(Element.ALIGN_CENTER); areaLabel.setFixedHeight(30); areaLabel.setPaddingTop(5); areaLabel.setColspan(2); PdfPCell actividadLabel = new PdfPCell(new Paragraph("ACTIVIDAD")); actividadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); actividadLabel.setFixedHeight(30); actividadLabel.setVerticalAlignment(Element.ALIGN_CENTER); actividadLabel.setPaddingTop(5); actividadLabel.setColspan(3); PdfPCell responsableLabel = new PdfPCell(new Paragraph("RESPONSABLE DE OPERACION")); responsableLabel.setHorizontalAlignment(Element.ALIGN_CENTER); responsableLabel.setFixedHeight(30); responsableLabel.setVerticalAlignment(Element.ALIGN_CENTER); responsableLabel.setPaddingTop(5); responsableLabel.setColspan(3); String area; if (lugar.getNombre().contains("linea")) { area = "envasado"; } else if (lugar.getNombre().contains("otro")) { area = "Tecate 500"; } else if (lugar.getNombre().contains("PD")) { area = "concretos"; } else if (lugar.getNombre().contains("planta agua")) { area = "cerveceria"; } else { area = "elaboracion"; } PdfPCell areaValor = new PdfPCell(new Paragraph(area)); areaValor.setFixedHeight(25); areaValor.setHorizontalAlignment(Element.ALIGN_CENTER); areaValor.setColspan(2); PdfPCell actividadValor = new PdfPCell(new Paragraph(current.getActividad())); actividadValor.setHorizontalAlignment(Element.ALIGN_CENTER); actividadValor.setFixedHeight(25); actividadValor.setColspan(3); PdfPCell responsableValor = new PdfPCell(new Paragraph(current.getEncargado())); responsableValor.setHorizontalAlignment(Element.ALIGN_CENTER); responsableValor.setFixedHeight(25); responsableValor.setColspan(3); // 2 FILAS PARA INF. EQUIPO Y LUGAR PdfPCell equipoLabel = new PdfPCell(new Paragraph("EQUIPO/CONJUNTO")); equipoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); equipoLabel.setVerticalAlignment(Element.ALIGN_CENTER); equipoLabel.setFixedHeight(30); equipoLabel.setPaddingTop(5); equipoLabel.setColspan(4); PdfPCell lugarLabel = new PdfPCell(new Paragraph("LUGAR")); lugarLabel.setHorizontalAlignment(Element.ALIGN_CENTER); lugarLabel.setFixedHeight(30); lugarLabel.setVerticalAlignment(Element.ALIGN_CENTER); lugarLabel.setPaddingTop(5); lugarLabel.setColspan(4); String numeroEquipo = null; if (equipo.getNumeroEquipo() != null) { numeroEquipo = equipo.getNumeroEquipo(); } else { numeroEquipo = "n/a"; } PdfPCell equipoValor = new PdfPCell(new Paragraph(numeroEquipo)); equipoValor.setHorizontalAlignment(Element.ALIGN_CENTER); equipoValor.setFixedHeight(25); equipoValor.setColspan(4); PdfPCell lugarValor = new PdfPCell(new Paragraph(lugar.getNombre())); lugarValor.setHorizontalAlignment(Element.ALIGN_CENTER); lugarValor.setFixedHeight(25); lugarValor.setColspan(4); //END INFO EQUIPO // 4 ROW and 5 ROW PdfPCell descripcionLabel = new PdfPCell(new Paragraph("DESCRIPCION")); descripcionLabel.setPadding(12); descripcionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); descripcionLabel.setColspan(8); PdfPCell descripcionValor = new PdfPCell(new Paragraph(current.getDescripcion())); descripcionValor.setPadding(10); descripcionValor.setColspan(8); //END ROWS //ROW BEFORE HISTORIAL_DETALLES PdfPCell historialLabel = new PdfPCell(new Paragraph("OBSERVACIONES")); historialLabel.setPadding(12); historialLabel.setHorizontalAlignment(Element.ALIGN_CENTER); historialLabel.setColspan(8); //END HISTORIAL table.addCell(leftHeaderMainCell); table.addCell(cellHeaderRight); table.addCell(areaLabel); table.addCell(actividadLabel); table.addCell(responsableLabel); table.addCell(areaValor); table.addCell(actividadValor); table.addCell(responsableValor); table.addCell(equipoLabel); table.addCell(lugarLabel); table.addCell(equipoValor); table.addCell(lugarValor); table.addCell(descripcionLabel); table.addCell(descripcionValor); List<HistorialDetalles> observaciones = hisFacade.findAllByOrder(current.getIdorden()); if (observaciones != null) { if (observaciones.size() > 0) { table.addCell(historialLabel); //LOOP HISTORIAL_DETALLES for (int i = 0; i < observaciones.size(); i++) { HistorialDetalles historial = observaciones.get(i); PdfPCell paramCell = new PdfPCell(); paramCell.setColspan(3); paramCell.addElement(new Paragraph(historial.getParametro())); paramCell.setVerticalAlignment(Element.ALIGN_CENTER); paramCell.setPaddingLeft(10); paramCell.setPaddingBottom(10); PdfPCell valueParamCell = new PdfPCell(); valueParamCell.setColspan(5); valueParamCell.setPaddingLeft(10); valueParamCell.setVerticalAlignment(Element.ALIGN_CENTER); valueParamCell.addElement(new Paragraph(historial.getValor())); valueParamCell.setPaddingBottom(10); if (historial.getValor() != null) { if (historial.getValor().length() > 0) { table.addCell(paramCell); table.addCell(valueParamCell); } } } } } //END LOOP HISTORIAL // FIRST ROWS OF FOTOGRAPHIC REPORT PdfPCell pasoLabel = new PdfPCell(new Paragraph("PASO")); pasoLabel.setFixedHeight(20); pasoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); pasoLabel.setColspan(1); PdfPCell accionLabel = new PdfPCell(new Paragraph("ACCION")); accionLabel.setFixedHeight(20); accionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); accionLabel.setColspan(3); PdfPCell imagenLabel = new PdfPCell(new Paragraph("IMAGENES")); imagenLabel.setFixedHeight(20); imagenLabel.setHorizontalAlignment(Element.ALIGN_CENTER); imagenLabel.setColspan(4); //END ROWS PdfPTable table2 = new PdfPTable(8); //ROW BEFORE HISTORIAL_DETALLES PdfPCell headerPictures = new PdfPCell(new Paragraph("PROCEDIMIENTO")); headerPictures.setPadding(12); headerPictures.setHorizontalAlignment(Element.ALIGN_CENTER); headerPictures.setColspan(8); table2.addCell(headerPictures); //END HISTORIAL table2.addCell(pasoLabel); table2.addCell(accionLabel); table2.addCell(imagenLabel); //fotos loop List<Fotos> fotos = fotoFacade.findAllByOrder(current.getIdorden()); for (int i = 0; i < fotos.size(); i++) { Fotos foto = fotos.get(i); PdfPCell pasoVal = new PdfPCell(new Paragraph(String.valueOf(i))); pasoVal.setHorizontalAlignment(Element.ALIGN_CENTER); pasoVal.setColspan(1); PdfPCell detail = new PdfPCell(new Paragraph(foto.getTitulo())); detail.setPadding(5); detail.setBorder(Rectangle.NO_BORDER); PdfPCell accionVal = new PdfPCell(); accionVal.addElement(new Paragraph(foto.getDescripcion())); accionVal.setHorizontalAlignment(Element.ALIGN_CENTER); accionVal.setBorder(Rectangle.NO_BORDER); //accionVal.setColspan(3); PdfPTable infoTable = new PdfPTable(1); infoTable.addCell(detail); infoTable.addCell(accionVal); PdfPCell infiCell = new PdfPCell(); infiCell.setColspan(3); infiCell.addElement(infoTable); //Table collumn //System.getenv("OPENSHIFT_DATA_DIR") + "imagenes/" + name) //Image imgFoto = Image.getInstance("http://mantenimiento-contactres.rhcloud.com/MantenimientoRest/webresources/com.mim.entities.fotos/api/" + foto.getIdfotos()); String archivo = foto.getArchivo(); String[] split = archivo.split("/"); int size = split.length; final String name = split[size - 1]; System.out.println("Valor " + name); Image imgFoto = Image.getInstance("/opt/shared/home/" + "imagenes/" + name); PdfPTable imagenTable = new PdfPTable(1); PdfPCell fotoCell = new PdfPCell(); fotoCell.setColspan(1); fotoCell.addElement(imgFoto); fotoCell.setFixedHeight(310); fotoCell.setHorizontalAlignment(Element.ALIGN_CENTER); fotoCell.setBorder(Rectangle.NO_BORDER); imagenTable.addCell(fotoCell); PdfPCell imagenVal = new PdfPCell(); imagenVal.setColspan(4); imagenVal.addElement(imagenTable); table2.addCell(pasoVal); table2.addCell(infiCell); table2.addCell(imagenVal); } //end loop //table.addCell(tiempoLabel); document.add(table); document.newPage(); document.add(table2); }
From source file:com.mim.controllers.OrdenCtrl.java
private void ordenReport(Document document, Lugar lugar) throws BadElementException, DocumentException, IOException { document.addTitle(current.getNumeroOrden()); // step 3//from w w w. ja va 2 s . co m // step 4 PdfPTable table = new PdfPTable(8); //LEFT HEADER CONTENT PdfPTable leftHeaderTable = new PdfPTable(4); PdfPCell imgCell = new PdfPCell(); imgCell.setBorder(Rectangle.NO_BORDER); imgCell.setPaddingTop(14); imgCell.setColspan(1); imgCell.setFixedHeight(25); //Image img = Image.getInstance("/opt/shared/home/logo.png"); Image img = Image.getInstance("http://mimconstructions.com/img/mim%20trendy.png"); imgCell.addElement(img); PdfPCell reportTitleCell = new PdfPCell(new Paragraph("REPORTE MANTENIMIENTO")); reportTitleCell.setPaddingTop(14); reportTitleCell.setPaddingLeft(20); reportTitleCell.setColspan(3); reportTitleCell.setBorder(Rectangle.NO_BORDER); leftHeaderTable.addCell(imgCell); leftHeaderTable.addCell(reportTitleCell); PdfPCell leftHeaderMainCell = new PdfPCell(leftHeaderTable); leftHeaderMainCell.setColspan(4); //END CONTENT //RIGHT HEADER WITH INFO ABOUT ORDER AND DATE PdfPTable infHeader = new PdfPTable(3); PdfPCell numberOrderLabel = new PdfPCell(new Paragraph("#ORDEN")); numberOrderLabel.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderLabel.setColspan(1); String numeroOrden = null; if (current.getNumeroOrden() != null) { numeroOrden = current.getNumeroOrden(); } else { numeroOrden = current.getActividad(); } PdfPCell numberOrderValue = new PdfPCell(new Paragraph(numeroOrden)); numberOrderValue.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderValue.setColspan(2); PdfPCell prioridadLabel = new PdfPCell(new Paragraph("PRIORIDAD")); prioridadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadLabel.setColspan(1); PdfPCell prioridadValue = new PdfPCell(new Paragraph(current.getPrioridad())); prioridadValue.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadValue.setColspan(2); PdfPCell fechaLabel = new PdfPCell(new Paragraph("FECHA")); fechaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); fechaLabel.setColspan(1); //dd-MM-yyyy SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy"); Date startDate = current.getStartDate(); if (startDate == null) { startDate = new Date(); } String fecha = format1.format(startDate); PdfPCell fechaValue = new PdfPCell(new Paragraph(fecha)); fechaValue.setHorizontalAlignment(Element.ALIGN_CENTER); fechaValue.setColspan(2); infHeader.addCell(numberOrderLabel); infHeader.addCell(numberOrderValue); infHeader.addCell(prioridadLabel); infHeader.addCell(prioridadValue); infHeader.addCell(fechaLabel); infHeader.addCell(fechaValue); PdfPCell cellHeaderRight = new PdfPCell(infHeader); cellHeaderRight.setColspan(4); //END HEADER PdfPCell areaLabel = new PdfPCell(new Paragraph("AREA")); areaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); areaLabel.setVerticalAlignment(Element.ALIGN_CENTER); areaLabel.setFixedHeight(30); areaLabel.setPaddingTop(5); areaLabel.setColspan(2); PdfPCell actividadLabel = new PdfPCell(new Paragraph("ACTIVIDAD")); actividadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); actividadLabel.setFixedHeight(30); actividadLabel.setVerticalAlignment(Element.ALIGN_CENTER); actividadLabel.setPaddingTop(5); actividadLabel.setColspan(3); PdfPCell responsableLabel = new PdfPCell(new Paragraph("RESPONSABLE DE OPERACION")); responsableLabel.setHorizontalAlignment(Element.ALIGN_CENTER); responsableLabel.setFixedHeight(30); responsableLabel.setVerticalAlignment(Element.ALIGN_CENTER); responsableLabel.setPaddingTop(5); responsableLabel.setColspan(3); PdfPCell areaValor = new PdfPCell(new Paragraph("concretera")); areaValor.setFixedHeight(25); areaValor.setHorizontalAlignment(Element.ALIGN_CENTER); areaValor.setColspan(2); PdfPCell actividadValor = new PdfPCell(new Paragraph(current.getActividad())); actividadValor.setHorizontalAlignment(Element.ALIGN_CENTER); actividadValor.setFixedHeight(25); actividadValor.setColspan(3); PdfPCell responsableValor = new PdfPCell(new Paragraph(current.getEncargado())); responsableValor.setHorizontalAlignment(Element.ALIGN_CENTER); responsableValor.setFixedHeight(25); responsableValor.setColspan(3); // 2 FILAS PARA INF. EQUIPO Y LUGAR PdfPCell equipoLabel = new PdfPCell(new Paragraph("EQUIPO/CONJUNTO")); equipoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); equipoLabel.setVerticalAlignment(Element.ALIGN_CENTER); equipoLabel.setFixedHeight(30); equipoLabel.setPaddingTop(5); equipoLabel.setColspan(4); PdfPCell lugarLabel = new PdfPCell(new Paragraph("LUGAR")); lugarLabel.setHorizontalAlignment(Element.ALIGN_CENTER); lugarLabel.setFixedHeight(30); lugarLabel.setVerticalAlignment(Element.ALIGN_CENTER); lugarLabel.setPaddingTop(5); lugarLabel.setColspan(4); String numeroEquipo = null; if (equipo.getNumeroEquipo() != null) { numeroEquipo = equipo.getNumeroEquipo(); } else { numeroEquipo = "n/a"; } PdfPCell equipoValor = new PdfPCell(new Paragraph(numeroEquipo)); equipoValor.setHorizontalAlignment(Element.ALIGN_CENTER); equipoValor.setFixedHeight(25); equipoValor.setColspan(4); PdfPCell lugarValor = new PdfPCell(new Paragraph(lugar.getNombre())); lugarValor.setHorizontalAlignment(Element.ALIGN_CENTER); lugarValor.setFixedHeight(25); lugarValor.setColspan(4); //END INFO EQUIPO // 4 ROW and 5 ROW PdfPCell descripcionLabel = new PdfPCell(new Paragraph("DESCRIPCION")); descripcionLabel.setPadding(12); descripcionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); descripcionLabel.setColspan(8); PdfPCell descripcionValor = new PdfPCell(new Paragraph(current.getDescripcion())); descripcionValor.setPadding(10); descripcionValor.setColspan(8); //END ROWS //ROW BEFORE HISTORIAL_DETALLES PdfPCell historialLabel = new PdfPCell(new Paragraph("OBSERVACIONES")); historialLabel.setPadding(12); historialLabel.setHorizontalAlignment(Element.ALIGN_CENTER); historialLabel.setColspan(8); //END HISTORIAL table.addCell(leftHeaderMainCell); table.addCell(cellHeaderRight); table.addCell(areaLabel); table.addCell(actividadLabel); table.addCell(responsableLabel); table.addCell(areaValor); table.addCell(actividadValor); table.addCell(responsableValor); table.addCell(equipoLabel); table.addCell(lugarLabel); table.addCell(equipoValor); table.addCell(lugarValor); table.addCell(descripcionLabel); table.addCell(descripcionValor); List<HistorialDetalles> observaciones = hisFacade.findAllByOrder(current.getIdorden()); if (observaciones != null) { if (observaciones.size() > 0) { table.addCell(historialLabel); //LOOP HISTORIAL_DETALLES for (int i = 0; i < observaciones.size(); i++) { HistorialDetalles historial = observaciones.get(i); PdfPCell paramCell = new PdfPCell(); paramCell.setColspan(3); paramCell.addElement(new Paragraph(historial.getParametro())); paramCell.setVerticalAlignment(Element.ALIGN_CENTER); paramCell.setPaddingLeft(10); paramCell.setPaddingBottom(10); PdfPCell valueParamCell = new PdfPCell(); valueParamCell.setColspan(5); valueParamCell.setPaddingLeft(10); valueParamCell.setVerticalAlignment(Element.ALIGN_CENTER); valueParamCell.addElement(new Paragraph(historial.getValor())); valueParamCell.setPaddingBottom(10); table.addCell(paramCell); table.addCell(valueParamCell); } } } //END LOOP HISTORIAL // FIRST ROWS OF FOTOGRAPHIC REPORT PdfPCell pasoLabel = new PdfPCell(new Paragraph("PASO")); pasoLabel.setFixedHeight(20); pasoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); pasoLabel.setColspan(1); PdfPCell accionLabel = new PdfPCell(new Paragraph("ACCION")); accionLabel.setFixedHeight(20); accionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); accionLabel.setColspan(3); PdfPCell imagenLabel = new PdfPCell(new Paragraph("IMAGENES")); imagenLabel.setFixedHeight(20); imagenLabel.setHorizontalAlignment(Element.ALIGN_CENTER); imagenLabel.setColspan(4); //END ROWS PdfPTable table2 = new PdfPTable(8); //ROW BEFORE HISTORIAL_DETALLES PdfPCell headerPictures = new PdfPCell(new Paragraph("PROCEDIMIENTO")); headerPictures.setPadding(12); headerPictures.setHorizontalAlignment(Element.ALIGN_CENTER); headerPictures.setColspan(8); table2.addCell(headerPictures); //END HISTORIAL table2.addCell(pasoLabel); table2.addCell(accionLabel); table2.addCell(imagenLabel); //fotos loop List<Fotos> fotos = fotoFacade.findAllByOrder(current.getIdorden()); for (int i = 0; i < fotos.size(); i++) { Fotos foto = fotos.get(i); PdfPCell pasoVal = new PdfPCell(new Paragraph(String.valueOf(i))); pasoVal.setHorizontalAlignment(Element.ALIGN_CENTER); pasoVal.setColspan(1); PdfPCell detail = new PdfPCell(new Paragraph(foto.getTitulo())); detail.setPadding(5); detail.setBorder(Rectangle.NO_BORDER); PdfPCell accionVal = new PdfPCell(); accionVal.addElement(new Paragraph(foto.getDescripcion())); accionVal.setHorizontalAlignment(Element.ALIGN_CENTER); accionVal.setBorder(Rectangle.NO_BORDER); //accionVal.setColspan(3); PdfPTable infoTable = new PdfPTable(1); infoTable.addCell(detail); infoTable.addCell(accionVal); PdfPCell infiCell = new PdfPCell(); infiCell.setColspan(3); infiCell.addElement(infoTable); //Table collumn //System.getenv("OPENSHIFT_DATA_DIR") + "imagenes/" + name) //Image imgFoto = Image.getInstance("http://mantenimiento-contactres.rhcloud.com/MantenimientoRest/webresources/com.mim.entities.fotos/api/" + foto.getIdfotos()); String archivo = foto.getArchivo(); String[] split = archivo.split("/"); int size = split.length; final String name = split[size - 1]; System.out.println("Valor " + name); Image imgFoto = Image.getInstance("/opt/shared/home/" + "imagenes/" + name); PdfPTable imagenTable = new PdfPTable(1); PdfPCell fotoCell = new PdfPCell(); fotoCell.setColspan(1); fotoCell.addElement(imgFoto); fotoCell.setFixedHeight(310); fotoCell.setHorizontalAlignment(Element.ALIGN_CENTER); fotoCell.setBorder(Rectangle.NO_BORDER); imagenTable.addCell(fotoCell); PdfPCell imagenVal = new PdfPCell(); imagenVal.setColspan(4); imagenVal.addElement(imagenTable); table2.addCell(pasoVal); table2.addCell(infiCell); table2.addCell(imagenVal); } //end loop //table.addCell(tiempoLabel); document.add(table); document.newPage(); document.add(table2); }