List of usage examples for com.itextpdf.text Document addCreationDate
public boolean addCreationDate()
From source file:org.opentox.io.publishable.PDFObject.java
License:Open Source License
public void publish(YaqpIOStream stream) throws YaqpException { if (stream == null) { throw new NullPointerException("Cannot public pdf to a null output stream"); }/*from w ww .j a v a2 s. co m*/ try { Document doc = new Document(); try { PdfWriter.getInstance(doc, (OutputStream) stream.getStream()); } catch (ClassCastException ex) { throw new ClassCastException("The stream you provided is not a valid output stream"); } doc.open(); doc.addAuthor(pdfAuthor); doc.addCreationDate(); doc.addProducer(); doc.addSubject(subject); doc.addCreator(pdfCreator); doc.addTitle(pdfTitle); doc.addKeywords(pdfKeywords); doc.addHeader("License", "GNU GPL v3"); Image image = null; try { image = Image.getInstance(new URL(OpenToxLogoUrl)); } catch (Exception ex) {// OpenTox Logo was not found on the web... try {// use the cached image instead YaqpLogger.LOG.log(new Trace(getClass(), "OpenTox Logo not found at " + OpenToxLogoUrl)); image = Image.getInstance(alternativeLogoPath); } catch (Exception ex1) {// if no image at local folder YaqpLogger.LOG.log(new Debug(getClass(), "OpenTox Logo not found at " + alternativeLogoPath + " :: " + ex1)); } } if (image != null) { image.scalePercent(40); image.setAnnotation(new Annotation(0, 0, 0, 0, "http://opentox.org")); Chunk ck_ot = new Chunk(image, -5, -30); doc.add(ck_ot); } try { Image yaqp = Image.getInstance(yaqpLogo); yaqp.scalePercent(30); yaqp.setAnnotation(new Annotation(0, 0, 0, 0, "https://opentox.ntua.gr")); yaqp.setAlt("YAQP(R), yet another QSAR Project"); Chunk ck_yaqp = new Chunk(yaqp, 15, -30); doc.add(ck_yaqp); } catch (Exception ex) { YaqpLogger.LOG .log(new Warning(getClass(), "YAQP Logo not found at " + kinkyDesignLogo + " :: " + ex)); } doc.add(new Paragraph("\n\n\n")); for (Element e : elements) { doc.add(e); } doc.close(); } catch (DocumentException ex) { String message = "Error while generating PDF representation."; YaqpLogger.LOG.log(new Warning(getClass(), message)); throw new YaqpException(XPDF18, message, ex); } }
From source file:org.restate.project.controller.PaymentReceiptController.java
License:Open Source License
@RequestMapping(method = RequestMethod.GET, value = "receipt.print") public void downloadDocument(HttpServletResponse response, @RequestParam(value = "id", required = false) Integer id) throws Exception { if (id == null) { return;/* ww w. j a v a 2 s . co m*/ } // creation of the document with a certain size and certain margins // may want to use PageSize.LETTER instead // Document document = new Document(PageSize.A4, 50, 50, 50, 50); Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); File tmpFile = File.createTempFile("paymentReceipt", ".pdf"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(tmpFile)); //document header attributes doc.addAuthor("betterThanZero"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("MySampleCode.com"); doc.addTitle("Report with Column Headings"); doc.setPageSize(PageSize.LETTER); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("iText is a library that allows you to create and " + "manipulate PDF documents. It enables developers looking to enhance web and other " + "applications with dynamic PDF document generation and/or manipulation."); //specify column widths float[] columnWidths = { 1.5f, 2f, 5f, 2f }; //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); //insert column headings insertCell(table, "Order No", Element.ALIGN_RIGHT, 1, bfBold12); insertCell(table, "Account No", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Account Name", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Order Total", Element.ALIGN_RIGHT, 1, bfBold12); table.setHeaderRows(1); //insert an empty row insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12); //create section heading by cell merging insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12); double orderTotal, total = 0; //just some random data to fill for (int x = 1; x < 5; x++) { insertCell(table, "10010" + x, Element.ALIGN_RIGHT, 1, bf12); insertCell(table, "ABC00" + x, Element.ALIGN_LEFT, 1, bf12); insertCell(table, "This is Customer Number ABC00" + x, Element.ALIGN_LEFT, 1, bf12); orderTotal = Double.valueOf(df.format(Math.random() * 1000)); total = total + orderTotal; insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12); } //merge the cells to create a footer for that section insertCell(table, "New York Total...", Element.ALIGN_RIGHT, 3, bfBold12); insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12); //repeat the same as above to display another location insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12); insertCell(table, "California Orders ...", Element.ALIGN_LEFT, 4, bfBold12); orderTotal = 0; for (int x = 1; x < 7; x++) { insertCell(table, "20020" + x, Element.ALIGN_RIGHT, 1, bf12); insertCell(table, "XYZ00" + x, Element.ALIGN_LEFT, 1, bf12); insertCell(table, "This is Customer Number XYZ00" + x, Element.ALIGN_LEFT, 1, bf12); orderTotal = Double.valueOf(df.format(Math.random() * 1000)); total = total + orderTotal; insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12); } insertCell(table, "California Total...", Element.ALIGN_RIGHT, 3, bfBold12); insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12); //add the PDF table to the paragraph paragraph.add(table); // add the paragraph to the document doc.add(paragraph); } catch (DocumentException dex) { dex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } response.setHeader("Content-disposition", "attachment; filename=" + "sampleDoc" + ".pdf"); response.setContentType("application/pdf"); OutputStream outputStream = response.getOutputStream(); FileInputStream fileInputStream = new FileInputStream(tmpFile); IOUtils.copy(fileInputStream, outputStream); fileInputStream.close(); outputStream.flush(); tmpFile.delete(); } }
From source file:org.spinsuite.print.ReportPrintData.java
License:Open Source License
/** * Create a PDF File/*w ww .jav a 2 s . c om*/ * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com 02/04/2014, 22:52:09 * @param outFile * @throws FileNotFoundException * @throws DocumentException * @return void */ private void createPDF(File outFile) throws FileNotFoundException, DocumentException { Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile)); PDFHeaderAndFooter event = new PDFHeaderAndFooter(); writer.setPageEvent(event); document.open(); // document.addAuthor(ctx.getResources().getString(R.string.app_name)); document.addCreationDate(); // Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName()); // Set Font title.getFont().setStyle(Font.BOLD); // Set Alignment title.setAlignment(Paragraph.ALIGN_CENTER); // Add Title document.add(title); // Add New Line document.add(Chunk.NEWLINE); // Parameters ProcessInfoParameter[] param = m_pi.getParameter(); // Get Parameter if (param != null) { // boolean isFirst = true; // Iterate for (ProcessInfoParameter para : param) { // Get SQL Name String name = para.getInfo(); StringBuffer textParameter = new StringBuffer(); if (para.getParameter() == null && para.getParameter_To() == null) continue; else { // Add Parameters Title if (isFirst) { Paragraph titleParam = new Paragraph( ctx.getResources().getString(R.string.msg_ReportParameters)); // Set Font titleParam.getFont().setStyle(Font.BOLDITALIC); // Add to Document document.add(titleParam); isFirst = false; } // Add Parameters Name if (para.getParameter() != null && para.getParameter_To() != null) { // From and To is filled // textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ") .append(para.getDisplayValue_To()); } else if (para.getParameter() != null) { // Only From // textParameter.append(name).append(" = ").append(para.getDisplayValue()); } else if (para.getParameter_To() != null) { // Only To // textParameter.append(name).append(" <= ").append(para.getDisplayValue_To()); } } // Add to Document Paragraph viewParam = new Paragraph(textParameter.toString()); document.add(viewParam); } } document.add(Chunk.NEWLINE); // InfoReportField[] columns = m_reportQuery.getColumns(); // Add Table PdfPTable table = new PdfPTable(columns.length); table.setSpacingBefore(4); // Add Header PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName())); headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerCell.setColspan(columns.length); // Add to Table table.addCell(headerCell); // Add Header // Decimal and Date Format DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length]; SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length]; for (int i = 0; i < columns.length; i++) { InfoReportField column = columns[i]; // Only Numeric if (DisplayType.isNumeric(column.DisplayType)) cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern); // Only Date else if (DisplayType.isDate(column.DisplayType)) cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern); // Phrase phrase = new Phrase(column.PrintName); PdfPCell cell = new PdfPCell(phrase); if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // table.addCell(cell); } // Add Detail for (int row = 0; row < m_data.size(); row++) { // Get Row RowPrintData rPrintData = m_data.get(row); // Iterate for (int col = 0; col < columns.length; col++) { InfoReportField column = columns[col]; ColumnPrintData cPrintData = rPrintData.get(col); Phrase phrase = null; PdfPCell cell = new PdfPCell(); // String value = cPrintData.getValue(); // Only Values if (value != null) { if (DisplayType.isNumeric(column.DisplayType)) { // Number // Format DecimalFormat decimalFormat = cDecimalFormat[col]; // Format if (decimalFormat != null) value = decimalFormat.format(DisplayType.getNumber(value)); // Set Value cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } else if (DisplayType.isDate(column.DisplayType)) { // Is Date SimpleDateFormat dateFormat = cDateFormat[col]; if (dateFormat != null && value.trim().length() > 0) { long date = Long.parseLong(value); value = dateFormat.format(new Date(date)); } } } // Set Value phrase = new Phrase(value); // if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // Set Font if (rPrintData.isFunctionRow()) { // Set Function Value if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0) phrase = new Phrase(cPrintData.getFunctionValue()); // Set Font phrase.getFont().setStyle(Font.BOLDITALIC); } // Add to Table cell.setPhrase(phrase); table.addCell(cell); } } // Add Table to Document document.add(table); // New Line document.add(Chunk.NEWLINE); // Add Footer StringBuffer footerText = new StringBuffer(Env.getContext("#SUser")); footerText.append("("); footerText.append(Env.getContext("#AD_Role_Name")); footerText.append("@"); footerText.append(Env.getContext("#AD_Client_Name")); footerText.append("."); footerText.append(Env.getContext("#AD_Org_Name")); footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) "); // Date SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME); footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = "); footerText.append(pattern.format(new Date())); // Paragraph footer = new Paragraph(footerText.toString()); footer.setAlignment(Paragraph.ALIGN_CENTER); // Set Font footer.getFont().setSize(8); // Add Footer document.add(footer); // Close Document document.close(); }
From source file:org.spinsuite.view.report.ReportPrintData.java
License:Open Source License
/** * Create a PDF File//from ww w. ja va 2 s. c o m * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 02/04/2014, 22:52:09 * @param outFile * @throws FileNotFoundException * @throws DocumentException * @return void */ private void createPDF(File outFile) throws FileNotFoundException, DocumentException { Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile)); PDFHeaderAndFooter event = new PDFHeaderAndFooter(); writer.setPageEvent(event); document.open(); // document.addAuthor(ctx.getResources().getString(R.string.app_name)); document.addCreationDate(); // Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName()); // Set Font title.getFont().setStyle(Font.BOLD); // Set Alignment title.setAlignment(Paragraph.ALIGN_CENTER); // Add Title document.add(title); // Add New Line document.add(Chunk.NEWLINE); // Parameters ProcessInfoParameter[] param = m_pi.getParameter(); // Get Parameter if (param != null) { // boolean isFirst = true; // Iterate for (ProcessInfoParameter para : param) { // Get SQL Name String name = para.getInfo(); StringBuffer textParameter = new StringBuffer(); if (para.getParameter() == null && para.getParameter_To() == null) continue; else { // Add Parameters Title if (isFirst) { Paragraph titleParam = new Paragraph( ctx.getResources().getString(R.string.msg_ReportParameters)); // Set Font titleParam.getFont().setStyle(Font.BOLDITALIC); // Add to Document document.add(titleParam); isFirst = false; } // Add Parameters Name if (para.getParameter() != null && para.getParameter_To() != null) { // From and To is filled // textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ") .append(para.getDisplayValue_To()); } else if (para.getParameter() != null) { // Only From // textParameter.append(name).append(" = ").append(para.getDisplayValue()); } else if (para.getParameter_To() != null) { // Only To // textParameter.append(name).append(" <= ").append(para.getDisplayValue_To()); } } // Add to Document Paragraph viewParam = new Paragraph(textParameter.toString()); document.add(viewParam); } } document.add(Chunk.NEWLINE); // InfoReportField[] columns = m_reportQuery.getColumns(); // Add Table PdfPTable table = new PdfPTable(columns.length); table.setSpacingBefore(4); // Add Header PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName())); headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerCell.setColspan(columns.length); // Add to Table table.addCell(headerCell); // Add Header // Decimal and Date Format DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length]; SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length]; for (int i = 0; i < columns.length; i++) { InfoReportField column = columns[i]; // Only Numeric if (DisplayType.isNumeric(column.DisplayType)) cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern); // Only Date else if (DisplayType.isDate(column.DisplayType)) cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern); // Phrase phrase = new Phrase(column.PrintName); PdfPCell cell = new PdfPCell(phrase); if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // table.addCell(cell); } // Add Detail for (int row = 0; row < m_data.size(); row++) { // Get Row RowPrintData rPrintData = m_data.get(row); // Iterate for (int col = 0; col < columns.length; col++) { InfoReportField column = columns[col]; ColumnPrintData cPrintData = rPrintData.get(col); Phrase phrase = null; PdfPCell cell = new PdfPCell(); // String value = cPrintData.getValue(); if (DisplayType.isNumeric(column.DisplayType)) { // Number // Format DecimalFormat decimalFormat = cDecimalFormat[col]; // Format if (decimalFormat != null) value = decimalFormat.format(DisplayType.getNumber(value)); // Set Value cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } else if (DisplayType.isDate(column.DisplayType)) { // Is Date SimpleDateFormat dateFormat = cDateFormat[col]; if (dateFormat != null) { long date = Long.getLong(value, 0); value = dateFormat.format(new Date(date)); } } // Set Value phrase = new Phrase(value); // if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // Set Font if (rPrintData.isFunctionRow()) { // Set Function Value if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0) phrase = new Phrase(cPrintData.getFunctionValue()); // Set Font phrase.getFont().setStyle(Font.BOLDITALIC); } // Add to Table cell.setPhrase(phrase); table.addCell(cell); } } // Add Table to Document document.add(table); // New Line document.add(Chunk.NEWLINE); // Add Footer StringBuffer footerText = new StringBuffer(Env.getContext(ctx, "#SUser")); footerText.append("("); footerText.append(Env.getContext(ctx, "#AD_Role_Name")); footerText.append("@"); footerText.append(Env.getContext(ctx, "#AD_Client_Name")); footerText.append("."); footerText.append(Env.getContext(ctx, "#AD_Org_Name")); footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) "); // Date SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME); footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = "); footerText.append(pattern.format(new Date())); // Paragraph footer = new Paragraph(footerText.toString()); footer.setAlignment(Paragraph.ALIGN_CENTER); // Set Font footer.getFont().setSize(8); // Add Footer document.add(footer); // Close Document document.close(); }
From source file:pdf.CoverLetterUtility.java
License:Apache License
public void createPdf() { System.out.println("Creating cover letter..."); Document document = new Document(); document.setPageSize(PageSize.A4);//from w w w . jav a 2s. c o m document.setMargins(62, 48, 36, 36); baos = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, baos); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } document.open(); document.addAuthor("vitaelifetime@gmail.com"); document.addCreationDate(); addTitle(document); addReference(document); addSalutation(document); addIntroduction(document); addWhyMe(document); addWhyYou(document); addConclusion(document); document.close(); }
From source file:pdfcreator.PDFCreator.java
License:Open Source License
@SuppressWarnings("static-access") protected void createPdf(String filename, String[] images) throws Exception { Document doc = new Document(); PdfWriter writer;//w w w . j a v a 2 s . c o m if (pdfxConformance.equals("PDFA1A")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_1A); } else if (pdfxConformance.equals("PDFA1B")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_1B); } else if (pdfxConformance.equals("PDFA2A")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_2A); } else if (pdfxConformance.equals("PDFA2B")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_2B); } else if (pdfxConformance.equals("PDFA3A")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_3A); } else if (pdfxConformance.equals("PDFA3B")) { writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_3B); } else { writer = PdfWriter.getInstance(doc, new FileOutputStream(filename)); } if (pdfVersion.equals("1.4")) { writer.setPdfVersion(PdfWriter.VERSION_1_4); } else if (pdfVersion.equals("1.5")) { writer.setPdfVersion(PdfWriter.VERSION_1_5); } else if (pdfVersion.equals("1.6")) { writer.setPdfVersion(PdfWriter.VERSION_1_6); } else if (pdfVersion.equals("1.7")) { writer.setPdfVersion(PdfWriter.VERSION_1_7); } else { writer.setPdfVersion(PdfWriter.VERSION_1_4); } verbose(filename + ": open"); doc.addCreationDate(); doc.addCreator(creator); if (title != null) { doc.addTitle(title); } for (int i = 0; i < images.length; i++) { verbose(" +" + images[i]); Image img = Image.getInstance(images[i]); doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); doc.setMargins(0, 0, 0, 0); if (doc.isOpen()) { doc.newPage(); } else { doc.open(); } doc.add(img); doc.newPage(); } ICC_Profile icc = getImageColorProfile(images[0]); if (icc == null) { System.err.println("warning: no color profile available in " + images[0] + " using " + profileName); icc = getDefaultColorProfile(); } writer.setOutputIntents("Custom", "", null, null, icc); writer.createXmpMetadata(); doc.close(); verbose(filename + ": close"); }
From source file:printInv.GenerateInvoice.java
private void createPDF(String pdfFilename) { Document doc = new Document(); PdfWriter docWriter = null;/*from w ww. j av a 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:qedit.export.PDFObject.java
License:GNU General Public License
public void publish(OutputStream stream) throws Exception { if (stream == null) { throw new NullPointerException("Cannot public pdf to a null output stream"); }/* w ww. j a v a 2 s . co m*/ try { /* * Initialize the document... */ Document doc = new Document(); try { PdfWriter.getInstance(doc, stream); } catch (ClassCastException ex) { throw new ClassCastException("The stream you provided is not a valid output stream"); } doc.open(); /* * Meta-information about the document... */ doc.addAuthor(pdfAuthor); doc.addCreationDate(); doc.addProducer(); doc.addSubject(subject); doc.addCreator(pdfCreator); doc.addTitle(pdfTitle); doc.addKeywords(pdfKeywords); doc.addHeader("License", "GNU GPL v3"); doc.add(new Paragraph("\n\n\n")); for (Element e : elements) { doc.add(e); } doc.close(); } catch (DocumentException ex) { throw new DocumentException("Error while generating PDF representation."); } }
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 . ja v a 2 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:ro.ldir.chartpackage.GarbagePackageBuilder.java
License:Open Source License
public void writePDF(OutputStream out) throws DocumentException, MalformedURLException, XPathExpressionException, IOException { BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, "Cp1250", BaseFont.NOT_EMBEDDED); final Font hfFont = new Font(bf, 8, Font.NORMAL, BaseColor.GRAY); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, out); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); writer.setPageEvent(new PdfPageEventHelper() { private int page = 0; @Override/*from w ww . j a va 2 s. c om*/ public void onEndPage(PdfWriter writer, Document arg1) { page++; Rectangle rect = writer.getBoxSize("art"); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("Pachet mormane - \u00a9 Let's Do It, Romania!", hfFont), (rect.getLeft() + rect.getRight()) / 2, rect.getTop() + 18, 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("- " + page + " -", hfFont), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0); } }); document.open(); document.addAuthor("Let's Do It, Romania!"); document.addTitle("Pachet mormane"); document.addCreationDate(); Font titleFont = new Font(bf, 24, Font.BOLD); Font noteFont = new Font(bf, 12, Font.NORMAL, BaseColor.RED); Font headerFont = new Font(bf, 12, Font.BOLD); Font normalFont = new Font(bf, 11); Font defFont = new Font(bf, 11, Font.BOLD); Paragraph par; int page = 0; for (Garbage garbage : garbages) { par = new Paragraph(); par.setAlignment(Element.ALIGN_CENTER); par.add(new Chunk("Morman " + garbage.getGarbageId() + "\n", titleFont)); par.add(new Chunk("Citi\u0163i cu aten\u0163ie!", noteFont)); document.add(par); par = new Paragraph(); par.setSpacingBefore(20); par.add(new Chunk("1. Date generale\n", headerFont)); par.add(new Chunk("Jude\u0163ul: ", defFont)); par.add(new Chunk(garbage.getCounty().getName() + "\n", normalFont)); par.add(new Chunk("Comuna: ", defFont)); par.add(new Chunk(garbage.getTown().getName() + "\n", normalFont)); if (garbage.getChartedArea() != null) { par.add(new Chunk("Zona cartare: ", defFont)); par.add(new Chunk(garbage.getChartedArea().getName() + "\n", normalFont)); } par.add(new Chunk("Pozi\u0163ie: ", defFont)); par.add(new Chunk(garbage.getY() + ", " + garbage.getX() + "\n", normalFont)); par.add(new Chunk("Descriere:\n", defFont)); par.add(new Phrase(garbage.getDescription() + "\n", normalFont)); par.add(new Chunk("Componen\u0163\u0103 gunoi:\n", defFont)); List list = new List(); list.add(new ListItem( new Chunk("Procent plastic: " + garbage.getPercentagePlastic() + "%", normalFont))); list.add(new ListItem( new Chunk("Procent sticl\u0103: " + garbage.getPercentageGlass() + "%", normalFont))); list.add(new ListItem(new Chunk("Procent metale: " + garbage.getPercentageMetal() + "%", normalFont))); list.add(new ListItem( new Chunk("Procent nereciclabile: " + garbage.getPercentageWaste() + "%", normalFont))); par.add(list); document.add(par); par = new Paragraph(); par.setSpacingBefore(20); par.add(new Chunk("2. Indica\u0163ii rutiere\n", headerFont)); Image img = Image.getInstance(getImage(garbage)); img.scaleToFit((float) (PageSize.A4.getWidth() * .75), (float) (PageSize.A4.getHeight() * .75)); img.setAlignment(Element.ALIGN_CENTER); par.add(img); document.add(par); if (page < garbages.size() - 1) document.newPage(); page++; } document.close(); }