List of usage examples for com.lowagie.text Font NORMAL
int NORMAL
To view the source code for com.lowagie.text Font NORMAL.
Click Source Link
From source file:permit.InvoicePdf.java
License:Open Source License
void writePages(HttpServletResponse res, Invoice invoice) { ////from w w w . j a v a2s . c om // paper size legal (A4) 8.5 x 11 // page 1-inch = 72 points // String fileName = "row_invoice_" + invoice.getInvoice_num() + ".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("INVOICE", 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("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("Status", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk(invoice.getStatus(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("Invoice Date", fntb); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk(invoice.getDate(), fnt); phrase = new Phrase(); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("From ", fntb); phrase = new Phrase(); phrase.add(ch); ch = new Chunk(invoice.getStart_date(), fnt); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // ch = new Chunk("To ", fntb); phrase = new Phrase(); phrase.add(ch); ch = new Chunk(invoice.getEnd_date(), 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++; // float[] widthOne = {100f}; 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("Invoice No. ", fntb); ch = new Chunk(invoice.getInvoice_num(), 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( "Payment due upon receipt. Please Make check payable to 'City of Bloomington'. Thank You.", fnt)); cell.setHorizontalAlignment(Rectangle.ALIGN_CENTER); cell.setBorder(Rectangle.NO_BORDER); borderTable.addCell(cell); borderTable.addCell(titleTable); // invoice 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"); // // if you want for users to download, uncomment the following line // // 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.PermitPdf.java
License:Open Source License
/** * handles the letter header// w w w.j ava 2 s .c om */ 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) { ///* w ww.ja v a 2 s. c om*/ // 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 ww.jav a2 s. c om // 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:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java
License:Open Source License
private Font getFont() throws Exception { BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED); Font f = new Font(bf, 10, Font.NORMAL); return f;// w w w .ja v a 2 s . c o m }
From source file:ro.nextreports.engine.exporter.RtfExporter.java
License:Apache License
private void updateFont(Font fnt, Map<String, Object> style) { if (style != null) { if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) { String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY); fnt.setFamily(val); }/*from ww w. j a v a2s . c om*/ if (style.containsKey(StyleFormatConstants.FONT_SIZE)) { Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE); fnt.setSize(val); } if (style.containsKey(StyleFormatConstants.FONT_COLOR)) { Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR); fnt.setColor(val); } if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) { if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.NORMAL); } if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.BOLD); } if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.ITALIC); } if (StyleFormatConstants.FONT_STYLE_BOLDITALIC .equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.BOLDITALIC); } } } }
From source file:rollyroll.com.servlet.ModuloServlet.java
private void exportar_ModulosaPDF(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try {//from ww w . j av a2s .co m // String[] headers = new String[]{"CODIGO", "NOMBRE", "ACCION", "ORDEN", "ICONO", "ESTADO"}; String[] headers = new String[] { "NOMBRE", "ACCION", "ICONO" }; ArrayList<Modulo> lista = null; lista = moduloService.listar_Modulos(); PdfPTable table = new PdfPTable(headers.length); table.setHorizontalAlignment(0); table.setWidthPercentage(95); float[] espaciocolumna = new float[] { 25f, 38f, 50f }; table.setWidths(espaciocolumna); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 10, Font.BOLD))); table.addCell(cell); } table.completeRow(); PdfPCell cell; // int codigomodulo = 0; String nombremodulo = ""; String accionmodulo = ""; // int ordenmodulo = 0; String iconomodulo = ""; // int estadomodulo = 0; for (Modulo modulo : lista) { // codigomodulo += Integer.parseInt(modulo.getCodigomodulo()); nombremodulo += modulo.getNombremodulo(); accionmodulo += modulo.getAccionmodulo(); // ordenmodulo += Integer.parseInt(modulo.getOrdenmoduloS()); iconomodulo += modulo.getIconomodulo(); // estadomodulo += Byte.parseByte(modulo.getEstadomoduloS()); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getCodigomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); // cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getNombremodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getAccionmodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getOrdenmoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getIconomodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getEstadomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); } table.completeRow(); //incia diseo de documento exportado Document document = new Document(PageSize.A4.rotate(), 20, 5, 5, 5); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); document.addTitle("Reporte de Ventas Generales"); document.add( new Paragraph("Reporte: Ventas Generales 2016", new Font(Font.HELVETICA, 16, Font.UNDERLINE))); document.add(new Paragraph("_")); document.add(table); document.add(Chunk.NEWLINE); document.add(new Paragraph( "Leyenda: AB: Inicio, BA: Retorno (Importante: No se consideran unidades sin GPS)")); document.addAuthor("Quispe Roque Alex Christian"); table = new PdfPTable(4); table.setHorizontalAlignment(0); table.setWidthPercentage(40); espaciocolumna = new float[] { 10f, 40f, 20f, 20f }; table.setWidths(espaciocolumna); cell = new PdfPCell(); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase("RESUMEN", new Font(Font.HELVETICA, 10, Font.BOLD))); cell.setColspan(7); table.addCell(cell); table.completeRow(); //aqui iniciamos asignacion de datos //=================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("FLOTA OPERATIVA", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase(lista.size() + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("UNIDADES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // table.completeRow(); // // //================================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("2", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("NRO DE VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase((totalAB + totalBA) + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // table.completeRow(); //================================================================================== document.add(Chunk.NEWLINE); document.add(table); document.left(1); document.top(1); document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // response.setHeader("Content-Disposition", "attachment; filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Content-Disposition", "filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baos.size()); ServletOutputStream out = response.getOutputStream(); baos.writeTo(out); out.flush(); } catch (Exception e) { RequestDispatcher rd2; rd2 = request.getRequestDispatcher("vista/include/error_404.jsp"); rd2.forward(request, response); System.out.println( "rollyroll.com.servlet.ModuloServlet.exportar_ModulosaPDF() => ERROR GRAVE AL GENERAR PDF"); e.getMessage(); } }
From source file:se.idega.idegaweb.commune.school.report.business.ReportPDFWriter.java
License:Open Source License
private MemoryFileBuffer getPDFBuffer() throws DocumentException { MemoryFileBuffer buffer = new MemoryFileBuffer(); MemoryOutputStream mos = new MemoryOutputStream(buffer); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, mos); String titleKey = this._reportModel.getReportTitleLocalizationKey(); String title = localize(titleKey, titleKey); this._normalFont = new Font(Font.HELVETICA, 7, Font.NORMAL); this._boldFont = new Font(Font.HELVETICA, 7, Font.BOLD); document.addTitle(title);/*from w w w.j a v a 2 s . c o m*/ document.addAuthor("Agura IT Reports"); document.addSubject(title); document.open(); String dateString = new Date(System.currentTimeMillis()).toString(); document.add(new Phrase(title + " " + dateString + "\n\n", this._boldFont)); document.add(new Phrase("\n", this._boldFont)); int cols = this._reportModel.getColumnSize() + 1; Table table = new Table(cols); this._widths = new int[cols]; for (int i = 0; i < cols; i++) { this._widths[i] = 1; } table.setSpacing(1.5f); buildColumnHeaders(table); buildRowHeaders(table); buildReportCells(table); int totalWidth = 0; for (int i = 0; i < cols; i++) { this._widths[i] += 1; totalWidth += this._widths[i]; } int width = (100 * totalWidth) / 95; if (width > 100) { width = 100; } table.setWidth(width); table.setWidths(this._widths); document.add(table); document.close(); writer.setPdfVersion(PdfWriter.VERSION_1_2); return buffer; }
From source file:textdisplay.TagFilter.java
License:Educational Community License
public void replaceTagsWithPDFEncoding(String[] tags, styles[] tagStyles, OutputStream os) throws DocumentException { // FileWriter w = null; try {//w ww . j a v a2s. c o m BaseFont bf = BaseFont.createFont("/usr/Junicode.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Document doc = new Document(); PdfWriter p = PdfWriter.getInstance(doc, os); doc.open(); Paragraph para = new Paragraph(); para.setFont(new Font(bf, 12, Font.NORMAL)); //doc.add(para); Font italic = new Font(bf, 12, Font.ITALIC); Font bold = new Font(bf, 12, Font.BOLD); Font underlined = new Font(bf, 12, Font.UNDERLINE); StringBuilder chunkBuffer = new StringBuilder(""); //holds the next bit of content that will be added to the pdf as a chunk styles chunkStyle = null; //the style to be applied to chunkBuffer when it gets added to the document String chunkTag = ""; Stack<String> wrappingTags = new Stack(); Stack<styles> wrappingStyles = new Stack(); String content = text; Boolean inTag = false; //is this inside a tag, meaning between the < and > String tagTextBuffer = ""; //the text of the tag, including name and any parameters Boolean beingTagged = false; //Is the parser currently reading character data that is surrounded by a tag that demands styling for (int charCounter = 0; charCounter < this.text.length(); charCounter++) { if (text.charAt(charCounter) == '>') { inTag = false; //if this was a self closing tag, dont do anything if (tagTextBuffer.contains("/>")) { tagTextBuffer = ""; } else { //this is a closing tag, save the chunk and pop the tag and style off of the stack if (tagTextBuffer.startsWith("/")) { if (chunkStyle != null) System.out.print(" closing tag " + tagTextBuffer + " with style " + chunkStyle.name() + "\n"); else System.out.print(" closing tag " + tagTextBuffer + " with style null" + "\n"); if (chunkStyle == styles.paragraph) chunkBuffer = new StringBuilder("\n" + chunkBuffer); Chunk c = new Chunk(chunkBuffer.toString()); styleChunk(c, chunkStyle); if (chunkStyle != styles.remove) para.add(c); chunkBuffer = new StringBuilder(""); chunkStyle = null; chunkTag = ""; if (!wrappingStyles.empty()) { chunkStyle = wrappingStyles.pop(); chunkTag = wrappingTags.pop(); } tagTextBuffer = ""; } else { //this is the closing bracket of an opening tag String tagName = tagTextBuffer.split(" ")[0]; System.out.print("tag is " + tagName + "\n"); for (int i = 0; i < tags.length; i++) { if (tags[i].compareTo(tagName) == 0) { // this is a tag that is suposed to be styled in the pdf if (chunkStyle != null) { //this tag is nested in a tag that was already applying styling. Add this chunk to the pdf and put the tag/style //for the previous tag on the stack, so when this new tag ends, the previous styling will resume. if (chunkStyle == styles.paragraph) chunkBuffer = new StringBuilder("\n" + chunkBuffer); Chunk c = new Chunk(chunkBuffer.toString()); styleChunk(c, chunkStyle); if (chunkStyle != styles.remove) para.add(c); wrappingStyles.add(chunkStyle); wrappingTags.add(chunkTag); chunkTag = tagName; chunkStyle = tagStyles[i]; chunkBuffer = new StringBuilder(""); } else { Chunk c = new Chunk(chunkBuffer.toString()); para.add(c); chunkTag = tagName; chunkStyle = tagStyles[i]; chunkBuffer = new StringBuilder(""); } } } tagTextBuffer = ""; } } } if (inTag) { tagTextBuffer += text.charAt(charCounter); } if (text.charAt(charCounter) == '<') { if (inTag) { //if we hit another < before hitting a > this was not a tag, so add the tagTextBuffer to the chunk. It was simply conent. chunkBuffer.append(tagTextBuffer); tagTextBuffer = ""; } inTag = true; } if (!inTag && text.charAt(charCounter) != '>') { chunkBuffer.append(text.charAt(charCounter)); } } Chunk c = new Chunk(chunkBuffer.toString()); para.add(c); doc.newPage(); doc.add(para); doc.newPage(); doc.close(); } catch (IOException ex) { Logger.getLogger(TagFilter.class.getName()).log(Level.SEVERE, null, ex); } finally { } }
From source file:textdisplay.TagFilter.java
License:Educational Community License
/**Apply a style (font) to a chunk of pdf text*/ private void styleChunk(Chunk c, styles s) { try {//from www . j a v a2 s. com BaseFont bf = BaseFont.createFont("/usr/Junicode.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); BaseFont ita = BaseFont.createFont("/usr/Junicode-Italic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); BaseFont bol = BaseFont.createFont("/usr/Junicode-Italic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); if (bf.charExists(540)) { System.out.print("font cant do 540\n"); } Font italic = new Font(ita, 12, Font.ITALIC); Font bold = new Font(bol, 12, Font.BOLD); Font underlined = new Font(bf, 12, Font.UNDERLINE); Font superscript = new Font(bf, 9, Font.NORMAL); if (s == styles.bold) { c.setFont(bold); } if (s == styles.italic) { c.setFont(italic); } if (s == styles.underlined) { c.setFont(underlined); } if (s == styles.superscript) { c.setTextRise(7.0f); c.setFont(superscript); } //wipe out that content } catch (DocumentException ex) { Logger.getLogger(TagFilter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(TagFilter.class.getName()).log(Level.SEVERE, null, ex); } }