List of usage examples for com.lowagie.text Paragraph setIndentationLeft
public void setIndentationLeft(float indentation)
From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
/** * Renders a Cell for//ww w . j a va 2 s . c om * * @param label * @param header * @param depth * @param leaf * @param horizantalAlignment * @return * @throws BadElementException */ public static Cell bodyCell(String label, boolean header, int depth, boolean leaf, int horizantalAlignment) throws BadElementException { Cell cell = new Cell(); cell.setHorizontalAlignment(horizantalAlignment); if (label != null) { Paragraph para = new Paragraph(label); Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK); if (depth == 0 && !leaf) { font.setColor(Color.WHITE); } para.setFont(font); para.setIndentationLeft(5.4f + (header ? 12 * depth : 0)); cell.addElement(para); } cell.setBorderWidthLeft(0f); cell.setBorderWidthRight(0); cell.setBorderWidthTop(0); if (!leaf && depth == 0) { cell.setBackgroundColor(new Color(149, 179, 215)); // #95B3D7 cell.setBorderWidthBottom(0.5f); cell.setBorderColorBottom(new Color(219, 229, 241)); // #DBE5F1 } else if (!leaf && depth == 1) { cell.setBackgroundColor(new Color(219, 229, 241)); cell.setBorderWidthBottom(0.5f); cell.setBorderColorBottom(new Color(79, 129, 189)); } else { cell.setBorderWidthBottom(0.5f); cell.setBorderColorBottom(new Color(219, 229, 241)); cell.setBorderWidthTop(0.5f); cell.setBorderColorTop(new Color(219, 229, 241)); } return cell; }
From source file:permit.PermitPdf.java
License:Open Source License
void writePage(HttpServletResponse res, Permit permit) { ////w w w .jav a2s . 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:s2s.report.MiddleTable.java
License:GNU General Public License
public void addCell1(String strTitle) throws BadElementException { Paragraph prTitle = new Paragraph(strTitle.trim(), REPORT_SETTINGS.ftParagraph3); prTitle.setIndentationLeft(15f); super.addCell(prTitle); }
From source file:s2s.report.MiddleTable.java
License:GNU General Public License
public void addCell2(String strTitle1) throws BadElementException { Paragraph prTitle1 = new Paragraph(strTitle1.trim(), REPORT_SETTINGS.ftParagraph2); prTitle1.setIndentationLeft(10f); super.addCell(prTitle1); }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagrafo(String strName) throws BadElementException, DocumentException { Paragraph pr = new Paragraph("", REPORT_SETTINGS.ftParagraph2); //pr.setIndentationLeft(10f); Paragraph pr1 = new Paragraph(strName, REPORT_SETTINGS.ftTableHeader); pr1.setIndentationLeft(10f); Cell cl = new Cell(pr1); cl.setBackgroundColor(REPORT_SETTINGS.clTableHeader); CenterMiddleTable tbl = new CenterMiddleTable(1); tbl.toLeft();/*w ww . ja v a 2 s .c o m*/ tbl.addCell(cl); pr.add(tbl); m_document.add(pr); }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagraph2(String strText) throws BadElementException, DocumentException { Paragraph pr = new Paragraph(strText != null ? strText.trim() : "", REPORT_SETTINGS.ftParagraph2); pr.setAlignment(Element.ALIGN_JUSTIFIED); pr.setIndentationLeft(10f); m_document.add(pr);//from ww w .j ava 2 s . c o m }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagraph3(String strText) throws BadElementException, DocumentException { Paragraph pr = new Paragraph(strText != null ? strText.trim() : "", REPORT_SETTINGS.ftParagraph3); pr.setAlignment(Element.ALIGN_JUSTIFIED); pr.setIndentationLeft(15f); m_document.add(pr);/*from w w w .j av a 2s . co m*/ }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagraph3(String strText, int iLevel) throws BadElementException, DocumentException { Paragraph pr = new Paragraph(strText != null ? strText.trim() : "", REPORT_SETTINGS.ftParagraph3); pr.setIndentationLeft(5 * iLevel); m_document.add(pr);//from w w w.j a va 2s .c om }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagraph3_1(String strText) throws BadElementException, DocumentException { Paragraph pr = new Paragraph(strText != null ? strText.trim() : "", REPORT_SETTINGS.ftParagraph3_1); pr.setIndentationLeft(15f); m_document.add(pr);/* w w w . ja v a 2 s . c o m*/ }
From source file:s2s.report.Report.java
License:GNU General Public License
public void writeParagraph3_2(String strText) throws BadElementException, DocumentException { Paragraph pr = new Paragraph(strText != null ? strText.trim() : "", REPORT_SETTINGS.ftParagraph3_2); pr.setIndentationLeft(15f); m_document.add(pr);//from w w w .j a va 2 s . c om }