List of usage examples for com.lowagie.text.pdf PdfPCell setBorder
public void setBorder(int border)
From source file:permit.PermitPdf.java
License:Open Source License
/** * handles the letter header/*w w w .j a va2 s .c o m*/ */ PdfPTable getHeader() { // String str = ""; String spacer = " "; // PdfPTable headTable = null; try { // // for http url use // Image image = Image.getInstance(url + "js/images/city_logo3.jpg"); Font fnt = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL); Font fntb = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); float[] widths = { 25f, 40f, 35f }; // percentages headTable = new PdfPTable(widths); headTable.setWidthPercentage(100); headTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); headTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // image.setWidthPercentage(33.0f); image.scalePercent(15f); PdfPCell cell = new PdfPCell(image); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headTable.addCell(cell); // float[] width = { 33f }; PdfPTable midTable = new PdfPTable(width); midTable.setWidthPercentage(33); midTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); midTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); Phrase phrase = new Phrase(); Chunk ch = new Chunk("City of Bloomington ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("Planning and Transportation Department ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("bloomington.in.gov", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // headTable.addCell(midTable); // PdfPTable rightTable = new PdfPTable(width); rightTable.setWidthPercentage(33); rightTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); rightTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); phrase = new Phrase(); ch = new Chunk("401 N Morton St Suite 130 ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("PO Box 100 \nBloomington, IN 47404", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("\n Phone: (812) 349-3423\nFax (812) 349-3520\nEmail: planning@bloomington.in.gov", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); headTable.addCell(rightTable); } catch (Exception ex) { logger.error(ex); } return headTable; }
From source file:permit.PermitPdf.java
License:Open Source License
void writePage(HttpServletResponse res, Permit permit) { ///*from w ww .ja v a 2 s. co m*/ // paper size legal (A4) 8.5 x 11 // page 1-inch = 72 points // String fileName = "row_permit_" + permit.getId() + ".pdf"; Rectangle pageSize = new Rectangle(612, 792); // 8.5" X 11" Document document = new Document(pageSize, 36, 36, 18, 18); ServletOutputStream out = null; Font fnt = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL); Font fntb = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); Font fnts = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL); Font fntbs = new Font(Font.TIMES_ROMAN, 8, Font.BOLD); String spacer = " "; PdfPTable header = getHeader(); Bond bond = permit.getBond(); Invoice invoice = permit.getInvoice(); if (bond == null) bond = new Bond(); if (invoice == null) invoice = new Invoice(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); String str = ""; document.open(); document.add(header); // // title float[] width = { 100f }; // one cell PdfPTable table = new PdfPTable(width); table.setWidthPercentage(100.0f); PdfPCell cell = new PdfPCell(new Phrase("Right Of Way Excavation Permit", fntb)); // cell.setBorder(Rectangle.BOTTOM); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); document.add(table); // // we need these later Paragraph pp = new Paragraph(); Chunk ch = new Chunk(" ", fntb); Phrase phrase = new Phrase(); // float[] widths = { 14f, 20f, 17f, 18f, 13f, 20f }; // percentages table = new PdfPTable(widths); table.setWidthPercentage(100.0f); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); // // first row cell = new PdfPCell(new Phrase("Company", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getCompany().getName(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Status", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getStatus(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Permit", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getPermit_num(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); // // 2nd row // cell = new PdfPCell(new Phrase("Responsible", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getContact().getFullName(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Inspector", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getReviewer().getFullName(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Date Issued", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getDate(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); // // 3rd row cell = new PdfPCell(new Phrase("Project", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getProject(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Permit Fee", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("$" + permit.getFee(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Start Date", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(permit.getStart_date(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); // // 4th row cell = new PdfPCell(new Phrase("Bond Amount", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("$" + bond.getAmount(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Expiration Date", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(bond.getExpire_date(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Invoice", fntb)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(invoice.getStatus(), fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); document.add(table); // phrase = new Phrase(new Chunk(spacer, fnt)); document.add(phrase); // float[] widths2 = { 25f, 15f, 15f, 25f, 10f, 10f }; table = new PdfPTable(widths2); table.setWidthPercentage(100.0f); cell = new PdfPCell(new Phrase("Address", fntb)); table.addCell(cell); cell = new PdfPCell(new Phrase("Cut Type", fntb)); table.addCell(cell); cell = new PdfPCell(new Phrase("Utility", fntb)); table.addCell(cell); cell = new PdfPCell(new Phrase("Description", fntb)); table.addCell(cell); cell = new PdfPCell(new Phrase("Width", fntb)); table.addCell(cell); cell = new PdfPCell(new Phrase("Length", fntb)); table.addCell(cell); List<Excavation> list = permit.getExcavations(); if (list != null && list.size() > 0) { for (Excavation one : list) { cell = new PdfPCell(new Phrase(one.getAddress().getAddress(), fnt)); table.addCell(cell); cell = new PdfPCell(new Phrase(one.getCut_type(), fnt)); table.addCell(cell); cell = new PdfPCell(new Phrase(one.getUtility_type().getName(), fnt)); table.addCell(cell); cell = new PdfPCell(new Phrase(one.getCut_description(), fnt)); table.addCell(cell); cell = new PdfPCell(new Phrase(one.getWidth(), fnt)); table.addCell(cell); cell = new PdfPCell(new Phrase(one.getLength(), fnt)); table.addCell(cell); } } document.add(table); // pp = new Paragraph(); pp.setIndentationLeft(12); pp.setAlignment(Element.ALIGN_LEFT); pp.setLeading(0f, 1f); ch = new Chunk("\nSpecial Provisions\n", fntb); phrase = new Phrase(); phrase.add(ch); ch = new Chunk(permit.getNotes() + "\n", fnt); phrase.add(ch); pp.add(phrase); document.add(pp); // pp = new Paragraph(); pp.setIndentationLeft(12); pp.setAlignment(Element.ALIGN_LEFT); ch = new Chunk("Standards Conditions of Approval\n", fntb); phrase = new Phrase(); phrase.add(ch); pp.add(phrase); document.add(pp); // pp = new Paragraph(); pp.setIndentationLeft(12); pp.setAlignment(Element.ALIGN_LEFT); pp.setLeading(0f, 1f); ch = new Chunk("1 - " + conditions[0] + "\n", fntbs); phrase = new Phrase(); phrase.add(ch); pp.add(phrase); document.add(pp); // int jj = 1; for (int j = 1; j < conditions.length; j++) { jj = j + 1; pp = new Paragraph(); pp.setLeading(0f, 1f); pp.setIndentationLeft(12); pp.setAlignment(Element.ALIGN_LEFT); ch = new Chunk(jj + " - " + conditions[j] + "\n", fnts); phrase = new Phrase(); phrase.add(ch); pp.add(phrase); document.add(pp); } pp = new Paragraph(); pp.setIndentationLeft(20); pp.setAlignment(Element.ALIGN_RIGHT); ch = new Chunk("\n\n___________________\n", fnt); phrase = new Phrase(); phrase.add(ch); pp.add(phrase); ch = new Chunk(permit.getReviewer().getFullName(), fnt); phrase = new Phrase(); phrase.add(ch); pp.add(phrase); document.add(pp); document.close(); writer.close(); res.setHeader("Expires", "0"); res.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); res.setHeader("Content-Disposition", "attachment; filename=" + fileName); res.setHeader("Pragma", "public"); // // setting the content type res.setContentType("application/pdf"); // // the contentlength is needed for MSIE!!! res.setContentLength(baos.size()); // out = res.getOutputStream(); if (out != null) { baos.writeTo(out); } } catch (Exception ex) { logger.error(ex); } }
From source file:permit.ReceiptPdf.java
License:Open Source License
void writePages(HttpServletResponse res, Receipt receipt) { ///*w w w . j a v a 2s .co m*/ // paper size legal (A4) 8.5 x 11 // page 1-inch = 72 points // Invoice invoice = receipt.getInvoice(); String fileName = "row_receipt_" + receipt.getId() + ".pdf"; Rectangle pageSize = new Rectangle(612, 792); // 8.5" X 11" Document document = new Document(pageSize, 36, 36, 18, 18); ServletOutputStream out = null; Font fnt = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL); Font fntb = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); Font fnts = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL); Font fntbs = new Font(Font.TIMES_ROMAN, 8, Font.BOLD); String spacer = " "; PdfPTable header = getHeader(); Company company = invoice.getCompany(); Contact contact = null; if (invoice.hasContact()) { contact = invoice.getContact(); } List<Page> pages = invoice.getPages(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); String str = ""; document.open(); document.add(header); // // title float[] width = { 100f }; // one cell PdfPTable table = new PdfPTable(width); table.setWidthPercentage(100.0f); PdfPCell cell = new PdfPCell(new Phrase("RECEIPT", fntb)); // cell.setBorder(Rectangle.BOTTOM); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); document.add(table); // // we need these later Paragraph pp = new Paragraph(); Chunk ch = new Chunk(" ", fntb); Phrase phrase = new Phrase(); // float[] widths = { 35f, 30f, 35f }; // percentages table = new PdfPTable(widths); table.setWidthPercentage(100.0f); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); // // first row float[] widthOne = { 100f }; PdfPTable leftTable = new PdfPTable(widthOne); leftTable.setWidthPercentage(35.0f); leftTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // if (company != null) { ch = new Chunk("Company\n", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); leftTable.addCell(cell); phrase = new Phrase(); ch = new Chunk(company.getName() + "\n", fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); leftTable.addCell(cell); } if (contact != null) { phrase = new Phrase(); ch = new Chunk(contact.getFullName(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); leftTable.addCell(cell); phrase = new Phrase(); ch = new Chunk(contact.getAddress(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); leftTable.addCell(cell); ch = new Chunk(contact.getCityStateZip(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); leftTable.addCell(cell); } table.addCell(leftTable); // // middle cell // cell = new PdfPCell(new Phrase(spacer, fnt)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); // float[] widths2 = { 50f, 50f }; // percentages PdfPTable rightTable = new PdfPTable(widths2); rightTable.setWidthPercentage(35.0f); rightTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // ch = new Chunk("Receipt No.", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk(receipt.getId(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("Invoice No.", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk(invoice.getInvoice_num(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("Receipt Date", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk(receipt.getDate(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("Amount Paid $", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("$" + receipt.getAmount_paid(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("Payment Method ", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk(receipt.getPayment_type(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // table.addCell(rightTable); // document.add(table); // phrase = new Phrase(new Chunk(spacer, fnt)); document.add(phrase); // int jj = 0; if (pages != null) { for (Page page : pages) { jj++; PdfPTable borderTable = new PdfPTable(widthOne); borderTable.setWidthPercentage(100.0f); borderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); float[] widthTwo = { 50f, 50f }; PdfPTable titleTable = new PdfPTable(widthTwo); titleTable.setWidthPercentage(75.0f); titleTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); phrase = new Phrase("Receipt Number ", fntb); ch = new Chunk(receipt.getId(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Rectangle.ALIGN_LEFT); cell.setBorder(Rectangle.NO_BORDER); titleTable.addCell(cell); // phrase = new Phrase(page.getPage_num(), fnt); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT); cell.setBorder(Rectangle.NO_BORDER); titleTable.addCell(cell); // borderTable.addCell(titleTable); float[] width4 = { 25f, 40f, 25f, 10f }; PdfPTable contTable = new PdfPTable(width4); cell = new PdfPCell(new Phrase("Excavation Permit Number", fntb)); contTable.addCell(cell); cell = new PdfPCell(new Phrase("Project", fntb)); contTable.addCell(cell); cell = new PdfPCell(new Phrase("Date Issued", fntb)); contTable.addCell(cell); cell = new PdfPCell(new Phrase("Permit Fee", fntb)); contTable.addCell(cell); List<Permit> permits = page.getPermits(); if (permits != null) { for (Permit permit : permits) { cell = new PdfPCell(new Phrase(permit.getPermit_num(), fnt)); contTable.addCell(cell); phrase = new Phrase(permit.getProject() + "\n", fnt); List<Excavation> cuts = permit.getExcavations(); if (cuts != null) { for (Excavation one : cuts) { ch = new Chunk(one.getAddress() + " (" + one.getCut_type() + ")", fnt); phrase.add(ch); } } cell = new PdfPCell(phrase); contTable.addCell(cell); cell = new PdfPCell(new Phrase(permit.getDate(), fnt)); contTable.addCell(cell); cell = new PdfPCell(new Phrase("$" + permit.getFee(), fnt)); cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT); contTable.addCell(cell); cell = new PdfPCell(new Phrase(spacer, fnt)); // // space line // cell.setColspan(4); contTable.addCell(cell); } } if (page.getNeededLines() > 0) { // first page for (int j = 0; j < page.getNeededLines(); j++) { cell = new PdfPCell(new Phrase(spacer, fnt)); contTable.addCell(cell); contTable.addCell(cell); contTable.addCell(cell); contTable.addCell(cell); } } if (jj == pages.size()) { cell = new PdfPCell(new Phrase("Total Invoice Amount\n" + invoice.getTotal(), fntb)); cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT); cell.setColspan(4); contTable.addCell(cell); } borderTable.addCell(contTable); cell = new PdfPCell(new Phrase("Thank You.", fnt)); cell.setHorizontalAlignment(Rectangle.ALIGN_CENTER); cell.setBorder(Rectangle.NO_BORDER); borderTable.addCell(cell); borderTable.addCell(titleTable); // receipt and date document.add(borderTable); if (jj < pages.size()) { document.newPage(); } } } // document.close(); writer.close(); res.setHeader("Expires", "0"); res.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // res.setHeader("Content-Disposition","attachment; filename="+fileName); res.setHeader("Pragma", "public"); // // setting the content type res.setContentType("application/pdf"); // // the contentlength is needed for MSIE!!! res.setContentLength(baos.size()); // out = res.getOutputStream(); if (out != null) { baos.writeTo(out); } } catch (Exception ex) { logger.error(ex); } }
From source file:s2s.luna.reports.Stampa_documento.java
License:GNU General Public License
@SuppressWarnings("CallToThreadDumpStack") private boolean addPDF(String titolo, byte[] fileContent, Document document, PdfWriter writer) { try {/*ww w. j a v a 2 s .co m*/ // Inizializzo il contenitore del pdf da importare. PdfContentByte cb = writer.getDirectContent(); // Inizializzo la variabile dove appogger (una alla volta) // le pagine del pdf da importare. PdfImportedPage page; // Apro in lettura il pdf da importare. PdfReader pdfReader = new PdfReader(fileContent); // Ne determino il numero di pagine totali. int pdfPageNumber = pdfReader.getNumberOfPages(); // Inzializzo il contatore delle pagine. int pageOfCurrentReaderPDF = 1; // Per ogni pagina... while (pageOfCurrentReaderPDF <= pdfPageNumber) { // Creo una nuova pagina vuota sul pdf di destinazione. document.newPage(); // Estraggo la pagina dal pdf da importare. page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF); // Coverto la pagina in un immagine. Image pageImg = Image.getInstance(page); // Aggiungo la pagina estratta al pdf di destinazione, ruotandola se necessario. PdfPTable table = new PdfPTable(1); PdfPCell defaultCell = table.getDefaultCell(); defaultCell.setRotation(-pdfReader.getPageRotation(pageOfCurrentReaderPDF)); defaultCell.setBorder(Rectangle.NO_BORDER); table.addCell(pageImg); document.add(table); // Incremento il contatore delle pagine pageOfCurrentReaderPDF++; } return true; } catch (Exception ex) { // Eccezione silenziosa. // Gestisce il caso in cui si verifica un errore non previsto ex.printStackTrace(); return false; } }
From source file:s2s.report.MyPageEvents.java
License:GNU General Public License
@Override public void onEndPage(PdfWriter writer, Document m_document) { if ((strBottomLeft.length() == 0) && (strBottomRight.length() == 0) && (bShowDate == false) && strFirstBottomLeft.length() == 0 && strFirstBottomRight.length() == 0) { return;// w w w. j a v a 2 s. com } int iColumns = 0; PdfPTable tbl1 = null; PdfPTable tbl2 = null; // Stampa gli eventuali valori delle celle (sinistra e destra) di un // ulteriore pi di pagina, precedente a quello standard, senza bordi di // tabella. if (strFirstBottomLeft.length() != 0 || strFirstBottomRight.length() != 0) { if (strFirstBottomLeft.length() != 0) { iColumns++; } if (strFirstBottomRight.length() != 0) { iColumns++; } tbl1 = new PdfPTable(iColumns); tbl1.setTotalWidth(m_rect.getWidth() - 60); if (strFirstBottomLeft.length() != 0) { PdfPCell cell = new PdfPCell(new Phrase(strFirstBottomLeft, REPORT_SETTINGS.ftText10)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_LEFT); tbl1.addCell(cell); } if (strFirstBottomRight.length() != 0) { PdfPCell cell = new PdfPCell(new Phrase(strFirstBottomRight, REPORT_SETTINGS.ftText10)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); tbl1.addCell(cell); } } // Stampa gli eventuali valori delle celle (sinistra e destra) // del pi di pagina standard. if ((strBottomLeft.length() != 0) || (strBottomRight.length() != 0) || (bShowDate == true)) { iColumns = 0; if (strBottomLeft.length() != 0) { iColumns++; } if (strBottomRight.length() != 0) { iColumns++; } if (bShowDate) { iColumns++; } tbl2 = new PdfPTable(iColumns); tbl2.setTotalWidth(m_rect.getWidth() - 60); if (strBottomLeft.length() != 0) { tbl2.addCell(new Phrase(strBottomLeft, REPORT_SETTINGS.ftText10)); } if (strBottomRight.length() != 0) { tbl2.addCell(new Phrase(strBottomRight, REPORT_SETTINGS.ftText10)); } if (bShowDate) { PdfPCell pc = new PdfPCell(new Phrase( Formatter.format(new java.sql.Date(System.currentTimeMillis())), REPORT_SETTINGS.ftText11)); pc.setHorizontalAlignment(Element.ALIGN_CENTER); tbl2.addCell(pc); } } // Scrive il pi di pagina precedente a quello standard if (tbl1 != null) { tbl1.writeSelectedRows(0, -1, 30, (tbl2 != null ? 150 : 100), cb); } // Scrive il pi di pagina standard if (tbl2 != null) { tbl2.writeSelectedRows(0, -1, 30, 50, cb); } }
From source file:se.idega.idegaweb.commune.school.business.StudentAddressLabelsWriter.java
License:Open Source License
/** * Adds a student address to the specified document. */// www . ja v a 2s . c o m protected void addAddress(PdfWriter writer, IWResourceBundle iwrb, MailReceiver student, int studentCount) { // User student = member.getStudent(); // Address address = userBusiness.getUsersMainAddress(student); // PostalCode postalCode = address != null ? address.getPostalCode() : null; // String name = student.getFirstName() + " " + student.getLastName(); // String streetAddress = address != null ? address.getStreetAddress() : ""; // String postalAddress = ""; // if (address != null && postalCode != null) { // String zip = postalCode.getPostalCode(); // if (zip.length() > 4) { // zip = zip.substring(0, 3) + " " + zip.substring(3, 5); // } // postalAddress = zip + " " + postalCode.getName(); // } PdfPTable table = new PdfPTable(1); table.setTotalWidth(ADDRESS_TABLE_WIDTH); table.getDefaultCell().setPadding(3); PdfPCell cell; cell = new PdfPCell( new Phrase(iwrb.getLocalizedString(KEY_TO_CUSTODIAN_FOR, "To custodian for") + ":", this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getStudentName(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getStreetAddress(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getPostalAddress(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); int row = (studentCount / NR_OF_COLUMNS) % NR_OF_ROWS; int column = studentCount % NR_OF_COLUMNS; table.writeSelectedRows(0, -1, LEFT_MARGIN + column * ADDRESS_TABLE_WIDTH, TOP_START - row * ADDRESS_TABLE_HEIGHT, writer.getDirectContent()); }
From source file:sms.ReportForms.java
public PdfPCell creatTextCellHeader(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD)); p.add(text);// www.ja va2 s . com cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); return cell; }
From source file:sms.ReportForms.java
public PdfPCell creatTextCellChart(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD)); p.add(text);//from ww w . ja v a 2s . c om cell.addElement(p); cell.setRowspan(2); cell.setBorder(Rectangle.NO_BORDER); return cell; }
From source file:sms.ReportForms.java
public PdfPCell createImageCell(String path) throws IOException { PdfPCell cell = null; try {//w ww .ja v a 2s . co m Image img = Image.getInstance(path); cell = new PdfPCell(img, true); cell.setFixedHeight(60); cell.setBorder(Rectangle.NO_BORDER); } catch (BadElementException ex) { Logger.getLogger(ReportForms.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(ReportForms.class.getName()).log(Level.SEVERE, null, ex); } return cell; }
From source file:sms.ReportForms.java
public PdfPCell createTextCell(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD)); // p.setFont(Font.BOLD); p.setAlignment(Element.ALIGN_CENTER); p.add(text);/*from ww w. j a v a2s .co m*/ cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }