List of usage examples for com.itextpdf.text PageSize LETTER
Rectangle LETTER
To view the source code for com.itextpdf.text PageSize LETTER.
Click Source Link
From source file:Presentacion.InterfacesAdmin.GeneracionInformes.java
public void InformeHotel() { String fecha = this.fechaInforme.getEditor().getText(); try {//from w ww . j a v a 2s . c o m GeneradorPDF generador = new GeneradorPDF(PageSize.LETTER, 14, 12, 12); generador.GenerarPDF(this.jTextField1.getText()); generador.openDoc(); generador.addTitulo("INFORME CONTABLE HOTEL"); generador.addParagrafo("\n"); generador.addParagrafo("\n"); generador.addParagrafo("FECHA: " + fecha); generador.addParagrafo("\n"); Administrador objadmin = new Administrador(); S_Hotel objHotel = new S_Hotel(); ArrayList<Recepcionista> listarecep = new ArrayList<Recepcionista>(); ArrayList<Informacion_hotel> inforecep = new ArrayList<Informacion_hotel>(); listarecep = objadmin.GetInfoRecepcionista(Conexion.obtener()); for (int i = 0; i < listarecep.size(); i++) { generador.addParagrafo("RECEPCIONISTA: " + listarecep.get(i).getRecepcionista_nombres() + " " + listarecep.get(i).getRecepcionista_apellidos()); generador.addParagrafo("\n"); inforecep = objHotel.LoadInfoPerRecepcionista(Conexion.obtener(), fecha, listarecep.get(i).getIdRecepcionista()); if (inforecep.size() != 0) { PdfPTable tabla = new PdfPTable(2); generador.AgregarCeldaTabla("N HABITACIN", tabla); generador.AgregarCeldaTabla("VALOR TOTAL", tabla); for (int j = 0; j < inforecep.size(); j++) { generador.AgregarCeldaTabla(Integer.toString(inforecep.get(j).getNumHabitacion()), tabla); generador.AgregarCeldaTabla(Long.toString(inforecep.get(j).getTotalPagado()), tabla); } generador.addTable(tabla); generador.addParagrafo("\n"); } else { generador.addParagrafo("No tiene registros asociados"); generador.addParagrafo("\n"); } } ArrayList<String> total = objadmin.TotalesDiarios(Conexion.obtener(), fecha); generador.addParagrafo("TOTAL: " + total.get(2)); generador.addParagrafo("\n"); generador.closeDoc(); JOptionPane.showMessageDialog(null, "Reporte creado con exito"); File file = new File(generador.ruta); Desktop.getDesktop().open(file); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:Presentacion.InterfacesAdmin.GeneracionInformes.java
public void InformeLavadero() { String fecha = this.fechaInforme.getEditor().getText(); try {// ww w.j a v a 2 s . c o m GeneradorPDF generador = new GeneradorPDF(PageSize.LETTER, 14, 12, 12); generador.GenerarPDF(this.jTextField1.getText()); generador.openDoc(); generador.addTitulo("INFORME CONTABLE LAVADERO"); generador.addParagrafo("\n"); generador.addParagrafo("\n"); generador.addParagrafo("FECHA: " + fecha); generador.addParagrafo("\n"); Administrador objadmin = new Administrador(); SLavadero lavadero = new SLavadero(); ArrayList<Recepcionista> listarecep = new ArrayList<Recepcionista>(); ArrayList<Informe_Lavadero> inforecep = new ArrayList<Informe_Lavadero>(); listarecep = objadmin.GetInfoRecepcionista(Conexion.obtener()); for (int i = 0; i < listarecep.size(); i++) { generador.addParagrafo("RECEPCIONISTA: " + listarecep.get(i).getRecepcionista_nombres() + " " + listarecep.get(i).getRecepcionista_apellidos()); generador.addParagrafo("\n"); inforecep = lavadero.LoadInfoPerRecepcionista(Conexion.obtener(), fecha, listarecep.get(i).getIdRecepcionista()); if (inforecep.size() != 0) { PdfPTable tabla = new PdfPTable(2); generador.AgregarCeldaTabla("LAVADOR", tabla); generador.AgregarCeldaTabla("VALOR TOTAL", tabla); for (int j = 0; j < inforecep.size(); j++) { generador.AgregarCeldaTabla(inforecep.get(j).getLavador_names(), tabla); generador.AgregarCeldaTabla(Long.toString((long) inforecep.get(j).getValor_total()), tabla); } generador.addTable(tabla); generador.addParagrafo("\n"); } else { generador.addParagrafo("No tiene registros asociados"); generador.addParagrafo("\n"); } } float total = lavadero.LoadTotalRecep(Conexion.obtener(), fecha); generador.addParagrafo("TOTAL: " + total); generador.addParagrafo("\n"); generador.closeDoc(); JOptionPane.showMessageDialog(null, "Reporte creado con exito"); File file = new File(generador.ruta); Desktop.getDesktop().open(file); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:Presentacion.InterfacesAdmin.GeneracionInformes.java
public void InformeTotalMensual() { String fecha = this.fechaInforme.getEditor().getText(); try {/*from w w w. j a va2s .co m*/ GeneradorPDF generador = new GeneradorPDF(PageSize.LETTER, 14, 12, 12); generador.GenerarPDF(this.jTextField1.getText()); generador.openDoc(); generador.addTitulo("INFORME TOTAL MENSUAL"); generador.addParagrafo("\n"); generador.addParagrafo("\n"); generador.addParagrafo("MES: " + fecha); generador.addParagrafo("\n"); Administrador objadmin = new Administrador(); ArrayList<String> datos_mensuales = objadmin.Informe_Total_Mensual(Conexion.obtener(), fecha); generador.addParagrafo("SERVICIO: PARQUEADERO"); generador.addParagrafo("TOTAL: " + Long.parseLong(datos_mensuales.get(0))); generador.addParagrafo("\n"); generador.addParagrafo("SERVICIO: LAVADERO"); generador.addParagrafo("TOTAL: " + Long.parseLong(datos_mensuales.get(2))); generador.addParagrafo("\n"); generador.addParagrafo("SERVICIO: HOTEL"); generador.addParagrafo("TOTAL: " + Long.parseLong(datos_mensuales.get(1))); generador.addParagrafo("\n"); generador.addParagrafo("\n"); generador.addParagrafo("\n"); generador.addParagrafo("TOTAL MES: " + Long.parseLong(datos_mensuales.get(3))); generador.closeDoc(); JOptionPane.showMessageDialog(null, "Reporte creado con exito"); File file = new File(generador.ruta); Desktop.getDesktop().open(file); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:printInv.GenerateInvoice.java
private void createPDF(String pdfFilename) { Document doc = new Document(); PdfWriter docWriter = null;// ww w . j a va 2 s.c om initializeFonts(); try { // String path = "docs/" + pdfFilename; String path = pdfFilename; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.addAuthor("SmartWMS"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("SmartWMS"); doc.addTitle("Invoice"); doc.setPageSize(PageSize.LETTER); doc.open(); PdfContentByte cb = docWriter.getDirectContent(); boolean beginPage = true; int y = 0; System.out.println("n ===========" + n); for (int i = 0; i < n; i++) { if (beginPage) { beginPage = false; generateLayout(doc, cb); generateHeader(doc, cb); y = 615; } generateDetail(doc, cb, i, y); y = y - 15; if (y < 50) { printPageNumber(cb); doc.newPage(); beginPage = true; } } printPageNumber(cb); cb.beginText(); cb.setFontAndSize(bfBold, 10); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Grand Total : " + total, 570, 35, 0); cb.endText(); } catch (DocumentException dex) { dex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (doc != null) { doc.close(); } if (docWriter != null) { docWriter.close(); } } }
From source file:printom.PDFCreator.java
public static void createBOL(ArrayList<Shipment> aShipmentList, int aTemplate) { ArrayList<Shipment> shipmentList = aShipmentList; Order chosenOrder = shipmentList.get(0).getChosenOrder(); String bolCode = shipmentList.get(0).getBolCode(); String bolFileName = bolCode + ".pdf"; String myCustName = Customer.getCustomerName(chosenOrder.getCustID()); String myShipDate = Prompter.dateString(shipmentList.get(0).getDateShipped()); String myCarrier = shipmentList.get(0).getCarrier(); String myInstructs = shipmentList.get(0).getInstructions(); Address myAddress = Address.retAddress(shipmentList.get(0).getChosenOrder().getShipAddressID()); try {//www .j a va2s.c o m //BaseFont bf1 = BaseFont.createFont("c:/windows/fonts/consola.ttf", //BaseFont.WINANSI, BaseFont.EMBEDDED); Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, BaseColor.WHITE); Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); Font courierNorm = new Font(Font.FontFamily.COURIER, 11, Font.NORMAL, BaseColor.BLACK); Font courierSBig = new Font(Font.FontFamily.COURIER, 13, Font.NORMAL, BaseColor.BLACK); // step 1 Document document = new Document(PageSize.LETTER, 18, 18, 126, 54); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(bolFileName)); // step 3 document.open(); // step 4 // we set the compression to 0 so that we can read the PDF syntax writer.setCompressionLevel(0); // writes something to the direct content using a convenience method PdfContentByte canvas = writer.getDirectContentUnder(); // Graphic Letterheard Image image = Image.getInstance("AresLH.jpg"); image.scalePercent(50f); image.setAbsolutePosition(43, 680); if (aTemplate == 1) document.add(image); // 11" = 792 // 8.5 = 612 // TEXT SIZE = 11 // LINE SPACING = 11 // PARAGRAPH SPACE = 3 * 11 int myPageWidth = 612; int myPageHeight = 792; int myTopMargin = 655; int myTopSubMargin = 622; int myPageLeftMargin = 54; // HEADER LINES ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ARES BOL# " + bolCode, courierNorm), myPageLeftMargin, myTopMargin, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("DATE: " + myShipDate, courierNorm), myPageWidth - myPageLeftMargin, myTopMargin, 0); // CONSIGNEE ADDRESS int myAddressStartY = myTopSubMargin; int myCurrentY = myTopSubMargin; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CONSIGNEE", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ADDRESS:", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY = myAddressStartY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getAttention(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getAddress1(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getCity() + ", " + myAddress.getState() + " " + myAddress.getZipCode(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getLastLine(), courierNorm), 125, myCurrentY, 0); // FROM ADDRESS myCurrentY = myAddressStartY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FROM:", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Ares Printing & Packaging", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("63 Flushing Ave, Bldg 5", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn Navy Yard", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn, NY 11205", courierNorm), 98 + 288, myCurrentY, 0); // CARRIER, FOB AND SPECIAL INSTRUCTIONS myCurrentY -= 33; int myItemStartY = myCurrentY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CARRIER: " + myCarrier, courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FOB: Brooklyn", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("SPECIAL INSTRUCTIONS: " + myInstructs, courierNorm), myPageLeftMargin, myCurrentY, 0); int myBOLTPallets = 0; int myBOLTCases = 0; int myBOLTPieces = 0; myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); // Start Item/ShipLine Information for (Shipment shipment : shipmentList) { ArrayList<Inventory> shipInventoryList = shipment.getInvenList(); ArrayList<Inventory.InventoryLine> invenLineList = new ArrayList<>(); Item item = new Item(shipInventoryList.get(0).getItemID()); String apo = ""; for (int i = 0; i < shipInventoryList.size(); i++) { if (i == 0) { apo += shipInventoryList.get(i).getJobNum(); } else { apo += ", " + shipInventoryList.get(i).getJobNum(); } invenLineList.addAll(shipInventoryList.get(i).getInvenLines()); } //START ITEM myCurrentY -= 22; if (myCurrentY < 100) { document.newPage(); if (aTemplate == 1) { document.add(image); } myCurrentY = myTopSubMargin; } ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: " + item.getItemName(), courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: " + chosenOrder.getPOrderNum(), courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: " + item.getItemCode(), courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: " + apo, courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; int myItemTPallets = 0; int myItemTCases = 0; int myItemTPieces = 0; for (Inventory.InventoryLine invenLine : invenLineList) { ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getPallets()), courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getCases()), courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getPieces()), courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; myItemTPallets += invenLine.getPallets(); myItemTCases += invenLine.getPallets() * invenLine.getCases(); myItemTPieces += invenLine.getPallets() * invenLine.getCases() * invenLine.getPieces(); myBOLTPallets += myItemTPallets; myBOLTCases += myItemTCases; myBOLTPieces += myItemTPieces; } myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned( canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: " + myItemTPallets + " CASES: " + myItemTCases + " QUANTITY: " + myItemTPieces, courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); ////////////// //END ITEM ////////////// myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ////////////// //START ITEM ////////////// ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// */ ////////////// //START FOOTER ////////////// myCurrentY -= 33; if (myCurrentY < 85) { document.newPage(); myCurrentY = myTopSubMargin; } ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("SHIPMENT RECEIVED IN GOOD CONDITION BY:", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("______________________________________", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY -= 16; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("(SIGNATURE) (DATE & TIME)", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY += 49; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL PALLETS: " + myBOLTPallets, courierSBig), myPageLeftMargin + 500, myCurrentY, 0); myCurrentY -= 13; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL CASES: " + myBOLTCases, courierSBig), myPageLeftMargin + 500, myCurrentY, 0); myCurrentY -= 13; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL WEIGHT: ~" + ((myBOLTCases * 25) + (myBOLTPallets * 40)) + " lbs", courierSBig), myPageLeftMargin + 500, myCurrentY, 0); ////////////// //END FOOTER ////////////// /* document.newPage(); myCurrentY = myTopSubMargin; ////////////// //START ITEM ////////////// ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// */ // step 5 document.close(); if (Desktop.isDesktopSupported()) { try { File f = new File(bolFileName); Desktop.getDesktop().open(f); } catch (IOException ex) { // no application registered for PDFs } } } catch (IOException | DocumentException ex) { Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:registrosql.Registrar.java
public void PrintFrameToPDF(File file) { try {//from w w w .java 2s .c o m Document d = new Document(); PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream(file)); d.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(PageSize.LETTER.getWidth(), PageSize.LETTER.getHeight()); cb.addTemplate(template, 0, 0); Graphics2D g2d = template.createGraphics(PageSize.LETTER.getWidth(), PageSize.LETTER.getHeight()); g2d.scale(0.4, 0.4); for (int i = 0; i < this.getContentPane().getComponents().length; i++) { Component c = this.getContentPane().getComponent(i); if (c instanceof JLabel || c instanceof JScrollPane) { g2d.translate(c.getBounds().x, c.getBounds().y); if (c instanceof JScrollPane) { c.setBounds(0, 0, (int) PageSize.LETTER.getWidth() * 2, (int) PageSize.LETTER.getHeight() * 2); } c.paintAll(g2d); c.addNotify(); } } g2d.dispose(); d.close(); } catch (Exception e) { System.out.println("ERROR: " + e.toString()); } }
From source file:reportes.ServletIntegral.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); String path = context.getContextPath(); String realPath = context.getRealPath("/"); response.setContentType("application/pdf"); //Para descargar el PDF response.setHeader("Content-Disposition", "attachment; filename=\"ResultadoIntegral.pdf\""); // step 1: creation of a document-object try {/*from w ww . j ava 2 s . c o m*/ Document document = new Document(PageSize.LETTER); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a temporary buffer ByteArrayOutputStream buffer = new ByteArrayOutputStream(); PdfWriter.getInstance(document, buffer); // step 3: we open the document document.open(); // step 4: we add content to the document Paragraph title = new Paragraph( (session.getAttribute("nEmpresa") != null) ? session.getAttribute("nEmpresa").toString() : "Empresa"); title.setAlignment(Element.ALIGN_CENTER); title.setFont(NORMAL); document.add(title); title = new Paragraph("Estado de resultado integral del 01 de Enero al 31 de Diciembre del " + (new Date().getYear() + 1900)); title.setAlignment(Element.ALIGN_CENTER); title.setFont(NORMAL); document.add(title); title = new Paragraph("Cifras en miles de pesos"); title.setAlignment(Element.ALIGN_CENTER); title.setFont(NORMAL); document.add(title); for (int i = 0; i < 2; i++) { document.add(new Paragraph(" ")); } PdfPTable table = new PdfPTable(2); //Obtenemos los datos de la clase ResultadoIntegral ResultadoIntegral r = new ResultadoIntegral(); r.calculaResultado(Integer.parseInt(session.getAttribute("Empresa").toString())); for (int i = 0; i < r.getSaldos().size(); i++) { PdfPCell dato = new PdfPCell(); if (i == 2 || i == 7 || i == 12 || i == 14 || i == 16 || i == 18 || i == 19 || i == 17) { Chunk ch = new Chunk(descripciones[i]); ch.setFont(BOLD_Tot); Phrase ph = new Phrase(ch); dato.setPhrase(ph); } else { Phrase ph = new Phrase(descripciones[i]); dato.setPhrase(ph); } dato.setBorder(Rectangle.NO_BORDER); dato.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(dato); if (r.getValores().size() > 0) { Chunk ch = new Chunk(); if (r.getSaldos().get(i) < 0) { String valor = "(" + (r.getSaldos().get(i) * (-1)) + ")"; ch.append(valor); ch.setFont(NORMAL_Negative); } else { dato.setPhrase(new Phrase("" + r.getSaldos().get(i))); } } else { dato.setPhrase(new Phrase("0.0")); } if (i == 1 || i == 6 || i == 11 || i == 13 || i == 15 || i == 17 || i == 18) { dato.setBorder(Rectangle.BOTTOM); } else { dato.setBorder(Rectangle.NO_BORDER); } dato.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(dato); } document.add(table); document.add(new Paragraph("")); // step 5: we close the document document.close(); // step 6: we output the writer as bytes to the response output DataOutputStream output = new DataOutputStream(response.getOutputStream()); byte[] bytes = buffer.toByteArray(); response.setContentLength(bytes.length); for (int i = 0; i < bytes.length; i++) { output.writeByte(bytes[i]); } output.close(); response.getOutputStream(); //session.removeAttribute("bean"); //session.removeAttribute("producto"); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:reports.moh731_district.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, DocumentException { session = request.getSession();//from w w w . j a v a2 s . c o m dbConn conn = new dbConn(); String validitychecker = ""; session = request.getSession(); String FP_TAB = ""; String MCH_TAB = ""; String MATERNITY_TAB = ""; String VCT_TAB = ""; String DTC_TAB = ""; String enterdby = ""; // if(session.getAttribute("forms_holder")!=null && !(session.getAttribute("forms_holder").toString().equals(","))){ data = ""; // if(session.getAttribute("year")!=null){ // year=session.getAttribute("year").toString(); year = "2015"; // } // if(session.getAttribute("monthid")!=null){ // month=session.getAttribute("monthid").toString(); // } month = "4"; // if(session.getAttribute("facilityid")!=null){ // facilityId=session.getAttribute("facilityid").toString(); // } facilityId = "403"; // if(session.getAttribute("subcountyid")!=null){ // subcountyid=session.getAttribute("subcountyid").toString(); // } subcountyid = "8"; id = year + "_" + month + "_" + facilityId; System.out.println("id is " + id); invalidFPTXT = invalidPMTCTTXT = invalidMATTXT = invalidHTCTXT = ""; // id="2015_1_14498"; String fppane = ""; String pmctpane = ""; String matpane = ""; String htcpane = ""; String activeclass = ""; activeclass = "active"; int counter = 0; isValidated = ""; validity = ""; expectedFP = 0; expectedPMTCT = 0; expectedMAT = 0; expectedHTC = 0; validPMTCT = 0; invalidPMTCT = 0; totalPMTCT = 0; validFP = invalidFP = totalFP = validMAT = invalidMAT = totalMAT = validHTC = invalidHTC = totalHTC; String getExpectedForms = "SELECT SUM(FP),SUM(PMTCT),SUM(Maternity),SUM(HTC) FROM subpartnera WHERE subpartnera.DistrictID='" + subcountyid + "'"; conn.rs1 = conn.st1.executeQuery(getExpectedForms); if (conn.rs1.next() == true) { // System.out.println("pmtct : "+conn.rs1.getString(1)+" care : "+conn.rs1.getInt(2)+" pep : "+conn.rs1.getInt(3)); expectedFP = conn.rs1.getInt(1); expectedPMTCT = conn.rs1.getInt(2); expectedMAT = conn.rs1.getInt(3); expectedHTC = conn.rs1.getInt(4); } validPMTCT = invalidPMTCT = totalPMTCT = 0; validFP = invalidFP = totalFP = 0; validMAT = invalidMAT = totalMAT = 0; validHTC = invalidHTC = totalHTC = 0; String getEntered = "SELECT moh711.isValidated,SUM(subpartnera.FP),SUM(subpartnera.PMTCT),SUM(subpartnera.Maternity),SUM(subpartnera.HTC)" + " FROM subpartnera JOIN moh711 ON subpartnera.SubPartnerID=moh711.SubPartnerID WHERE " + "moh711.Mois='" + month + "' AND moh711.Annee='" + year + "' AND subpartnera.DistrictID='" + subcountyid + "' GROUP BY moh711.isValidated"; conn.rs1 = conn.st1.executeQuery(getEntered); while (conn.rs1.next()) { System.out.println("isvalidated : " + conn.rs1.getInt(1) + " num : " + conn.rs1.getInt(2)); if (conn.rs1.getInt(1) == 1) { validFP = conn.rs1.getInt(2); validPMTCT = conn.rs1.getInt(3); validMAT = conn.rs1.getInt(4); validHTC = conn.rs1.getInt(5); } if (conn.rs1.getInt(1) == 0) { invalidFP = conn.rs1.getInt(2); invalidPMTCT = conn.rs1.getInt(3); invalidMAT = conn.rs1.getInt(4); invalidHTC = conn.rs1.getInt(5); } } totalFP = validFP + invalidFP; totalPMTCT = validPMTCT + invalidPMTCT; totalMAT = validMAT + invalidMAT; totalHTC = validHTC + invalidHTC; invalidFPTXT = " Unvalidated Form(s) : 0"; invalidPMTCTTXT = " Unvalidated Form(s) : 0"; invalidMATTXT = " Unvalidated Form(s) : 0"; invalidHTCTXT = " Unvalidated Form(s) : 0"; if (invalidFP > 0) { invalidFPTXT = "<button type=\"button\" class=\"btn btn-primary btn-lg\" data-toggle=\"modal\" style=\"width:auto; height:auto;\" data-target=\"#unvalidatedModal\"> Unvalidated Form(s) : <span class=\"badge badge-important\">" + invalidFP + "</span></button>"; } if (invalidPMTCT > 0) { invalidPMTCTTXT = "<button type=\"button\" class=\"btn btn-primary btn-lg\" data-toggle=\"modal\" style=\"width:auto; height:auto;\" data-target=\"#unvalidatedModal\"> Unvalidated Form(s) : <span class=\"badge badge-important\">" + invalidPMTCT + "</span></button>"; } if (invalidMAT > 0) { invalidMATTXT = "<button type=\"button\" class=\"btn btn-primary btn-lg\" data-toggle=\"modal\" style=\"width:auto; height:auto;\" data-target=\"#unvalidatedModal\"> Unvalidated Form(s) : <span class=\"badge badge-important\">" + invalidMAT + "</span></button>"; } if (invalidHTC > 0) { invalidHTCTXT = "<button type=\"button\" class=\"btn btn-primary btn-lg\" data-toggle=\"modal\" style=\"width:auto; height:auto;\" data-target=\"#unvalidatedModal\"> Unvalidated Form(s) : <span class=\"badge badge-important\">" + invalidHTC + "</span></button>"; } String ul = " <ul class=\"nav nav-tabs\">\n"; // INITIALIZING VARIABLES // FAMILY PLANNING FPMicrolutN = FPMicrolutR = FPMicrolutT = FPMicrogynonN = FPMicrogynonR = FPMicrogynonT = FPINJECTIONSN = FPINJECTIONSR = ""; FPINJECTIONST = FPIUCDN = FPIUCDR = FPIUCDT = FPIMPLANTSN = FPIMPLANTSR = FPIMPLANTST = FPBTLN = FPBTLR = FPBTLT = FPVasectomyN = FPVasectomyR = ""; FPVasectomyT = FPCONDOMSN = FPCONDOMSR = FPCONDOMST = FPOTHERN = FPOTHERR = FPOTHERT = FPCLIENTSN = FPCLIENTSR = FPCLIENTST = FPIUCDRemoval = FPIMPLANTSRemoval = ""; //PMCT VARIABLES PMCTA_1stVisit_ANC = PMCTA_ReVisit_ANC = PMCTANCClientsT = PMCTHB7 = PMCTIPT1 = PMCTIPT2 = PMCTANCClients4 = PMCTITN = MATNormalDelivery = MATCSection = ""; MATBreech = MATAssistedVag = MATDeliveryT = MATLiveBirth = MATStillBirth = MATWeight2500 = MATPreTerm = MATDischargealive = MATReferral = MATNeoNatalD = MATMaternalD = MATAPHAlive = MATAPHDead = MATPPHAlive = MATPPHDead = MATEclampAlive = MATEclampDead = MATRupUtAlive = MATRupUtDead = MATObstrLaborAlive = MATObstrLaborDead = MATSepsisAlive = MATSepsisDead = ""; VCTClient_Couns_CM = VCTClient_Couns_CF = VCTClient_Couns_AM = VCTClient_Couns_AF = VCTClient_Couns_TOT = VCTClient_Tested_CM = VCTClient_Tested_CF = VCTClient_Tested_AM = VCTClient_Tested_AF = VCTClient_Tested_TOT = VCTClient_HIV_CM = VCTClient_HIV_CF = VCTClient_HIV_AM = VCTClient_HIV_AF = VCTClient_HIV_TOT = VCTPartner_Couns_TOT = VCTPartner_Tested_TOT = VCTPartner_HIV_TOT = VCTPartner_Disc_TOT = ""; DTCA_Couns_In_CM = DTCA_Couns_In_CF = DTCA_Couns_In_AM = DTCA_Couns_In_AF = DTCA_Couns_In_Tot = DTCA_Couns_Out_CM = DTCA_Couns_Out_CF = DTCA_Couns_Out_AM = DTCA_Couns_Out_AF = DTCA_Couns_Out_Tot = DTCB_Test_In_CM = DTCB_Test_In_CF = DTCB_Test_In_AM = DTCB_Test_In_AF = DTCB_Test_In_Tot = DTCB_Test_Out_CM = DTCB_Test_Out_CF = DTCB_Test_Out_AM = DTCB_Test_Out_AF = DTCB_Test_Out_Tot = DTCC_HIV_In_CM = DTCC_HIV_In_CF = DTCC_HIV_In_AM = DTCC_HIV_In_AF = DTCC_HIV_In_Tot = DTCC_HIV_Out_CM = DTCC_HIV_Out_CF = DTCC_HIV_Out_AM = DTCC_HIV_Out_AF = DTCC_HIV_Out_Tot = Userid = ""; String checker = "SELECT * FROM moh711 WHERE id=?"; conn.pst = conn.conn.prepareStatement(checker); conn.pst.setString(1, id); conn.rs = conn.pst.executeQuery(); if (conn.rs.next() == true) { System.out.println("Data already exist loading............................"); if (conn.rs.getString("FPMicrolutN") != null) { FPMicrolutN = conn.rs.getString("FPMicrolutN"); } else if (FPMicrolutN == null) { FPMicrolutN = ""; } FPMicrolutR = conn.rs.getString("FPMicrolutR"); if (FPMicrolutR == null) { FPMicrolutR = ""; } if (conn.rs.getString("FPMicrolutT") != null) { FPMicrolutT = conn.rs.getString("FPMicrolutT"); } else { FPMicrolutT = ""; } if (conn.rs.getString("FPMicrogynonN") != null) { FPMicrogynonN = conn.rs.getString("FPMicrogynonN"); } else { FPMicrogynonN = ""; } if (conn.rs.getString("FPMicrogynonR") != null) { FPMicrogynonR = conn.rs.getString("FPMicrogynonR"); } else { FPMicrogynonR = ""; } if (conn.rs.getString("FPMicrogynonT") != null) { FPMicrogynonT = conn.rs.getString("FPMicrogynonT"); } else { FPMicrogynonT = ""; } if (conn.rs.getString("FPINJECTIONSN") != null) { FPINJECTIONSN = conn.rs.getString("FPINJECTIONSN"); } else { FPINJECTIONSN = ""; } if (conn.rs.getString("FPINJECTIONSR") != null) { FPINJECTIONSR = conn.rs.getString("FPINJECTIONSR"); } else { FPINJECTIONSR = ""; } if (conn.rs.getString("FPINJECTIONST") != null) { FPINJECTIONST = conn.rs.getString("FPINJECTIONST"); } else { FPINJECTIONST = ""; } if (conn.rs.getString("FPIUCDN") != null) { FPIUCDN = conn.rs.getString("FPIUCDN"); } else { FPIUCDN = ""; } if (conn.rs.getString("FPIUCDR") != null) { FPIUCDR = conn.rs.getString("FPIUCDR"); } else { FPIUCDR = ""; } if (conn.rs.getString("FPIUCDT") != null) { FPIUCDT = conn.rs.getString("FPIUCDT"); } else { FPIUCDT = ""; } if (conn.rs.getString("FPIMPLANTSN") != null) { FPIMPLANTSN = conn.rs.getString("FPIMPLANTSN"); } else { FPIMPLANTSN = ""; } if (conn.rs.getString("FPIMPLANTSR") != null) { FPIMPLANTSR = conn.rs.getString("FPIMPLANTSR"); } else { FPIMPLANTSR = ""; } if (conn.rs.getString("FPIMPLANTST") != null) { FPIMPLANTST = conn.rs.getString("FPIMPLANTST"); } else { FPIMPLANTST = ""; } if (conn.rs.getString("FPBTLN") != null) { FPBTLN = conn.rs.getString("FPBTLN"); } else { FPBTLN = ""; } if (conn.rs.getString("FPBTLR") != null) { FPBTLR = conn.rs.getString("FPBTLR"); } else { FPBTLR = ""; } if (conn.rs.getString("FPBTLT") != null) { FPBTLT = conn.rs.getString("FPBTLT"); } else { FPBTLT = ""; } if (conn.rs.getString("FPVasectomyN") != null) { FPVasectomyN = conn.rs.getString("FPVasectomyN"); } else { FPVasectomyN = ""; } if (conn.rs.getString("FPVasectomyR") != null) { FPVasectomyR = conn.rs.getString("FPVasectomyR"); } else { FPVasectomyR = ""; } if (conn.rs.getString("FPVasectomyT") != null) { FPVasectomyT = conn.rs.getString("FPVasectomyT"); } else { FPVasectomyT = ""; } if (conn.rs.getString("FPCONDOMSN") != null) { FPCONDOMSN = conn.rs.getString("FPCONDOMSN"); } else { FPCONDOMSN = ""; } if (conn.rs.getString("FPCONDOMSR") != null) { FPCONDOMSR = conn.rs.getString("FPCONDOMSR"); } else { FPCONDOMSR = ""; } if (conn.rs.getString("FPCONDOMST") != null) { FPCONDOMST = conn.rs.getString("FPCONDOMST"); } else { FPCONDOMST = ""; } if (conn.rs.getString("FPOTHERN") != null) { FPOTHERN = conn.rs.getString("FPOTHERN"); } else { FPOTHERN = ""; } if (conn.rs.getString("FPOTHERR") != null) { FPOTHERR = conn.rs.getString("FPOTHERR"); } else { FPOTHERR = ""; } if (conn.rs.getString("FPOTHERT") != null) { FPOTHERT = conn.rs.getString("FPOTHERT"); } else { FPOTHERT = ""; } if (conn.rs.getString("FPCLIENTSN") != null) { FPCLIENTSN = conn.rs.getString("FPCLIENTSN"); } else { FPCLIENTSN = ""; } if (conn.rs.getString("FPCLIENTSR") != null) { FPCLIENTSR = conn.rs.getString("FPCLIENTSR"); } else { FPCLIENTSR = ""; } if (conn.rs.getString("FPCLIENTST") != null) { FPCLIENTST = conn.rs.getString("FPCLIENTST"); } else { FPCLIENTST = ""; } if (conn.rs.getString("FPIUCDRemoval") != null) { FPIUCDRemoval = conn.rs.getString("FPIUCDRemoval"); } else { FPIUCDRemoval = ""; } if (conn.rs.getString("FPIMPLANTSRemoval") != null) { FPIMPLANTSRemoval = conn.rs.getString("FPIMPLANTSRemoval"); } else { FPIMPLANTSRemoval = ""; } // mch if (conn.rs.getString("PMCTA_1stVisit_ANC") != null) { PMCTA_1stVisit_ANC = conn.rs.getString("PMCTA_1stVisit_ANC"); } else { PMCTA_1stVisit_ANC = ""; } if (conn.rs.getString("PMCTA_ReVisit_ANC") != null) { PMCTA_ReVisit_ANC = conn.rs.getString("PMCTA_ReVisit_ANC"); } else { PMCTA_ReVisit_ANC = ""; } if (conn.rs.getString("PMCTANCClientsT") != null) { PMCTANCClientsT = conn.rs.getString("PMCTANCClientsT"); } else { PMCTANCClientsT = ""; } if (conn.rs.getString("PMCTHB7") != null) { PMCTHB7 = conn.rs.getString("PMCTHB7"); } else { PMCTHB7 = ""; } if (conn.rs.getString("PMCTIPT1") != null) { PMCTIPT1 = conn.rs.getString("PMCTIPT1"); } else { PMCTIPT1 = ""; } if (conn.rs.getString("PMCTIPT2") != null) { PMCTIPT2 = conn.rs.getString("PMCTIPT2"); } else { PMCTIPT2 = ""; } if (conn.rs.getString("PMCTANCClients4") != null) { PMCTANCClients4 = conn.rs.getString("PMCTANCClients4"); } else { PMCTANCClients4 = ""; } if (conn.rs.getString("PMCTITN") != null) { PMCTITN = conn.rs.getString("PMCTITN"); } else { PMCTITN = ""; } if (conn.rs.getString("MATNormalDelivery") != null) { MATNormalDelivery = conn.rs.getString("MATNormalDelivery"); } else { MATNormalDelivery = ""; } if (conn.rs.getString("MATCSection") != null) { MATCSection = conn.rs.getString("MATCSection"); } else { MATCSection = ""; } if (conn.rs.getString("MATBreech") != null) { MATBreech = conn.rs.getString("MATBreech"); } else { MATBreech = ""; } if (conn.rs.getString("MATAssistedVag") != null) { MATAssistedVag = conn.rs.getString("MATAssistedVag"); } else { MATAssistedVag = ""; } if (conn.rs.getString("MATDeliveryT") != null) { MATDeliveryT = conn.rs.getString("MATDeliveryT"); } else { MATDeliveryT = ""; } if (conn.rs.getString("MATLiveBirth") != null) { MATLiveBirth = conn.rs.getString("MATLiveBirth"); } else { MATLiveBirth = ""; } if (conn.rs.getString("MATStillBirth") != null) { MATStillBirth = conn.rs.getString("MATStillBirth"); } else { MATStillBirth = ""; } if (conn.rs.getString("FPBTLT") != null) { FPBTLT = conn.rs.getString("FPBTLT"); } else { FPBTLT = ""; } if (conn.rs.getString("MATWeight2500") != null) { MATWeight2500 = conn.rs.getString("MATWeight2500"); } else { MATWeight2500 = ""; } if (conn.rs.getString("MATPreTerm") != null) { MATPreTerm = conn.rs.getString("MATPreTerm"); } else { MATPreTerm = ""; } if (conn.rs.getString("MATDischargealive") != null) { MATDischargealive = conn.rs.getString("MATDischargealive"); } else { MATDischargealive = ""; } if (conn.rs.getString("MATReferral") != null) { MATReferral = conn.rs.getString("MATReferral"); } else { MATReferral = ""; } if (conn.rs.getString("MATNeoNatalD") != null) { MATNeoNatalD = conn.rs.getString("MATNeoNatalD"); } else { MATNeoNatalD = ""; } if (conn.rs.getString("MATMaternalD") != null) { MATMaternalD = conn.rs.getString("MATMaternalD"); } else { MATMaternalD = ""; } if (conn.rs.getString("MATAPHAlive") != null) { MATAPHAlive = conn.rs.getString("MATAPHAlive"); } else { MATAPHAlive = ""; } if (conn.rs.getString("MATAPHDead") != null) { MATAPHDead = conn.rs.getString("MATAPHDead"); } else { MATAPHDead = ""; } if (conn.rs.getString("MATPPHAlive") != null) { MATPPHAlive = conn.rs.getString("MATPPHAlive"); } else { MATPPHAlive = ""; } if (conn.rs.getString("MATPPHDead") != null) { MATPPHDead = conn.rs.getString("MATPPHDead"); } else { MATPPHDead = ""; } if (conn.rs.getString("MATEclampAlive") != null) { MATEclampAlive = conn.rs.getString("MATEclampAlive"); } else { MATEclampAlive = ""; } if (conn.rs.getString("MATEclampDead") != null) { MATEclampDead = conn.rs.getString("MATEclampDead"); } else { MATEclampDead = ""; } if (conn.rs.getString("MATRupUtAlive") != null) { MATRupUtAlive = conn.rs.getString("MATRupUtAlive"); } else { MATRupUtAlive = ""; } if (conn.rs.getString("MATRupUtDead") != null) { MATRupUtDead = conn.rs.getString("MATRupUtDead"); } else { MATRupUtDead = ""; } if (conn.rs.getString("MATObstrLaborAlive") != null) { MATObstrLaborAlive = conn.rs.getString("MATObstrLaborAlive"); } else { MATObstrLaborAlive = ""; } if (conn.rs.getString("MATObstrLaborDead") != null) { MATObstrLaborDead = conn.rs.getString("MATObstrLaborDead"); } else { MATObstrLaborDead = ""; } if (conn.rs.getString("MATSepsisAlive") != null) { MATSepsisAlive = conn.rs.getString("MATSepsisAlive"); } else { MATSepsisAlive = ""; } if (conn.rs.getString("MATSepsisDead") != null) { MATSepsisDead = conn.rs.getString("MATSepsisDead"); } else { MATSepsisDead = ""; } if (conn.rs.getString("VCTClient_Couns_CM") != null) { VCTClient_Couns_CM = conn.rs.getString("VCTClient_Couns_CM"); } else { VCTClient_Couns_CM = ""; } if (conn.rs.getString("VCTClient_Couns_CF") != null) { VCTClient_Couns_CF = conn.rs.getString("VCTClient_Couns_CF"); } else { VCTClient_Couns_CF = ""; } if (conn.rs.getString("VCTClient_Couns_AM") != null) { VCTClient_Couns_AM = conn.rs.getString("VCTClient_Couns_AM"); } else { VCTClient_Couns_AM = ""; } if (conn.rs.getString("VCTClient_Couns_AF") != null) { VCTClient_Couns_AF = conn.rs.getString("VCTClient_Couns_AF"); } else { VCTClient_Couns_AF = ""; } if (conn.rs.getString("VCTClient_Couns_TOT") != null) { VCTClient_Couns_TOT = conn.rs.getString("VCTClient_Couns_TOT"); } else { VCTClient_Couns_TOT = ""; } if (conn.rs.getString("VCTClient_Tested_CM") != null) { VCTClient_Tested_CM = conn.rs.getString("VCTClient_Tested_CM"); } else { VCTClient_Tested_CM = ""; } if (conn.rs.getString("VCTClient_Tested_CF") != null) { VCTClient_Tested_CF = conn.rs.getString("VCTClient_Tested_CF"); } else { VCTClient_Tested_CF = ""; } if (conn.rs.getString("VCTClient_Tested_AM") != null) { VCTClient_Tested_AM = conn.rs.getString("VCTClient_Tested_AM"); } else { VCTClient_Tested_AM = ""; } if (conn.rs.getString("VCTClient_Tested_AF") != null) { VCTClient_Tested_AF = conn.rs.getString("VCTClient_Tested_AF"); } else { VCTClient_Tested_AF = ""; } if (conn.rs.getString("VCTClient_Tested_TOT") != null) { VCTClient_Tested_TOT = conn.rs.getString("VCTClient_Tested_TOT"); } else { VCTClient_Tested_TOT = ""; } if (conn.rs.getString("VCTClient_HIV_CM") != null) { VCTClient_HIV_CM = conn.rs.getString("VCTClient_HIV_CM"); } else { VCTClient_HIV_CM = ""; } if (conn.rs.getString("VCTClient_HIV_CF") != null) { VCTClient_HIV_CF = conn.rs.getString("VCTClient_HIV_CF"); } else { VCTClient_HIV_CF = ""; } if (conn.rs.getString("VCTClient_HIV_AM") != null) { VCTClient_HIV_AM = conn.rs.getString("VCTClient_HIV_AM"); } else { VCTClient_HIV_AM = ""; } if (conn.rs.getString("VCTClient_HIV_AF") != null) { VCTClient_HIV_AF = conn.rs.getString("VCTClient_HIV_AF"); } else { VCTClient_HIV_AF = ""; } if (conn.rs.getString("VCTClient_HIV_TOT") != null) { VCTClient_HIV_TOT = conn.rs.getString("VCTClient_HIV_TOT"); } else { VCTClient_HIV_TOT = ""; } if (conn.rs.getString("VCTPartner_Couns_TOT") != null) { VCTPartner_Couns_TOT = conn.rs.getString("VCTPartner_Couns_TOT"); } else { VCTPartner_Couns_TOT = ""; } if (conn.rs.getString("VCTPartner_Tested_TOT") != null) { VCTPartner_Tested_TOT = conn.rs.getString("VCTPartner_Tested_TOT"); } else { VCTPartner_Tested_TOT = ""; } if (conn.rs.getString("VCTPartner_HIV_TOT") != null) { VCTPartner_HIV_TOT = conn.rs.getString("VCTPartner_HIV_TOT"); } else { VCTPartner_HIV_TOT = ""; } if (conn.rs.getString("VCTPartner_Disc_TOT") != null) { VCTPartner_Disc_TOT = conn.rs.getString("VCTPartner_Disc_TOT"); } else { VCTPartner_Disc_TOT = ""; } // DTCA_Couns_In_CM=DTCA_Couns_In_CF=DTCA_Couns_In_AM=DTCA_Couns_In_AF=DTCA_Couns_In_Tot=DTCA_Couns_Out_CM=DTCA_Couns_Out_CF= //DTCA_Couns_Out_AM=DTCA_Couns_Out_AF=DTCA_Couns_Out_Tot=DTCB_Test_In_CM=DTCB_Test_In_CF //=DTCB_Test_In_AM=DTCB_Test_In_AF=DTCB_Test_In_Tot=DTCB_Test_Out_CM=DTCB_Test_Out_CF=DTCB_Test_Out_AM=DTCB_Test_Out_AF=DTCB_Test_Out_Tot //=DTCC_HIV_In_CM=DTCC_HIV_In_CF=DTCC_HIV_In_AM //=DTCC_HIV_In_AF= DTCC_HIV_In_Tot=DTCC_HIV_Out_CM=DTCC_HIV_Out_CF=DTCC_HIV_Out_AM=DTCC_HIV_Out_AF=DTCC_HIV_Out_Tot=Userid=""; //dtc if (conn.rs.getString("DTCA_Couns_In_CM") != null) { DTCA_Couns_In_CM = conn.rs.getString("DTCA_Couns_In_CM"); } else { DTCA_Couns_In_CM = ""; } if (conn.rs.getString("DTCA_Couns_In_CF") != null) { DTCA_Couns_In_CF = conn.rs.getString("DTCA_Couns_In_CF"); } else { DTCA_Couns_In_CF = ""; } if (conn.rs.getString("DTCA_Couns_In_AM") != null) { DTCA_Couns_In_AM = conn.rs.getString("DTCA_Couns_In_AM"); } else { DTCA_Couns_In_AM = ""; } if (conn.rs.getString("DTCA_Couns_In_AF") != null) { DTCA_Couns_In_AF = conn.rs.getString("DTCA_Couns_In_AF"); } else { DTCA_Couns_In_AF = ""; } if (conn.rs.getString("DTCA_Couns_In_Tot") != null) { DTCA_Couns_In_Tot = conn.rs.getString("DTCA_Couns_In_Tot"); } else { DTCA_Couns_In_Tot = ""; } if (conn.rs.getString("DTCA_Couns_Out_CM") != null) { DTCA_Couns_Out_CM = conn.rs.getString("DTCA_Couns_Out_CM"); } else { DTCA_Couns_Out_CM = ""; } if (conn.rs.getString("DTCA_Couns_Out_CF") != null) { DTCA_Couns_Out_CF = conn.rs.getString("DTCA_Couns_Out_CF"); } else { DTCA_Couns_Out_CF = ""; } if (conn.rs.getString("DTCA_Couns_Out_AM") != null) { DTCA_Couns_Out_AM = conn.rs.getString("DTCA_Couns_Out_AM"); } else { DTCA_Couns_Out_AM = ""; } if (conn.rs.getString("DTCA_Couns_Out_AF") != null) { DTCA_Couns_Out_AF = conn.rs.getString("DTCA_Couns_Out_AF"); } else { DTCA_Couns_Out_AF = ""; } if (conn.rs.getString("DTCA_Couns_Out_Tot") != null) { DTCA_Couns_Out_Tot = conn.rs.getString("DTCA_Couns_Out_Tot"); } else { DTCA_Couns_Out_Tot = ""; } if (conn.rs.getString("DTCB_Test_In_CM") != null) { DTCB_Test_In_CM = conn.rs.getString("DTCB_Test_In_CM"); } else { DTCB_Test_In_CM = ""; } if (conn.rs.getString("DTCB_Test_In_CF") != null) { DTCB_Test_In_CF = conn.rs.getString("DTCB_Test_In_CF"); } else { DTCB_Test_In_CF = ""; } if (conn.rs.getString("DTCB_Test_In_AM") != null) { DTCB_Test_In_AM = conn.rs.getString("DTCB_Test_In_AM"); } else { DTCB_Test_In_AM = ""; } if (conn.rs.getString("DTCB_Test_In_AF") != null) { DTCB_Test_In_AF = conn.rs.getString("DTCB_Test_In_AF"); } else { DTCB_Test_In_AF = ""; } if (conn.rs.getString("DTCB_Test_In_Tot") != null) { DTCB_Test_In_Tot = conn.rs.getString("DTCB_Test_In_Tot"); } else { DTCB_Test_In_Tot = ""; } if (conn.rs.getString("DTCB_Test_Out_CM") != null) { DTCB_Test_Out_CM = conn.rs.getString("DTCB_Test_Out_CM"); } else { DTCB_Test_Out_CM = ""; } if (conn.rs.getString("DTCB_Test_Out_CF") != null) { DTCB_Test_Out_CF = conn.rs.getString("DTCB_Test_Out_CF"); } else { DTCB_Test_Out_CF = ""; } if (conn.rs.getString("DTCB_Test_Out_AM") != null) { DTCB_Test_Out_AM = conn.rs.getString("DTCB_Test_Out_AM"); } else { DTCB_Test_Out_AM = ""; } if (conn.rs.getString("DTCB_Test_Out_AF") != null) { DTCB_Test_Out_AF = conn.rs.getString("DTCB_Test_Out_AF"); } else { DTCB_Test_Out_AF = ""; } if (conn.rs.getString("DTCB_Test_Out_Tot") != null) { DTCB_Test_Out_Tot = conn.rs.getString("DTCB_Test_Out_Tot"); } else { DTCB_Test_Out_Tot = ""; } if (conn.rs.getString("DTCC_HIV_In_CM") != null) { DTCC_HIV_In_CM = conn.rs.getString("DTCC_HIV_In_CM"); } else { DTCC_HIV_In_CM = ""; } if (conn.rs.getString("DTCC_HIV_In_CF") != null) { DTCC_HIV_In_CF = conn.rs.getString("DTCC_HIV_In_CF"); } else { DTCC_HIV_In_CF = ""; } if (conn.rs.getString("DTCC_HIV_In_AM") != null) { DTCC_HIV_In_AM = conn.rs.getString("DTCC_HIV_In_AM"); } else { DTCC_HIV_In_AM = ""; } if (conn.rs.getString("DTCC_HIV_In_AF") != null) { DTCC_HIV_In_AF = conn.rs.getString("DTCC_HIV_In_AF"); } else { DTCC_HIV_In_AF = ""; } if (conn.rs.getString("DTCC_HIV_In_Tot") != null) { DTCC_HIV_In_Tot = conn.rs.getString("DTCC_HIV_In_Tot"); } else { DTCC_HIV_In_Tot = ""; } if (conn.rs.getString("DTCC_HIV_Out_CM") != null) { DTCC_HIV_Out_CM = conn.rs.getString("DTCC_HIV_Out_CM"); } else { DTCC_HIV_Out_CM = ""; } if (conn.rs.getString("DTCC_HIV_Out_CF") != null) { DTCC_HIV_Out_CF = conn.rs.getString("DTCC_HIV_Out_CF"); } else { DTCC_HIV_Out_CF = ""; } if (conn.rs.getString("DTCC_HIV_Out_AM") != null) { DTCC_HIV_Out_AM = conn.rs.getString("DTCC_HIV_Out_AM"); } else { DTCC_HIV_Out_AM = ""; } if (conn.rs.getString("DTCC_HIV_Out_AF") != null) { DTCC_HIV_Out_AF = conn.rs.getString("DTCC_HIV_Out_AF"); } else { DTCC_HIV_Out_AF = ""; } if (conn.rs.getString("DTCC_HIV_Out_Tot") != null) { DTCC_HIV_Out_Tot = conn.rs.getString("DTCC_HIV_Out_Tot"); } else { DTCC_HIV_Out_Tot = ""; } if (conn.rs.getString("isValidated") != null) { isValidated = conn.rs.getString("isValidated"); } else { isValidated = ""; } //get the name of the person who entered the form String enterer = "select * from user where userid='" + conn.rs.getString("userid") + "'"; System.out.println(enterer); conn.rs1 = conn.st1.executeQuery(enterer); //add details of person who entered if (conn.rs1.next()) { enterdby = "<font color='green'>Data 1st entered by: <b> " + conn.rs1.getString("fname") + " " + conn.rs1.getString("mname") + " " + conn.rs1.getString("lname") + "</b> on <b>" + conn.rs.getString("timestamp") + "</b></font>"; } //now check if form was updated and if its one month after data entry if (conn.rs.getString("updatedOn") != null) { //get difference in months between entered date and updated date String compdate = "SELECT TIMESTAMPDIFF(MONTH,'" + conn.rs.getString("timestamp") + "','" + conn.rs.getString("updatedOn") + "')"; conn.rs2 = conn.st2.executeQuery(compdate); if (conn.rs2.next()) { //now get the details of the person who updated the form //if the difference is greater than or equal to one, if (conn.rs2.getInt(1) >= 1) { String updater = "select * from user where userid='" + conn.rs.getString("updatedBy") + "'"; conn.rs1 = conn.st1.executeQuery(updater); //add details of person who entered if (conn.rs1.next()) { enterdby += "<span style='margin-left:30%;'><font color='red'> Updated by: <b> " + conn.rs1.getString("fname") + " " + conn.rs1.getString("mname") + " " + conn.rs1.getString("lname") + "</b> on <b>" + conn.rs.getString("updatedOn") + "</b></font></span>"; } } //end of if month >=1 } //end of date comparison if } //end of if updated !=null System.out.println("entry by " + enterdby); } System.out.println("Validity checker : " + isValidated); if (isValidated.equals("0")) { validity = "<font color=\"red\"><b>Form Not Validated.<img style=\"margin-left:10px;\" src=\"images/notValidated.jpg\" width=\"20px\" height=\"20px\"></b></font>"; } else if (isValidated.equals("1")) { validity = "<font color=\"green\"><b>Form Validated.<img style=\"margin-left:10px;\" src=\"images/validated.jpg\" width=\"20px\" height=\"20px\"></b></font>"; } else { validity = "<font color=\"blue\"><b>New Entry</b></font>"; } FamilyPlanninng = pmct = maternity = vct = dtc = ""; FP_TAB += ""; validitychecker += "<p id=\"checkValidity\" hidden=\"hidden\">" + validity + "</p>"; // FPMicrolutN=FPMicrolutR=FPMicrolutT=FPMicrogynonN=FPMicrogynonR=FPMicrogynonT=FPINJECTIONSN=FPINJECTIONSR= //FPINJECTIONST=FPIUCDN=FPIUCDR=FPIUCDT=FPIMPLANTSN=FPIMPLANTSR=FPIMPLANTST=FPBTLN=FPBTLR=FPBTLT=FPVasectomyN=FPVasectomyR=""; //FPVasectomyT=FPCONDOMSN=FPCONDOMSR=FPCONDOMST=FPOTHERN=FPOTHERR=FPOTHERT=FPCLIENTSN=FPCLIENTSR=FPCLIENTST=FPIUCDRemoval= //FPIMPLANTSRemoval="";" FamilyPlanninng = "" + "<fieldset class=\"formatter\"><legend class=\"formatter\"><b style=\"text-align:center;\"> FAMILY PLANNING </b></legend>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\"><tr>" + "<td colspan=\"2\" class=\"form-actions\"><b>A: Family Planning </b></td>" + "<td class=\"form-actions\"> <b>NEW CLIENTS </b></td>" + "<td class=\"form-actions\"> <b>RE-VISITS </b></td>" + "<td class=\"form-actions\"> <b>TOTAL </b></td>" + "</tr>" + "<tr>" + "<td rowspan=\"2\">1. PILLS</td><td >MICROLUT</td>" + "<td >" + FPMicrolutN + "</td>" + "<td >" + FPMicrolutR + "</td>" + "<td >" + FPMicrolutT + "</td>" + "<tr>" // + "<td>2</td>" // + "<td >PILLS</td>" + "<td >MICROGYNON</td>" + "<td >" + FPMicrogynonN + "</td>" + "<td >" + FPMicrogynonR + "</td>" + "<td >" + FPMicrogynonT + "</td>" + "</tr>" + "<tr>" + "<td >2. INJECTIONS</td>" + "<td >INJECTIONS</td>" + "<td >" + FPINJECTIONSN + "</td>" + "<td >" + FPINJECTIONSR + "</td>" + "<td >" + FPINJECTIONST + "</td>" + "</tr>" + "<tr>" + "<td >3. I.U.C.D.</td>" + "<td >Insertion</td>" + "<td >" + FPIUCDN + " </td>" + "<td >" + FPIUCDR + " </td>" + "<td >" + FPIUCDT + " </td>" + "</tr>" + "<tr>" + "<td >4. IMPLANTS</td><td >Insertion</td>" + "<td >" + FPIMPLANTSN + "</td>" + "<td >" + FPIMPLANTSR + "</td>" + "<td >" + FPIMPLANTST + "</td>" + "</tr>" + "<tr>" + "<td rowspan=\"2\">5. STERILIZATION</td><td >B.T.L</td>" + "<td >" + FPBTLN + "</td>" + "<td >" + FPBTLR + "</td>" + "<td >" + FPBTLT + "</td>" + "</tr>" + "<tr>" + "<td >Vasectomy</td>" + "<td >" + FPVasectomyN + "</td>" + "<td >" + FPVasectomyR + "</td>" + "<td >" + FPVasectomyT + "</td>" + "</tr>" + "<tr>" + "<td >6. CONDOMS</td><td >No. of clients receiving</td>" + "<td >" + FPCONDOMSN + "</td>" + "<td >" + FPCONDOMSR + "</td>" + "<td >" + FPCONDOMST + "</td>" + "</tr>" + "<tr>" + "<td >7. ALL OTHERS:(Specify)</td>" + "<td >" + FPOTHERN + "</td>" + "<td >" + FPOTHERR + "</td>" + "<td >" + FPOTHERT + "</td>" + "</tr>" + "<tr>" + "<td >8. TOTAL NO. OF CLIENTS</td>" + "<td ></td>" + "<td >" + FPCLIENTSN + "</td>" + "<td >" + FPCLIENTSR + "</td>" + "<td >" + FPCLIENTST + "</td>" + "</tr>" + "<tr>" + "<td >9. REMOVALS</td>" + "<td > IUCD </td>" + "<td >" + FPIUCDRemoval + "</td>" + "<td >IMPLANTS</td>" + "<td >" + FPIMPLANTSRemoval + "</td>" + "</tr></table></fieldset>"; FP_TAB += FamilyPlanninng; pmct += ""; pmct += "<fieldset class=\"formatter\"><legend class=\"formatter\"><b style=\"text-align:center;\"> B: MCH-ANC/PMTCT </b></legend>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\">" + "<tr>" + "<td class=\"form-actions\"><b> </b></td>" + "<td class=\"form-actions\"> <b>NEW </b></td>" + "<td class=\"form-actions\"> <b>RE-VISIT </b></td>" + "<td class=\"form-actions\"> <b>TOTAL </b></td>" + "</tr>" + "<tr>" + "<td>1.No of ANC Clients</td>" + "<td >" + PMCTA_1stVisit_ANC + "</td>" + "<td >" + PMCTA_ReVisit_ANC + "</td>" + "<td >" + PMCTANCClientsT + "</td>" + "</tr></table>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\"><tr>" + " <td colspan=\"3\" >2. No of clients with Hb <7 g/dl </td>" + "<td >" + PMCTHB7 + "</td>" + "</tr>" + "<tr>" + " <td colspan=\"3\" >3. No of clients given IPT (1st Dose) </td>" + "<td >" + PMCTIPT1 + " </td>" + "</tr>" + "<tr>" + " <td colspan=\"3\" >4. No of clients given IPT (2nd Dose) </td>" + "<td >" + PMCTIPT2 + "</td>" + "</tr>" + "<tr>" + "<td colspan=\"3\" >5. No of clients completed 4th Antenatal Visit </td>" + "<td >" + PMCTANCClients4 + "</td>" + "</tr>" + "<tr>" + "<tr>" + " <td colspan=\"3\" >6. No of ITNs distributed to ANC Clients </td>" + "<td >" + PMCTITN + "</td>" + "</tr></table></fieldset>" + "" + ""; MCH_TAB += pmct; //MATERNITY DELIVERIES // maternity MATNormalDelivery=MATCSection=""MATBreech=MATAssistedVag=MATDeliveryT=MATLiveBirth=MATStillBirth=MATWeight2500= //MATPreTerm= //MATDischargealive=MATReferral=MATNeoNatalD= //MATMaternalD=MATAPHAlive=MATAPHDead=MATPPHAlive=MATPPHDead=MATEclampAlive=MATEclampDead=MATRupUtAlive //=MATRupUtDead=MATObstrLaborAlive=MATObstrLaborDead=MATSepsisAlive=MATSepsisDead=""; maternity += ""; maternity += "<fieldset class=\"formatter\"><legend class=\"formatter\"><b style=\"text-align:center;\"> C: MATERNITY / SAFE DELIVERIES </b></legend>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\"><tr>" + "<td colspan=\"2\" class=\"form-actions\"><b></b></td>" + "<td colspan=\"2\" class=\"form-actions\"> <b>NUMBER </b></td>" + "</tr>" + "<tr>" + "<td>1.</td><td >Normal Deliveries </td>" + "<td colspan=\"2\">" + MATNormalDelivery + "</td>" + "</tr>" + "<tr>" + " <td>2.</td> <td > Caesarian Sections </td>" + "<td colspan=\"2\">" + MATCSection + "</td>" + "</tr>" + "<tr>" + " <td>3.</td> <td > Breech Delivery </td>" + "<td colspan=\"2\">" + MATBreech + "</td>" + "</tr>" + "<tr>" + " <td>4.</td> <td > Assisted vaginal delivery </td>" + "<td colspan=\"2\">" + MATAssistedVag + "</td>" + "</tr>" + "<tr>" + "<td>5.</td> <td > TOTAL DELIVERIES</td>" + "<td colspan=\"2\">" + MATDeliveryT + "</td>" + "</tr>" + "<tr>" + " <td>6.</td> <td > Live Births </td>" + "<td colspan=\"2\">" + MATLiveBirth + "</td>" + "</tr>" + "<tr>" + " <td>7.</td> <td > Still Births </td>" + "<td colspan=\"2\">" + MATStillBirth + "</td>" + "</tr>" + "<tr>" + " <td>8.</td> <td > Under Weight Babies (Weight below 2500 grams) </td>" + "<td colspan=\"2\">" + MATWeight2500 + "</td>" + "</tr>" + "<tr>" + " <td>9.</td> <td > Pre-Term babies </td>" + "<td colspan=\"2\">" + MATPreTerm + "</td>" + "</tr>" + "<tr>" + " <td>10.</td> <td > No of babies discharged alive </td>" + "<td style=\"padding-right:20px;\" colspan=\"2\" >" + MATDischargealive + "</td>" + "</tr>" + "<tr>" + " <td>11.</td> <td > Referrals </td>" + "<td colspan=\"2\">" + MATReferral + "</td>" + "</tr>" + "<tr>" + " <td>12.</td> <td > Neonatal Deaths </td>" + "<td colspan=\"2\">" + MATNeoNatalD + "</td>" + "</tr>" + "<tr>" + " <td>13.</td> <td > Maternal Deaths </td>" + "<td colspan=\"2\">" + MATMaternalD + "</td>" + "</tr>" + "<tr>" + " <td colspan=\"2\" class=\"form-actions\"><b> Maternal Complications </b></td>" + "<td class=\"form-actions\"><b>Alive </b></td>" + "<td class=\"form-actions\" ><b>Dead </b></td>" + "</tr>" + "<tr>" + " <td>14.</td> <td > A.P.H. (Ante Partum Haemorrhage) </td>" + "<td >" + MATAPHAlive + "</td>" + "<td >" + MATAPHDead + "</td>" + "</tr>" + "" + "<tr>" + " <td>15.</td> <td > P.P.H. (Post Partum Haemorrhage) </td>" + "<td >" + MATPPHAlive + "</td>" + "<td >" + MATPPHDead + "</td>" + "</tr>" + "<tr>" + " <td>16.</td> <td > Eclampsia</td>" + "<td >" + MATEclampAlive + "</td>" + "<td >" + MATEclampDead + "</td>" + "</tr>" + "<tr>" + " <td>17.</td> <td > Ruptured Uterus</td>" + "<td >" + MATRupUtAlive + "</td>" + "<td >" + MATRupUtDead + "</td>" + "</tr>" + "<tr>" + " <td>18.</td> <td > Obstructed Labour</td>" + "<td >" + MATObstrLaborAlive + "</td>" + "<td >" + MATObstrLaborDead + "</td>" + "</tr>" + "<tr>" + " <td>19.</td> <td > Sepsis</td>" + "<td >" + MATSepsisAlive + "</td>" + "<td >" + MATSepsisDead + "</td>" + "</tr>" + "" + "" + "</table></fieldset>" + "" + ""; MATERNITY_TAB += maternity; //MATAPHAlive=MATAPHDead=MATPPHAlive=MATPPHDead=MATEclampAlive=MATEclampDead=MATRupUtAlive //=MATRupUtDead=MATObstrLaborAlive=MATObstrLaborDead=MATSepsisAlive=MATSepsisDead=""; //vct vct += ""; vct += "<fieldset class=\"formatter\"><legend class=\"formatter\"><b style=\"text-align:center;\"> H: VCT </b></legend>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\">" + "<tr>" + "<td rowspan=\"2\" colspan=\"3\" class=\"form-actions\"><b></b></td>" + "<td colspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b>15-24 </b></td>" + "<td colspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b> >=25 Years </b></td>" + "<td rowspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b>TOTAL </b></td>" + "</tr>" + "<tr>" + "<td class=\"form-actions\" style=\"text-align:center;\"><b>F </b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>M </b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>F</b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>M </b></td>" + "</tr>" + "<tr>" + "<td rowspan=\"3\">1.</td><td rowspan=\"3\">VCT Clients</td>" + "<td>Counselled</td>" + "<td style=\"text-align:center;\" >" + VCTClient_Couns_CF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Couns_CM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Couns_AF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Couns_AM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Couns_TOT + "</td>" + "</tr>" + "<tr>" + "" + "<td>Tested</td>" + "<td style=\"text-align:center;\">" + VCTClient_Tested_CF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Tested_CM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Tested_AF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Tested_AM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_Tested_TOT + "</td>" + "</tr>" + "<tr>" + "" + "<td>HIV+</td>" + "<td style=\"text-align:center;\">" + VCTClient_HIV_CF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_HIV_CM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_HIV_AF + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_HIV_AM + "</td>" + "<td style=\"text-align:center;\">" + VCTClient_HIV_TOT + "</td>" + "</tr>" + "<tr>" + "<td rowspan=\"4\">2.</td><td rowspan=\"4\">No of couples</td>" + "<td>Counselled</td>" + "<td colspan=\"4\"> </td>" + "<td style=\"text-align:center;\">" + VCTPartner_Couns_TOT + "</td>" + "</tr>" + "<tr>" + "" + "<td>Tested</td>" + "<td colspan=\"4\"> </td>" + "<td style=\"text-align:center;\" >" + VCTPartner_Tested_TOT + "</td>" + "</tr>" + "<tr>" + "" + "<td>Both HIV+</td>" + "<td colspan=\"4\"> </td>" + "<td style=\"text-align:center;\">" + VCTPartner_HIV_TOT + "</td>" + "</tr>" + "<tr>" + "" + "<td>with discordant HIV+</td>" + "<td colspan=\"4\"> </td>" + "<td style=\"text-align:center;\" >" + VCTPartner_Disc_TOT + "</td>" + "</tr>" + "</table></fieldset>" + "" + ""; VCT_TAB += vct; // VCTClient_Couns_CM=VCTClient_Couns_CF=VCTClient_Couns_AM=VCTClient_Couns_AF=VCTClient_Couns_TOT= // VCTClient_Tested_CM=VCTClient_Tested_CF=VCTClient_Tested_AM=VCTClient_Tested_AF //=VCTClient_Tested_TOT=VCTClient_HIV_CM=VCTClient_HIV_CF=VCTClient_HIV_AM=VCTClient_HIV_AF=VCTClient_HIV_TOT //=VCTPartner_Couns_TOT=VCTPartner_Tested_TOT=VCTPartner_HIV_TOT=VCTPartner_Disc_TOT=""; // dtc dtc += ""; dtc += "<fieldset class=\"formatter\"><legend class=\"formatter\"><p id=\"demo\" hidden=\"true\"></p><b style=\"text-align:center;\"> I: DTC </b></legend>" + "<table frame=\"box\" style=\"border-color: #e5e5e5;margin-bottom: 3px; margin-left:150px; width:800px;\">" + "<tr>" + "<td rowspan=\"2\" colspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"><b>I: DTC </b></td>" + "<td colspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b>Children </b></td>" + "<td colspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b> Adults </b></td>" + "<td rowspan=\"2\" class=\"form-actions\" style=\"text-align:center;\"> <b>TOTAL </b></td>" + "</tr>" + "<tr>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>F </b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>M </b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>F </b></td>" + "<td class=\"form-actions\" style=\"text-align:center;\"> <b>M </b></td>" + "</tr>" + "<tr>" + "<td rowspan=\"2\">1. No. Counselled</td>" + "<td>Outpatient</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_Out_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_Out_CM + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_Out_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_Out_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_Out_Tot + "</td>" + "</tr>" + "<tr>" + "" + "<td>Inpatient</td>" + "<td style=\"text-align:center;\" >" + DTCA_Couns_In_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_In_CM + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_In_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_In_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCA_Couns_In_Tot + "</td>" + "</tr>" + "<tr>" + "<td rowspan=\"2\">2. No. tested</td><td>Outpatient</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_Out_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_Out_CM + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_Out_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_Out_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_Out_Tot + "</td>" + "</tr>" + "<tr>" + "<td>Inpatient</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_In_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_In_CM + "></td>" + "<td style=\"text-align:center;\">" + DTCB_Test_In_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_In_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCB_Test_In_Tot + "</td>" + "</tr>" + "<tr>" + "<td rowspan=\"2\">3. No. HIV+</td><td>Outpatient</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_Out_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_Out_CM + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_Out_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_Out_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_Out_Tot + "</td>" + "</tr>" + "<tr>" + "<td>Inpatient</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_In_CF + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_In_CM + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_In_AF + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_In_AM + "</td>" + "<td style=\"text-align:center;\">" + DTCC_HIV_In_Tot + "</td>" + "</tr>" + "</table></fieldset>"; DTC_TAB += dtc; // DTCA_Couns_In_CM=DTCA_Couns_In_CF=DTCA_Couns_In_AM=DTCA_Couns_In_AF=DTCA_Couns_In_Tot= //DTCA_Couns_Out_CM=DTCA_Couns_Out_CF=DTCA_Couns_Out_AM=DTCA_Couns_Out_AF=DTCA_Couns_Out_Tot= // DTCB_Test_In_CM=DTCB_Test_In_CF //=DTCB_Test_In_AM=DTCB_Test_In_AF=DTCB_Test_In_Tot=DTCB_Test_Out_CM=DTCB_Test_Out_CF=DTCB_Test_Out_AM=DTCB_Test_Out_AF // =DTCB_Test_Out_Tot=DTCC_HIV_In_CM=DTCC_HIV_In_CF=DTCC_HIV_In_AM //=DTCC_HIV_In_AF= DTCC_HIV_In_Tot= // DTCC_HIV_Out_CM=DTCC_HIV_Out_CF=DTCC_HIV_Out_AM=DTCC_HIV_Out_AF=DTCC_HIV_Out_Tot=Userid=""; FP_TAB += "</div></div></div>"; MCH_TAB += "</div></div></div>"; MATERNITY_TAB += "</div></div></div>"; VCT_TAB += "</div></div></div>"; DTC_TAB += "</div></div></div>"; // System.out.println("aaaaa"+FP_TAB);//} //System.out.println("aaaaa"+FP_TAB); try { Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream("D://testpdf2.pdf")); document.open(); document.addAuthor("Real Gagnon"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle("Please read this"); HTMLWorker htmlWorker = new HTMLWorker(document); String str = "<html><head></head><body>" + FP_TAB + " " + MCH_TAB + " " + MATERNITY_TAB + " " + VCT_TAB + " " + DTC_TAB + " </body></html>"; htmlWorker.parse(new StringReader(str)); document.close(); System.out.println("Done"); } catch (Exception e) { e.printStackTrace(); } System.out.println("PDF Created!"); }
From source file:ryerson.daspub.artifact.PublishQRTagSheetTask.java
License:Open Source License
/** * Write artifact tag sheet to a file./*from w w w . j a v a2s . co m*/ * @param Output * @throws DocumentException * @throws FileNotFoundException * @throws BadElementException * @throws MalformedURLException * @throws IOException */ public void writeTagSheet() throws DocumentException, FileNotFoundException, BadElementException, MalformedURLException, IOException { // get list of input files File[] files = inputDir.listFiles(new QRCodeImageFileFilter()); if (files != null && files.length > 0) { // create a new PDF document logger.log(Level.INFO, "Writing tag sheet \"{0}\"", outputFile.getAbsolutePath()); Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); document.addTitle("Artifact QR Code Labels"); document.open(); // generate page layouts with barcodes if (files != null) { int itemcount = 0; int pagecount = 1; for (int i = 0; i < files.length; i++) { if (itemcount == 0) { drawPageLabels(writer, pagecount); } Point p = layout.get(itemcount); drawTag(writer, files[i], p); itemcount++; if (itemcount > ITEMS_PER_PAGE - 1) { itemcount = 0; pagecount++; document.newPage(); } } } document.close(); } }
From source file:Servicios.ArchivoOrden.java
public void update(ScannerIOMetadata.Type type, ScannerIOMetadata metadata) { try {//from ww w.j a va 2s . c o m if (type.equals(ScannerIOMetadata.ACQUIRED)) { //****************obtenemos la nueva fecha Date fecha_orden = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");//YYYY-MM-DD HH:MM:SS String valor = dateFormat.format(fecha_orden); String[] fecha = valor.split("-"); String[] hora = fecha[2].split(":"); String[] aux = hora[0].split(" "); fecha[2] = aux[0]; hora[0] = aux[1]; Calendar calendario = Calendar.getInstance(); calendario.set(Integer.parseInt(fecha[2]), Integer.parseInt(fecha[1]) - 1, Integer.parseInt(fecha[0]), Integer.parseInt(hora[0]), Integer.parseInt(hora[1]), Integer.parseInt(hora[2])); boolean op = true; do { String nombre = ""; File destino = null; nombre = javax.swing.JOptionPane.showInputDialog(null, "Guardar como:"); if (nombre == null) nombre = ""; if (nombre.compareToIgnoreCase("") != 0) { File archivo = new File(ruta + "ordenes/" + orden + "/archivos/" + nombre + ".pdf"); if (archivo.exists()) { int opt = JOptionPane.showConfirmDialog(this, "El archivo ya existe desea remplazarlo", "Alerta", JOptionPane.YES_NO_OPTION); if (opt == 0) { BufferedImage image = metadata.getImage(); Document document = new Document(PageSize.LETTER, 36, 36, 54, 36); PdfWriter.getInstance(document, new FileOutputStream( ruta + "ordenes/" + orden + "/archivos/" + nombre + ".pdf")); document.open(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write((RenderedImage) image, "jpg", baos); baos.flush(); byte[] imagedata = baos.toByteArray(); Image imagen = Image.getInstance(imagedata); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleAbsolute(PageSize.LETTER.getWidth(), PageSize.LETTER.getHeight()); document.add(imagen); document.close(); Session session = HibernateUtil.getSessionFactory().openSession(); try { session.beginTransaction().begin(); int id = -1; Archivo ar = (Archivo) session.createCriteria(Archivo.class) .add(Restrictions.eq("orden.idOrden", ord.getIdOrden())) .add(Restrictions.eq("nombreDocumento", archivo.getName())) .setMaxResults(1).uniqueResult(); if (ar != null) { ar.setFechaDocumento(calendario.getTime()); session.update(ar); } else { ar = new Archivo(); Archivo img = new Archivo(ord, archivo.getName(), calendario.getTime()); ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); ord.addArchivo(img); session.save(ord); } session.getTransaction().commit(); } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); File file = new File(ruta + "ordenes/" + orden + "/archivos/" + nombre + ".pdf"); Desktop.getDesktop().open(file); op = false; } } else { BufferedImage image = metadata.getImage(); Document document = new Document(PageSize.LETTER, 36, 36, 54, 36); PdfWriter.getInstance(document, new FileOutputStream( ruta + "ordenes/" + orden + "/archivos/" + nombre + ".pdf")); document.open(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write((RenderedImage) image, "jpg", baos); baos.flush(); byte[] imagedata = baos.toByteArray(); Image imagen = Image.getInstance(imagedata); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleAbsolute(PageSize.LETTER.getWidth(), PageSize.LETTER.getHeight()); document.add(imagen); document.close(); Session session = HibernateUtil.getSessionFactory().openSession(); try { session.beginTransaction().begin(); int id = -1; Archivo ar = (Archivo) session.createCriteria(Archivo.class) .add(Restrictions.eq("orden.idOrden", ord.getIdOrden())) .add(Restrictions.eq("nombreDocumento", archivo.getName())).setMaxResults(1) .uniqueResult(); ar = new Archivo(); Archivo img = new Archivo(ord, archivo.getName(), calendario.getTime()); ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); ord.addArchivo(img); session.save(ord); session.getTransaction().commit(); } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); File file = new File(ruta + "ordenes/" + orden + "/archivos/" + nombre + ".pdf"); Desktop.getDesktop().open(file); op = false; } } } while (op); cargaArchivos(); } else if (type.equals(ScannerIOMetadata.STATECHANGE)) { System.out.println(metadata.getStateStr()); } else if (type.equals(ScannerIOMetadata.EXCEPTION)) { metadata.getException().printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } }